mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
selection: mark_selected_region(): use an enum to encode how the cells are to be updated
This commit is contained in:
parent
db2737b96a
commit
d5df86f785
1 changed files with 20 additions and 7 deletions
27
selection.c
27
selection.c
|
|
@ -711,11 +711,26 @@ pixman_region_for_coords(const struct terminal *term,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum mark_selection_variant {
|
||||||
|
MARK_SELECTION_MARK_AND_DIRTY,
|
||||||
|
MARK_SELECTION_UNMARK_AND_DIRTY,
|
||||||
|
MARK_SELECTION_MARK_FOR_RENDER,
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mark_selected_region(struct terminal *term, pixman_box32_t *boxes,
|
mark_selected_region(struct terminal *term, pixman_box32_t *boxes,
|
||||||
size_t count, bool selected, bool dirty_cells,
|
size_t count, enum mark_selection_variant mark_variant)
|
||||||
bool highlight_empty)
|
|
||||||
{
|
{
|
||||||
|
const bool selected =
|
||||||
|
mark_variant == MARK_SELECTION_MARK_AND_DIRTY ||
|
||||||
|
mark_variant == MARK_SELECTION_MARK_FOR_RENDER;
|
||||||
|
const bool dirty_cells =
|
||||||
|
mark_variant == MARK_SELECTION_MARK_AND_DIRTY ||
|
||||||
|
mark_variant == MARK_SELECTION_UNMARK_AND_DIRTY;
|
||||||
|
const bool highlight_empty =
|
||||||
|
mark_variant != MARK_SELECTION_MARK_FOR_RENDER ||
|
||||||
|
term->selection.kind == SELECTION_BLOCK;
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
const pixman_box32_t *box = &boxes[i];
|
const pixman_box32_t *box = &boxes[i];
|
||||||
|
|
||||||
|
|
@ -842,10 +857,10 @@ selection_modify(struct terminal *term, struct coord start, struct coord end)
|
||||||
pixman_box32_t *boxes = NULL;
|
pixman_box32_t *boxes = NULL;
|
||||||
|
|
||||||
boxes = pixman_region32_rectangles(&no_longer_selected, &n_rects);
|
boxes = pixman_region32_rectangles(&no_longer_selected, &n_rects);
|
||||||
mark_selected_region(term, boxes, n_rects, false, true, true);
|
mark_selected_region(term, boxes, n_rects, MARK_SELECTION_UNMARK_AND_DIRTY);
|
||||||
|
|
||||||
boxes = pixman_region32_rectangles(&newly_selected, &n_rects);
|
boxes = pixman_region32_rectangles(&newly_selected, &n_rects);
|
||||||
mark_selected_region(term, boxes, n_rects, true, true, true);
|
mark_selected_region(term, boxes, n_rects, MARK_SELECTION_MARK_AND_DIRTY);
|
||||||
|
|
||||||
pixman_region32_fini(&newly_selected);
|
pixman_region32_fini(&newly_selected);
|
||||||
pixman_region32_fini(&no_longer_selected);
|
pixman_region32_fini(&no_longer_selected);
|
||||||
|
|
@ -1110,9 +1125,7 @@ selection_dirty_cells(struct terminal *term)
|
||||||
int n_rects = -1;
|
int n_rects = -1;
|
||||||
pixman_box32_t *boxes =
|
pixman_box32_t *boxes =
|
||||||
pixman_region32_rectangles(&visible_and_selected, &n_rects);
|
pixman_region32_rectangles(&visible_and_selected, &n_rects);
|
||||||
|
mark_selected_region(term, boxes, n_rects, MARK_SELECTION_MARK_FOR_RENDER);
|
||||||
const bool highlight_empty = term->selection.kind == SELECTION_BLOCK;
|
|
||||||
mark_selected_region(term, boxes, n_rects, true, false, highlight_empty);
|
|
||||||
|
|
||||||
pixman_region32_fini(&visible_and_selected);
|
pixman_region32_fini(&visible_and_selected);
|
||||||
pixman_region32_fini(&view);
|
pixman_region32_fini(&view);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue