mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
selection/input: triple click selects an entire row
This commit is contained in:
parent
ae84f0ee00
commit
481a1cd678
4 changed files with 32 additions and 12 deletions
34
input.c
34
input.c
|
|
@ -403,27 +403,37 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
|||
|
||||
switch (state) {
|
||||
case WL_POINTER_BUTTON_STATE_PRESSED: {
|
||||
bool double_click = false;
|
||||
|
||||
struct timeval now;
|
||||
/* Time since last click */
|
||||
struct timeval now, since_last;
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
struct timeval since_last;
|
||||
timersub(&now, &term->mouse.last_time, &since_last);
|
||||
|
||||
/* Double- or triple click? */
|
||||
if (button == term->mouse.last_button &&
|
||||
since_last.tv_sec == 0 && since_last.tv_usec <= 300 * 1000)
|
||||
since_last.tv_sec == 0 &&
|
||||
since_last.tv_usec <= 300 * 1000)
|
||||
{
|
||||
double_click = true;
|
||||
}
|
||||
term->mouse.count++;
|
||||
} else
|
||||
term->mouse.count = 1;
|
||||
|
||||
if (button == BTN_LEFT) {
|
||||
if (double_click)
|
||||
switch (term->mouse.count) {
|
||||
case 1:
|
||||
selection_start(term, term->mouse.col, term->mouse.row);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
selection_mark_word(term, term->mouse.col, term->mouse.row,
|
||||
term->kbd.ctrl, serial);
|
||||
else
|
||||
selection_start(term, term->mouse.col, term->mouse.row);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
selection_mark_row(term, term->mouse.row, serial);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (button == BTN_MIDDLE)
|
||||
if (term->mouse.count == 1 && button == BTN_MIDDLE)
|
||||
selection_from_primary(term);
|
||||
selection_cancel(term);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -333,6 +333,14 @@ selection_mark_word(struct terminal *term, int col, int row, bool spaces_only,
|
|||
selection_finalize(term, serial);
|
||||
}
|
||||
|
||||
void
|
||||
selection_mark_row(struct terminal *term, int row, uint32_t serial)
|
||||
{
|
||||
selection_start(term, 0, row);
|
||||
selection_update(term, term->cols - 1, row);
|
||||
selection_finalize(term, serial);
|
||||
}
|
||||
|
||||
static void
|
||||
target(void *data, struct wl_data_source *wl_data_source, const char *mime_type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ void selection_finalize(struct terminal *term, uint32_t serial);
|
|||
void selection_cancel(struct terminal *term);
|
||||
void selection_mark_word(struct terminal *term, int col, int row,
|
||||
bool spaces_only, uint32_t serial);
|
||||
void selection_mark_row(struct terminal *term, int row, uint32_t serial);
|
||||
|
||||
void selection_to_clipboard(struct terminal *term, uint32_t serial);
|
||||
void selection_from_clipboard(struct terminal *term, uint32_t serial);
|
||||
|
|
|
|||
|
|
@ -273,6 +273,7 @@ struct terminal {
|
|||
int row;
|
||||
int button;
|
||||
|
||||
int count;
|
||||
int last_button;
|
||||
struct timeval last_time;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue