aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--input.c3
-rw-r--r--selection.c16
-rw-r--r--selection.h4
3 files changed, 15 insertions, 8 deletions
diff --git a/input.c b/input.c
index 596bce1f..9eb0161d 100644
--- a/input.c
+++ b/input.c
@@ -408,7 +408,8 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
if (button == BTN_LEFT) {
if (double_click)
- selection_mark_word(term, term->mouse.col, term->mouse.row, serial);
+ selection_mark_word(term, term->mouse.col, term->mouse.row,
+ term->kbd.ctrl, serial);
else
selection_start(term, term->mouse.col, term->mouse.row);
} else {
diff --git a/selection.c b/selection.c
index 7a0d6960..92beafe5 100644
--- a/selection.c
+++ b/selection.c
@@ -225,8 +225,11 @@ selection_cancel(struct terminal *term)
}
static bool
-isword(wint_t c)
+isword(wint_t c, bool spaces_only)
{
+ if (spaces_only)
+ return !iswspace(c);
+
switch (c) {
default: return !iswspace(c);
@@ -243,7 +246,8 @@ isword(wint_t c)
}
void
-selection_mark_word(struct terminal *term, int col, int row, uint32_t serial)
+selection_mark_word(struct terminal *term, int col, int row, bool spaces_only,
+ uint32_t serial)
{
if (!selection_enabled(term))
return;
@@ -256,7 +260,7 @@ selection_mark_word(struct terminal *term, int col, int row, uint32_t serial)
const struct row *r = grid_row_in_view(term->grid, start.row);
wchar_t c = r->cells[start.col].wc;
- if (!(c == 0 || !isword(c))) {
+ if (!(c == 0 || !isword(c, spaces_only))) {
while (true) {
int next_col = start.col - 1;
int next_row = start.row;
@@ -271,7 +275,7 @@ selection_mark_word(struct terminal *term, int col, int row, uint32_t serial)
const struct row *row = grid_row_in_view(term->grid, next_row);
c = row->cells[next_col].wc;
- if (c == 0 || !isword(c))
+ if (c == 0 || !isword(c, spaces_only))
break;
start.col = next_col;
@@ -282,7 +286,7 @@ selection_mark_word(struct terminal *term, int col, int row, uint32_t serial)
r = grid_row_in_view(term->grid, end.row);
c = r->cells[end.col].wc;
- if (!(c == 0 || !isword(c))) {
+ if (!(c == 0 || !isword(c, spaces_only))) {
while (true) {
int next_col = end.col + 1;
int next_row = end.row;
@@ -297,7 +301,7 @@ selection_mark_word(struct terminal *term, int col, int row, uint32_t serial)
const struct row *row = grid_row_in_view(term->grid, next_row);
c = row->cells[next_col].wc;
- if (c == '\0' || !isword(c))
+ if (c == '\0' || !isword(c, spaces_only))
break;
end.col = next_col;
diff --git a/selection.h b/selection.h
index 8473dbfa..9d712da1 100644
--- a/selection.h
+++ b/selection.h
@@ -1,5 +1,6 @@
#pragma once
+#include <stdbool.h>
#include <wayland-client.h>
#include "terminal.h"
@@ -11,7 +12,8 @@ void selection_start(struct terminal *term, int col, int row);
void selection_update(struct terminal *term, int col, int row);
void selection_finalize(struct terminal *term, uint32_t serial);
void selection_cancel(struct terminal *term);
-void selection_mark_word(struct terminal *term, int col, int row, uint32_t serial);
+void selection_mark_word(struct terminal *term, int col, int row,
+ bool spaces_only, uint32_t serial);
void selection_to_clipboard(struct terminal *term, uint32_t serial);
void selection_from_clipboard(struct terminal *term, uint32_t serial);