mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
selection: track selection type; normal or block selection
This commit is contained in:
parent
1178a7763b
commit
d706e68280
5 changed files with 18 additions and 7 deletions
4
input.c
4
input.c
|
|
@ -581,7 +581,9 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
if (button == BTN_LEFT) {
|
if (button == BTN_LEFT) {
|
||||||
switch (wayl->mouse.count) {
|
switch (wayl->mouse.count) {
|
||||||
case 1:
|
case 1:
|
||||||
selection_start(term, wayl->mouse.col, wayl->mouse.row);
|
selection_start(
|
||||||
|
term, wayl->mouse.col, wayl->mouse.row,
|
||||||
|
wayl->kbd.ctrl ? SELECTION_BLOCK : SELECTION_NORMAL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
|
||||||
2
search.c
2
search.c
|
|
@ -138,7 +138,7 @@ search_update_selection(struct terminal *term,
|
||||||
|
|
||||||
assert(selection_row >= 0 &&
|
assert(selection_row >= 0 &&
|
||||||
selection_row < term->grid->num_rows);
|
selection_row < term->grid->num_rows);
|
||||||
selection_start(term, start_col, selection_row);
|
selection_start(term, start_col, selection_row, SELECTION_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update selection endpoint */
|
/* Update selection endpoint */
|
||||||
|
|
|
||||||
13
selection.c
13
selection.c
|
|
@ -126,14 +126,19 @@ extract_selection(const struct terminal *term)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
selection_start(struct terminal *term, int col, int row)
|
selection_start(struct terminal *term, int col, int row,
|
||||||
|
enum selection_kind kind)
|
||||||
{
|
{
|
||||||
if (!selection_enabled(term))
|
if (!selection_enabled(term))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
selection_cancel(term);
|
selection_cancel(term);
|
||||||
|
|
||||||
LOG_DBG("selection started at %d,%d", row, col);
|
LOG_DBG("%s selection started at %d,%d",
|
||||||
|
kind == SELECTION_NORMAL ? "normal" :
|
||||||
|
kind == SELECTION_BLOCK ? "block" : "<unknown>",
|
||||||
|
row, col);
|
||||||
|
term->selection.kind = kind;
|
||||||
term->selection.start = (struct coord){col, term->grid->view + row};
|
term->selection.start = (struct coord){col, term->grid->view + row};
|
||||||
term->selection.end = (struct coord){-1, -1};
|
term->selection.end = (struct coord){-1, -1};
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +292,7 @@ selection_mark_word(struct terminal *term, int col, int row, bool spaces_only,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selection_start(term, start.col, start.row);
|
selection_start(term, start.col, start.row, SELECTION_NORMAL);
|
||||||
selection_update(term, end.col, end.row);
|
selection_update(term, end.col, end.row);
|
||||||
selection_finalize(term, serial);
|
selection_finalize(term, serial);
|
||||||
}
|
}
|
||||||
|
|
@ -295,7 +300,7 @@ selection_mark_word(struct terminal *term, int col, int row, bool spaces_only,
|
||||||
void
|
void
|
||||||
selection_mark_row(struct terminal *term, int row, uint32_t serial)
|
selection_mark_row(struct terminal *term, int row, uint32_t serial)
|
||||||
{
|
{
|
||||||
selection_start(term, 0, row);
|
selection_start(term, 0, row, SELECTION_NORMAL);
|
||||||
selection_update(term, term->cols - 1, row);
|
selection_update(term, term->cols - 1, row);
|
||||||
selection_finalize(term, serial);
|
selection_finalize(term, serial);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ extern const struct wl_data_device_listener data_device_listener;
|
||||||
extern const struct zwp_primary_selection_device_v1_listener primary_selection_device_listener;
|
extern const struct zwp_primary_selection_device_v1_listener primary_selection_device_listener;
|
||||||
|
|
||||||
bool selection_enabled(const struct terminal *term);
|
bool selection_enabled(const struct terminal *term);
|
||||||
void selection_start(struct terminal *term, int col, int row);
|
void selection_start(
|
||||||
|
struct terminal *term, int col, int row, enum selection_kind kind);
|
||||||
void selection_update(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_finalize(struct terminal *term, uint32_t serial);
|
||||||
void selection_cancel(struct terminal *term);
|
void selection_cancel(struct terminal *term);
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,8 @@ enum mouse_reporting {
|
||||||
|
|
||||||
enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BAR };
|
enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BAR };
|
||||||
|
|
||||||
|
enum selection_kind { SELECTION_NORMAL, SELECTION_BLOCK };
|
||||||
|
|
||||||
struct ptmx_buffer {
|
struct ptmx_buffer {
|
||||||
void *data;
|
void *data;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
@ -248,6 +250,7 @@ struct terminal {
|
||||||
const char *xcursor;
|
const char *xcursor;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
enum selection_kind kind;
|
||||||
struct coord start;
|
struct coord start;
|
||||||
struct coord end;
|
struct coord end;
|
||||||
} selection;
|
} selection;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue