mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-22 05:33:45 -04:00
input: bindings: calculate 'cursor_is_on_grid' once only
This commit is contained in:
parent
2764a8394a
commit
bb9228dd21
1 changed files with 8 additions and 18 deletions
26
input.c
26
input.c
|
|
@ -81,6 +81,8 @@ execute_binding(struct seat *seat, struct terminal *term,
|
||||||
enum bind_action_normal action, char *const *pipe_argv,
|
enum bind_action_normal action, char *const *pipe_argv,
|
||||||
uint32_t serial)
|
uint32_t serial)
|
||||||
{
|
{
|
||||||
|
const bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case BIND_ACTION_NONE:
|
case BIND_ACTION_NONE:
|
||||||
break;
|
break;
|
||||||
|
|
@ -254,57 +256,45 @@ execute_binding(struct seat *seat, struct terminal *term,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case BIND_ACTION_SELECT_BEGIN: {
|
case BIND_ACTION_SELECT_BEGIN:
|
||||||
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
|
||||||
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
||||||
selection_start(
|
selection_start(
|
||||||
term, seat->mouse.col, seat->mouse.row, SELECTION_NORMAL);
|
term, seat->mouse.col, seat->mouse.row, SELECTION_NORMAL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case BIND_ACTION_SELECT_BEGIN_BLOCK: {
|
case BIND_ACTION_SELECT_BEGIN_BLOCK:
|
||||||
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
|
||||||
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
||||||
selection_start(
|
selection_start(
|
||||||
term, seat->mouse.col, seat->mouse.row, SELECTION_BLOCK);
|
term, seat->mouse.col, seat->mouse.row, SELECTION_BLOCK);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case BIND_ACTION_SELECT_EXTEND: {
|
case BIND_ACTION_SELECT_EXTEND:
|
||||||
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
|
||||||
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
||||||
selection_extend(
|
selection_extend(
|
||||||
seat, term, seat->mouse.col, seat->mouse.row, serial);
|
seat, term, seat->mouse.col, seat->mouse.row, serial);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case BIND_ACTION_SELECT_WORD: {
|
case BIND_ACTION_SELECT_WORD:
|
||||||
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
|
||||||
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
||||||
selection_mark_word(
|
selection_mark_word(
|
||||||
seat, term, seat->mouse.col, seat->mouse.row, false, serial);
|
seat, term, seat->mouse.col, seat->mouse.row, false, serial);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case BIND_ACTION_SELECT_WORD_WS: {
|
case BIND_ACTION_SELECT_WORD_WS:
|
||||||
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
|
||||||
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
||||||
selection_mark_word(
|
selection_mark_word(
|
||||||
seat, term, seat->mouse.col, seat->mouse.row, true, serial);
|
seat, term, seat->mouse.col, seat->mouse.row, true, serial);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case BIND_ACTION_SELECT_ROW: {
|
case BIND_ACTION_SELECT_ROW:
|
||||||
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
|
||||||
if (selection_enabled(term, seat) && cursor_is_on_grid)
|
if (selection_enabled(term, seat) && cursor_is_on_grid)
|
||||||
selection_mark_row(seat, term, seat->mouse.row, serial);
|
selection_mark_row(seat, term, seat->mouse.row, serial);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case BIND_ACTION_COUNT:
|
case BIND_ACTION_COUNT:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue