aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-11 07:57:04 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-11 15:38:01 +0000
commitd944274f14dc15eba141d1add6fc5a093dd0f4e8 (patch)
tree4e8a5ab85b06fe8494c8bf1ac3844714d93bd2dd
parentselection: add a selection API (diff)
selection: disable selection when client has enabled mouse tracking
-rw-r--r--selection.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/selection.c b/selection.c
index b0b688b9..96738a82 100644
--- a/selection.c
+++ b/selection.c
@@ -8,9 +8,18 @@
#define min(x, y) ((x) < (y) ? (x) : (y))
#define max(x, y) ((x) > (y) ? (x) : (y))
+static bool
+selection_enabled(const struct terminal *term)
+{
+ return term->mouse_tracking == MOUSE_NONE;
+}
+
void
selection_start(struct terminal *term, int col, int row)
{
+ if (!selection_enabled(term))
+ return;
+
selection_cancel(term);
LOG_DBG("selection started at %d,%d", row, col);
@@ -21,6 +30,9 @@ selection_start(struct terminal *term, int col, int row)
void
selection_update(struct terminal *term, int col, int row)
{
+ if (!selection_enabled(term))
+ return;
+
LOG_DBG("selection updated: start = %d,%d, end = %d,%d -> %d, %d",
term->selection.start.row, term->selection.start.col,
term->selection.end.row, term->selection.end.col,
@@ -41,6 +53,9 @@ selection_update(struct terminal *term, int col, int row)
void
selection_finalizie(struct terminal *term)
{
+ if (!selection_enabled(term))
+ return;
+
assert(term->selection.start.row != -1);
assert(term->selection.end.row != -1);
}
@@ -48,6 +63,9 @@ selection_finalizie(struct terminal *term)
void
selection_cancel(struct terminal *term)
{
+ if (!selection_enabled(term))
+ return;
+
LOG_DBG("selection cancelled: start = %d,%d end = %d,%d",
term->selection.start.row, term->selection.start.col,
term->selection.end.row, term->selection.end.col);