mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-27 07:58:07 -04:00
selection: modify: replace reset_context() macro with a function
This commit is contained in:
parent
ae70596a50
commit
f0fd3b7578
1 changed files with 9 additions and 9 deletions
18
selection.c
18
selection.c
|
|
@ -536,6 +536,13 @@ mark_selected(struct terminal *term, struct row *row, struct cell *cell,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
reset_modify_context(struct mark_context *ctx)
|
||||||
|
{
|
||||||
|
ctx->last_row = NULL;
|
||||||
|
ctx->empty_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
selection_modify(struct terminal *term, struct coord start, struct coord end)
|
selection_modify(struct terminal *term, struct coord start, struct coord end)
|
||||||
{
|
{
|
||||||
|
|
@ -543,11 +550,6 @@ selection_modify(struct terminal *term, struct coord start, struct coord end)
|
||||||
xassert(start.row != -1 && start.col != -1);
|
xassert(start.row != -1 && start.col != -1);
|
||||||
xassert(end.row != -1 && end.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 =
|
uint64_t **keep_selection =
|
||||||
xcalloc(term->grid->num_rows, sizeof(keep_selection[0]));
|
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 */
|
/* Premark all cells that *will* be selected */
|
||||||
foreach_selected(term, start, end, &premark_selected, &ctx);
|
foreach_selected(term, start, end, &premark_selected, &ctx);
|
||||||
reset_context();
|
reset_modify_context(&ctx);
|
||||||
|
|
||||||
if (term->selection.end.row >= 0) {
|
if (term->selection.end.row >= 0) {
|
||||||
/* Unmark previous selection, ignoring cells that are part of
|
/* Unmark previous selection, ignoring cells that are part of
|
||||||
* the new selection */
|
* the new selection */
|
||||||
foreach_selected(term, term->selection.start, term->selection.end,
|
foreach_selected(term, term->selection.start, term->selection.end,
|
||||||
&unmark_selected, &ctx);
|
&unmark_selected, &ctx);
|
||||||
reset_context();
|
reset_modify_context(&ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
term->selection.start = start;
|
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[i]);
|
||||||
}
|
}
|
||||||
free(keep_selection);
|
free(keep_selection);
|
||||||
|
|
||||||
#undef reset_context
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue