aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-08-14 07:56:14 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-08-16 17:15:52 +0000
commitf0fd3b7578c1868b62db647a60ecf15cd9ed06f3 (patch)
treeda1447ab0b64b288a1e8e66403613f93e731e913
parentselection: don’t require two cell attr bits for selection updating (diff)
selection: modify: replace reset_context() macro with a function
-rw-r--r--selection.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/selection.c b/selection.c
index 365975f0..f47e4920 100644
--- a/selection.c
+++ b/selection.c
@@ -537,17 +537,19 @@ mark_selected(struct terminal *term, struct row *row, struct cell *cell,
}
static void
+reset_modify_context(struct mark_context *ctx)
+{
+ ctx->last_row = NULL;
+ ctx->empty_count = 0;
+}
+
+static void
selection_modify(struct terminal *term, struct coord start, struct coord end)
{
xassert(term->selection.start.row != -1);
xassert(start.row != -1 && start.col != -1);
xassert(end.row != -1 && end.col != -1);
-#define reset_context() do { \
- ctx.last_row = NULL; \
- ctx.empty_count = 0; \
- } while (0)
-
uint64_t **keep_selection =
xcalloc(term->grid->num_rows, sizeof(keep_selection[0]));
@@ -555,14 +557,14 @@ selection_modify(struct terminal *term, struct coord start, struct coord end)
/* Premark all cells that *will* be selected */
foreach_selected(term, start, end, &premark_selected, &ctx);
- reset_context();
+ reset_modify_context(&ctx);
if (term->selection.end.row >= 0) {
/* Unmark previous selection, ignoring cells that are part of
* the new selection */
foreach_selected(term, term->selection.start, term->selection.end,
&unmark_selected, &ctx);
- reset_context();
+ reset_modify_context(&ctx);
}
term->selection.start = start;
@@ -578,8 +580,6 @@ selection_modify(struct terminal *term, struct coord start, struct coord end)
free(keep_selection[i]);
}
free(keep_selection);
-
-#undef reset_context
}
static void