mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-15 05:33:58 -04:00
config: add ‘select-extend-character-wise’ bind action
This forces the (new) selection mode to be character-wise when extending a word- or line-wise selection. Default key binding is ctrl+RMB.
This commit is contained in:
parent
2e46811953
commit
767bd4f1db
8 changed files with 65 additions and 18 deletions
|
|
@ -34,6 +34,8 @@
|
||||||
`vertical-letter-offset` to `foot.ini`. These options let you tweak
|
`vertical-letter-offset` to `foot.ini`. These options let you tweak
|
||||||
cell size and glyph positioning
|
cell size and glyph positioning
|
||||||
(https://codeberg.org/dnkl/foot/issues/244).
|
(https://codeberg.org/dnkl/foot/issues/244).
|
||||||
|
* Key/mouse binding `select-extend-character-wise`, which forces the
|
||||||
|
selection mode to 'character-wise' when extending a selection.
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
@ -49,6 +51,8 @@
|
||||||
word- or line-wise (https://codeberg.org/dnkl/foot/issues/267).
|
word- or line-wise (https://codeberg.org/dnkl/foot/issues/267).
|
||||||
* The line thickness of box drawing characters now depend on the font
|
* The line thickness of box drawing characters now depend on the font
|
||||||
size (https://codeberg.org/dnkl/foot/issues/281).
|
size (https://codeberg.org/dnkl/foot/issues/281).
|
||||||
|
* Extending a word/line-wise selection now uses the original selection
|
||||||
|
mode instead of switching to character-wise.
|
||||||
|
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
|
||||||
2
config.c
2
config.c
|
|
@ -80,6 +80,7 @@ static const char *const binding_action_map[] = {
|
||||||
[BIND_ACTION_SELECT_BEGIN] = "select-begin",
|
[BIND_ACTION_SELECT_BEGIN] = "select-begin",
|
||||||
[BIND_ACTION_SELECT_BEGIN_BLOCK] = "select-begin-block",
|
[BIND_ACTION_SELECT_BEGIN_BLOCK] = "select-begin-block",
|
||||||
[BIND_ACTION_SELECT_EXTEND] = "select-extend",
|
[BIND_ACTION_SELECT_EXTEND] = "select-extend",
|
||||||
|
[BIND_ACTION_SELECT_EXTEND_CHAR_WISE] = "select-extend-character-wise",
|
||||||
[BIND_ACTION_SELECT_WORD] = "select-word",
|
[BIND_ACTION_SELECT_WORD] = "select-word",
|
||||||
[BIND_ACTION_SELECT_WORD_WS] = "select-word-whitespace",
|
[BIND_ACTION_SELECT_WORD_WS] = "select-word-whitespace",
|
||||||
[BIND_ACTION_SELECT_ROW] = "select-row",
|
[BIND_ACTION_SELECT_ROW] = "select-row",
|
||||||
|
|
@ -2026,6 +2027,7 @@ add_default_mouse_bindings(struct config *conf)
|
||||||
add_binding(BIND_ACTION_SELECT_BEGIN, none, BTN_LEFT, 1);
|
add_binding(BIND_ACTION_SELECT_BEGIN, none, BTN_LEFT, 1);
|
||||||
add_binding(BIND_ACTION_SELECT_BEGIN_BLOCK, ctrl, BTN_LEFT, 1);
|
add_binding(BIND_ACTION_SELECT_BEGIN_BLOCK, ctrl, BTN_LEFT, 1);
|
||||||
add_binding(BIND_ACTION_SELECT_EXTEND, none, BTN_RIGHT, 1);
|
add_binding(BIND_ACTION_SELECT_EXTEND, none, BTN_RIGHT, 1);
|
||||||
|
add_binding(BIND_ACTION_SELECT_EXTEND_CHAR_WISE, ctrl, BTN_RIGHT, 1);
|
||||||
add_binding(BIND_ACTION_SELECT_WORD, none, BTN_LEFT, 2);
|
add_binding(BIND_ACTION_SELECT_WORD, none, BTN_LEFT, 2);
|
||||||
add_binding(BIND_ACTION_SELECT_WORD_WS, ctrl, BTN_LEFT, 2);
|
add_binding(BIND_ACTION_SELECT_WORD_WS, ctrl, BTN_LEFT, 2);
|
||||||
add_binding(BIND_ACTION_SELECT_ROW, none, BTN_LEFT, 3);
|
add_binding(BIND_ACTION_SELECT_ROW, none, BTN_LEFT, 3);
|
||||||
|
|
|
||||||
|
|
@ -581,21 +581,37 @@ All actions listed under *key-bindings* can be user here as well.
|
||||||
and copied to the _primary selection_, when the button is
|
and copied to the _primary selection_, when the button is
|
||||||
released. Default: _Control+BTN\_LEFT_.
|
released. Default: _Control+BTN\_LEFT_.
|
||||||
|
|
||||||
*select-extend*
|
|
||||||
Interactively extend an existing selection. The selection is
|
|
||||||
finalized, and copied to the _primary selection_, when the button
|
|
||||||
is released. Default: _BTN\_RIGHT_.
|
|
||||||
|
|
||||||
*select-word*
|
*select-word*
|
||||||
Select the _word_ (separated by spaces, period, comma, parenthesis
|
Begin an interactive word-wise selection, where words are
|
||||||
etc) under the pointer. Default: _BTN\_LEFT-2_.
|
separated by whitespace and all characters defined by the
|
||||||
|
*word-delimiters* option. The selection is finalized, and copied
|
||||||
|
to the _primary selection_, when the button is released. Default:
|
||||||
|
_BTN\_LEFT-2_.
|
||||||
|
|
||||||
*select-word-whitespace*
|
*select-word-whitespace*
|
||||||
Select the _word_ (separated by spaces _only_) under the
|
Same as *select-word*, but the characters in the *word-delimiters*
|
||||||
pointer. Default: Control+_BTN\_LEFT-2_.
|
option are ignored. I.e only whitespace characters act as
|
||||||
|
delimiters. The selection is finalized, and copied to the _primary
|
||||||
|
selection_, when the button is released. Default:
|
||||||
|
_Control+_BTN\_LEFT-2_.
|
||||||
|
|
||||||
*select-row*
|
*select-row*
|
||||||
Select the whole row under the pointer. Default: _BTN\_LEFT-3_.
|
Begin an interactive row-wise selection. The selection is
|
||||||
|
finalized, and copied to the _primary selection_, when the button
|
||||||
|
is released. Default: _BTN\_LEFT-3_.
|
||||||
|
|
||||||
|
*select-extend*
|
||||||
|
Interactively extend an existing selection, using the original
|
||||||
|
selection mode (normal, block, word-wise or row-wise). The
|
||||||
|
selection is finalized, and copied to the _primary selection_,
|
||||||
|
when the button is released. Default: _BTN\_RIGHT_.
|
||||||
|
|
||||||
|
*select-extend-character-wise*
|
||||||
|
Same as *select-extend*, but forces the selection mode to _normal_
|
||||||
|
(i.e. character wise). Note that this causes subsequent
|
||||||
|
*select-extend* operations to be character wise. This action is
|
||||||
|
ignored for block selections. Default: _Control+BTN\_RIGHT_.
|
||||||
|
|
||||||
|
|
||||||
*primary-paste*
|
*primary-paste*
|
||||||
Pastes from the _primary selection_. Default: _BTN\_MIDDLE_.
|
Pastes from the _primary selection_. Default: _BTN\_MIDDLE_.
|
||||||
|
|
|
||||||
1
foot.ini
1
foot.ini
|
|
@ -119,6 +119,7 @@
|
||||||
# select-begin=BTN_LEFT
|
# select-begin=BTN_LEFT
|
||||||
# select-begin-block=Control+BTN_LEFT
|
# select-begin-block=Control+BTN_LEFT
|
||||||
# select-extend=BTN_RIGHT
|
# select-extend=BTN_RIGHT
|
||||||
|
# select-extend-character-wise=Control+BTN_RIGHT
|
||||||
# select-word=BTN_LEFT-2
|
# select-word=BTN_LEFT-2
|
||||||
# select-word-whitespace=Control+BTN_LEFT-2
|
# select-word-whitespace=Control+BTN_LEFT-2
|
||||||
# select-row=BTN_LEFT-3
|
# select-row=BTN_LEFT-3
|
||||||
|
|
|
||||||
12
input.c
12
input.c
|
|
@ -291,7 +291,17 @@ execute_binding(struct seat *seat, struct terminal *term,
|
||||||
case BIND_ACTION_SELECT_EXTEND:
|
case BIND_ACTION_SELECT_EXTEND:
|
||||||
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, term->selection.kind);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case BIND_ACTION_SELECT_EXTEND_CHAR_WISE:
|
||||||
|
if (selection_enabled(term, seat) && cursor_is_on_grid &&
|
||||||
|
term->selection.kind != SELECTION_BLOCK)
|
||||||
|
{
|
||||||
|
selection_extend(
|
||||||
|
seat, term, seat->mouse.col, seat->mouse.row, SELECTION_CHAR_WISE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
22
selection.c
22
selection.c
|
|
@ -783,7 +783,8 @@ selection_dirty_cells(struct terminal *term)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
selection_extend_normal(struct terminal *term, int col, int row, uint32_t serial)
|
selection_extend_normal(struct terminal *term, int col, int row,
|
||||||
|
enum selection_kind new_kind)
|
||||||
{
|
{
|
||||||
const struct coord *start = &term->selection.start;
|
const struct coord *start = &term->selection.start;
|
||||||
const struct coord *end = &term->selection.end;
|
const struct coord *end = &term->selection.end;
|
||||||
|
|
@ -839,10 +840,14 @@ selection_extend_normal(struct terminal *term, int col, int row, uint32_t serial
|
||||||
|
|
||||||
switch (term->selection.kind) {
|
switch (term->selection.kind) {
|
||||||
case SELECTION_CHAR_WISE:
|
case SELECTION_CHAR_WISE:
|
||||||
|
assert(new_kind == SELECTION_CHAR_WISE);
|
||||||
set_pivot_point_for_block_and_char_wise(term, new_start, direction);
|
set_pivot_point_for_block_and_char_wise(term, new_start, direction);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SELECTION_WORD_WISE: {
|
case SELECTION_WORD_WISE: {
|
||||||
|
assert(new_kind == SELECTION_CHAR_WISE ||
|
||||||
|
new_kind == SELECTION_WORD_WISE);
|
||||||
|
|
||||||
struct coord pivot_start = {new_start.col, new_start.row - term->grid->view};
|
struct coord pivot_start = {new_start.col, new_start.row - term->grid->view};
|
||||||
struct coord pivot_end = pivot_start;
|
struct coord pivot_end = pivot_start;
|
||||||
|
|
||||||
|
|
@ -857,6 +862,9 @@ selection_extend_normal(struct terminal *term, int col, int row, uint32_t serial
|
||||||
}
|
}
|
||||||
|
|
||||||
case SELECTION_LINE_WISE:
|
case SELECTION_LINE_WISE:
|
||||||
|
assert(new_kind == SELECTION_CHAR_WISE ||
|
||||||
|
new_kind == SELECTION_LINE_WISE);
|
||||||
|
|
||||||
term->selection.pivot.start = (struct coord){0, new_start.row};
|
term->selection.pivot.start = (struct coord){0, new_start.row};
|
||||||
term->selection.pivot.end = (struct coord){term->cols - 1, new_start.row};
|
term->selection.pivot.end = (struct coord){term->cols - 1, new_start.row};
|
||||||
break;
|
break;
|
||||||
|
|
@ -867,12 +875,13 @@ selection_extend_normal(struct terminal *term, int col, int row, uint32_t serial
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
term->selection.kind = new_kind;
|
||||||
term->selection.direction = direction;
|
term->selection.direction = direction;
|
||||||
selection_modify(term, new_start, new_end);
|
selection_modify(term, new_start, new_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
selection_extend_block(struct terminal *term, int col, int row, uint32_t serial)
|
selection_extend_block(struct terminal *term, int col, int row)
|
||||||
{
|
{
|
||||||
const struct coord *start = &term->selection.start;
|
const struct coord *start = &term->selection.start;
|
||||||
const struct coord *end = &term->selection.end;
|
const struct coord *end = &term->selection.end;
|
||||||
|
|
@ -941,13 +950,16 @@ selection_extend_block(struct terminal *term, int col, int row, uint32_t serial)
|
||||||
|
|
||||||
void
|
void
|
||||||
selection_extend(struct seat *seat, struct terminal *term,
|
selection_extend(struct seat *seat, struct terminal *term,
|
||||||
int col, int row, uint32_t serial)
|
int col, int row, enum selection_kind new_kind)
|
||||||
{
|
{
|
||||||
if (term->selection.start.row < 0 || term->selection.end.row < 0) {
|
if (term->selection.start.row < 0 || term->selection.end.row < 0) {
|
||||||
/* No existing selection */
|
/* No existing selection */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (term->selection.kind == SELECTION_BLOCK && new_kind != SELECTION_BLOCK)
|
||||||
|
return;
|
||||||
|
|
||||||
term->selection.ongoing = true;
|
term->selection.ongoing = true;
|
||||||
|
|
||||||
row += term->grid->view;
|
row += term->grid->view;
|
||||||
|
|
@ -967,11 +979,11 @@ selection_extend(struct seat *seat, struct terminal *term,
|
||||||
case SELECTION_CHAR_WISE:
|
case SELECTION_CHAR_WISE:
|
||||||
case SELECTION_WORD_WISE:
|
case SELECTION_WORD_WISE:
|
||||||
case SELECTION_LINE_WISE:
|
case SELECTION_LINE_WISE:
|
||||||
selection_extend_normal(term, col, row, serial);
|
selection_extend_normal(term, col, row, new_kind);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SELECTION_BLOCK:
|
case SELECTION_BLOCK:
|
||||||
selection_extend_block(term, col, row, serial);
|
selection_extend_block(term, col, row);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,9 @@ void selection_finalize(
|
||||||
struct seat *seat, struct terminal *term, uint32_t serial);
|
struct seat *seat, struct terminal *term, uint32_t serial);
|
||||||
void selection_dirty_cells(struct terminal *term);
|
void selection_dirty_cells(struct terminal *term);
|
||||||
void selection_cancel(struct terminal *term);
|
void selection_cancel(struct terminal *term);
|
||||||
void selection_extend( struct seat *seat, struct terminal *term,
|
void selection_extend(
|
||||||
int col, int row, uint32_t serial);
|
struct seat *seat, struct terminal *term,
|
||||||
|
int col, int row, enum selection_kind kind);
|
||||||
|
|
||||||
bool selection_on_rows(const struct terminal *term, int start, int end);
|
bool selection_on_rows(const struct terminal *term, int start, int end);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ enum bind_action_normal {
|
||||||
BIND_ACTION_SELECT_BEGIN,
|
BIND_ACTION_SELECT_BEGIN,
|
||||||
BIND_ACTION_SELECT_BEGIN_BLOCK,
|
BIND_ACTION_SELECT_BEGIN_BLOCK,
|
||||||
BIND_ACTION_SELECT_EXTEND,
|
BIND_ACTION_SELECT_EXTEND,
|
||||||
|
BIND_ACTION_SELECT_EXTEND_CHAR_WISE,
|
||||||
BIND_ACTION_SELECT_WORD,
|
BIND_ACTION_SELECT_WORD,
|
||||||
BIND_ACTION_SELECT_WORD_WS,
|
BIND_ACTION_SELECT_WORD_WS,
|
||||||
BIND_ACTION_SELECT_ROW,
|
BIND_ACTION_SELECT_ROW,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue