aboutsummaryrefslogtreecommitdiff
path: root/selection.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-05-17 16:20:12 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-05-17 16:20:12 +0000
commit3da8dc123f998113109e80912588fff0a9fbef92 (patch)
treea1614644f672834da37177777583d5639ee2861b /selection.c
parentMerge branch 'box-drawing-use-pixman' (diff)
parentchangelog: ctrl+w can now be used across lines (diff)
Merge branch 'search-refactor-extend-word'
Closes #421
Diffstat (limited to 'selection.c')
-rw-r--r--selection.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/selection.c b/selection.c
index 5bb386ab..f684c2fa 100644
--- a/selection.c
+++ b/selection.c
@@ -215,7 +215,7 @@ selection_to_text(const struct terminal *term)
if (term->selection.end.row == -1)
return NULL;
- struct extraction_context *ctx = extract_begin(term->selection.kind);
+ struct extraction_context *ctx = extract_begin(term->selection.kind, true);
if (ctx == NULL)
return NULL;
@@ -227,9 +227,9 @@ selection_to_text(const struct terminal *term)
return extract_finish(ctx, &text, NULL) ? text : NULL;
}
-static void
-find_word_boundary_left(struct terminal *term, struct coord *pos,
- bool spaces_only)
+void
+selection_find_word_boundary_left(struct terminal *term, struct coord *pos,
+ bool spaces_only)
{
const struct row *r = grid_row_in_view(term->grid, pos->row);
wchar_t c = r->cells[pos->col].wc;
@@ -299,9 +299,9 @@ find_word_boundary_left(struct terminal *term, struct coord *pos,
}
}
-static void
-find_word_boundary_right(struct terminal *term, struct coord *pos,
- bool spaces_only)
+void
+selection_find_word_boundary_right(struct terminal *term, struct coord *pos,
+ bool spaces_only)
{
const struct row *r = grid_row_in_view(term->grid, pos->row);
wchar_t c = r->cells[pos->col].wc;
@@ -403,8 +403,8 @@ selection_start(struct terminal *term, int col, int row,
case SELECTION_WORD_WISE: {
struct coord start = {col, row}, end = {col, row};
- find_word_boundary_left(term, &start, spaces_only);
- find_word_boundary_right(term, &end, spaces_only);
+ selection_find_word_boundary_left(term, &start, spaces_only);
+ selection_find_word_boundary_right(term, &end, spaces_only);
term->selection.start = (struct coord){
start.col, term->grid->view + start.row};
@@ -694,14 +694,16 @@ selection_update(struct terminal *term, int col, int row)
switch (term->selection.direction) {
case SELECTION_LEFT: {
struct coord end = {col, row};
- find_word_boundary_left(term, &end, term->selection.spaces_only);
+ selection_find_word_boundary_left(
+ term, &end, term->selection.spaces_only);
new_end = (struct coord){end.col, term->grid->view + end.row};
break;
}
case SELECTION_RIGHT: {
struct coord end = {col, row};
- find_word_boundary_right(term, &end, term->selection.spaces_only);
+ selection_find_word_boundary_right(
+ term, &end, term->selection.spaces_only);
new_end = (struct coord){end.col, term->grid->view + end.row};
break;
}
@@ -840,8 +842,10 @@ selection_extend_normal(struct terminal *term, int col, int row,
struct coord pivot_start = {new_start.col, new_start.row - term->grid->view};
struct coord pivot_end = pivot_start;
- find_word_boundary_left(term, &pivot_start, term->selection.spaces_only);
- find_word_boundary_right(term, &pivot_end, term->selection.spaces_only);
+ selection_find_word_boundary_left(
+ term, &pivot_start, term->selection.spaces_only);
+ selection_find_word_boundary_right(
+ term, &pivot_end, term->selection.spaces_only);
term->selection.pivot.start =
(struct coord){pivot_start.col, term->grid->view + pivot_start.row};