mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-28 06:46:38 -04:00
Add new key-binding: "extend-to-end-line"
This new key-binding is similar to "extend-to-word-boundary" and "extend-to-next-whitespace", it applies in "scrollback search" mode and extends current selection to the end of the line. This commit also removes the parameter "bool spaces_only" from selection_find_line_boundary_right and selection_find_line_boundary_left since it is not used inside the functions
This commit is contained in:
parent
206e9a1050
commit
fc0a1923dc
9 changed files with 42 additions and 15 deletions
|
|
@ -193,6 +193,10 @@ These are the default shortcuts. See `man foot.ini` and the example
|
|||
: Same as <kbd>ctrl</kbd>+<kbd>w</kbd>, except that the only word
|
||||
separating characters are whitespace characters.
|
||||
|
||||
<kbd>ctrl</kbd>+<kbd>l</kbd>
|
||||
: Extend current selection (and thus the search criteria) to the end
|
||||
of the line.
|
||||
|
||||
<kbd>ctrl</kbd>+<kbd>v</kbd>, <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>v</kbd>, <kbd>ctrl</kbd>+<kbd>y</kbd>, <kbd>XF86Paste</kbd>
|
||||
: Paste from clipboard into the search buffer.
|
||||
|
||||
|
|
|
|||
2
config.c
2
config.c
|
|
@ -146,6 +146,7 @@ static const char *const search_binding_action_map[] = {
|
|||
[BIND_ACTION_SEARCH_DELETE_NEXT_WORD] = "delete-next-word",
|
||||
[BIND_ACTION_SEARCH_EXTEND_WORD] = "extend-to-word-boundary",
|
||||
[BIND_ACTION_SEARCH_EXTEND_WORD_WS] = "extend-to-next-whitespace",
|
||||
[BIND_ACTION_SEARCH_EXTEND_LINE] = "extend-to-end-line",
|
||||
[BIND_ACTION_SEARCH_CLIPBOARD_PASTE] = "clipboard-paste",
|
||||
[BIND_ACTION_SEARCH_PRIMARY_PASTE] = "primary-paste",
|
||||
};
|
||||
|
|
@ -2705,6 +2706,7 @@ add_default_search_bindings(struct config *conf)
|
|||
{BIND_ACTION_SEARCH_DELETE_NEXT_WORD, m_alt, {{XKB_KEY_d}}},
|
||||
{BIND_ACTION_SEARCH_EXTEND_WORD, m_ctrl, {{XKB_KEY_w}}},
|
||||
{BIND_ACTION_SEARCH_EXTEND_WORD_WS, m_ctrl_shift, {{XKB_KEY_w}}},
|
||||
{BIND_ACTION_SEARCH_EXTEND_LINE, m_ctrl, {{XKB_KEY_l}}},
|
||||
{BIND_ACTION_SEARCH_CLIPBOARD_PASTE, m_ctrl, {{XKB_KEY_v}}},
|
||||
{BIND_ACTION_SEARCH_CLIPBOARD_PASTE, m_ctrl_shift, {{XKB_KEY_v}}},
|
||||
{BIND_ACTION_SEARCH_CLIPBOARD_PASTE, m_ctrl, {{XKB_KEY_y}}},
|
||||
|
|
|
|||
|
|
@ -231,6 +231,10 @@ default) available; see *foot.ini*(5).
|
|||
Same as *ctrl*+*w*, except that the only word separating
|
||||
characters are whitespace characters.
|
||||
|
||||
*ctrl*+*l*
|
||||
Extend current selection (and thus the search criteria) to the end
|
||||
of the line.
|
||||
|
||||
*ctrl*+*v*, *ctrl*+*shift*+*v*, *ctrl*+*y*, *XF86Paste*
|
||||
Paste from clipboard into the search buffer.
|
||||
|
||||
|
|
|
|||
|
|
@ -851,6 +851,10 @@ scrollback search mode. The syntax is exactly the same as the regular
|
|||
Extend the current selection to the next whitespace. Default:
|
||||
_Control+Shift+w_.
|
||||
|
||||
*extend-to-end-line*
|
||||
Extend current selection to the end of the line. Default:
|
||||
_Control+l_.
|
||||
|
||||
*clipboard-paste*
|
||||
Paste from the _clipboard_ into the search buffer. Default:
|
||||
_Control+v Control+y_.
|
||||
|
|
|
|||
1
foot.ini
1
foot.ini
|
|
@ -167,6 +167,7 @@
|
|||
# delete-next-word=Mod1+d Control+Delete
|
||||
# extend-to-word-boundary=Control+w
|
||||
# extend-to-next-whitespace=Control+Shift+w
|
||||
# extend-to-end-line=Control+l
|
||||
# clipboard-paste=Control+v Control+Shift+v Control+y XF86Paste
|
||||
# primary-paste=Shift+Insert
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ enum bind_action_search {
|
|||
BIND_ACTION_SEARCH_DELETE_NEXT_WORD,
|
||||
BIND_ACTION_SEARCH_EXTEND_WORD,
|
||||
BIND_ACTION_SEARCH_EXTEND_WORD_WS,
|
||||
BIND_ACTION_SEARCH_EXTEND_LINE,
|
||||
BIND_ACTION_SEARCH_CLIPBOARD_PASTE,
|
||||
BIND_ACTION_SEARCH_PRIMARY_PASTE,
|
||||
BIND_ACTION_SEARCH_COUNT,
|
||||
|
|
|
|||
20
search.c
20
search.c
|
|
@ -643,7 +643,7 @@ search_add_chars(struct terminal *term, const char *src, size_t count)
|
|||
}
|
||||
|
||||
static void
|
||||
search_match_to_end_of_word(struct terminal *term, bool spaces_only)
|
||||
search_match_to_end_of_object(struct terminal *term, bool spaces_only, bool line)
|
||||
{
|
||||
if (term->search.match_len == 0)
|
||||
return;
|
||||
|
|
@ -683,10 +683,14 @@ search_match_to_end_of_word(struct terminal *term, bool spaces_only)
|
|||
xassert(new_end.row < grid->num_rows);
|
||||
xassert(grid->rows[new_end.row] != NULL);
|
||||
|
||||
/* Find next word boundary */
|
||||
/* Find next word/line boundary */
|
||||
new_end.row -= grid->view + grid->num_rows;
|
||||
new_end.row &= grid->num_rows - 1;
|
||||
selection_find_word_boundary_right(term, &new_end, spaces_only, false);
|
||||
if (!line) {
|
||||
selection_find_word_boundary_right(term, &new_end, spaces_only, false);
|
||||
} else {
|
||||
selection_find_line_boundary_right(term, &new_end);
|
||||
}
|
||||
new_end.row += grid->view;
|
||||
new_end.row &= grid->num_rows - 1;
|
||||
|
||||
|
|
@ -967,13 +971,19 @@ execute_binding(struct seat *seat, struct terminal *term,
|
|||
}
|
||||
|
||||
case BIND_ACTION_SEARCH_EXTEND_WORD:
|
||||
search_match_to_end_of_word(term, false);
|
||||
search_match_to_end_of_object(term, false, false);
|
||||
*update_search_result = false;
|
||||
*redraw = true;
|
||||
return true;
|
||||
|
||||
case BIND_ACTION_SEARCH_EXTEND_WORD_WS:
|
||||
search_match_to_end_of_word(term, true);
|
||||
search_match_to_end_of_object(term, true, false);
|
||||
*update_search_result = false;
|
||||
*redraw = true;
|
||||
return true;
|
||||
|
||||
case BIND_ACTION_SEARCH_EXTEND_LINE:
|
||||
search_match_to_end_of_object(term, false, true);
|
||||
*update_search_result = false;
|
||||
*redraw = true;
|
||||
return true;
|
||||
|
|
|
|||
18
selection.c
18
selection.c
|
|
@ -459,8 +459,7 @@ selection_find_word_boundary_right(struct terminal *term, struct coord *pos,
|
|||
}
|
||||
|
||||
void
|
||||
selection_find_line_boundary_left(struct terminal *term, struct coord *pos,
|
||||
bool spaces_only)
|
||||
selection_find_line_boundary_left(struct terminal *term, struct coord *pos)
|
||||
{
|
||||
int next_row = pos->row;
|
||||
pos->col = 0;
|
||||
|
|
@ -481,8 +480,7 @@ selection_find_line_boundary_left(struct terminal *term, struct coord *pos,
|
|||
}
|
||||
|
||||
void
|
||||
selection_find_line_boundary_right(struct terminal *term, struct coord *pos,
|
||||
bool spaces_only)
|
||||
selection_find_line_boundary_right(struct terminal *term, struct coord *pos)
|
||||
{
|
||||
int next_row = pos->row;
|
||||
pos->col = term->cols - 1;
|
||||
|
|
@ -547,8 +545,8 @@ selection_start(struct terminal *term, int col, int row,
|
|||
|
||||
case SELECTION_LINE_WISE: {
|
||||
struct coord start = {0, row}, end = {term->cols - 1, row};
|
||||
selection_find_line_boundary_left(term, &start, spaces_only);
|
||||
selection_find_line_boundary_right(term, &end, spaces_only);
|
||||
selection_find_line_boundary_left(term, &start);
|
||||
selection_find_line_boundary_right(term, &end);
|
||||
|
||||
term->selection.coords.start = (struct coord){
|
||||
start.col, term->grid->view + start.row};
|
||||
|
|
@ -889,7 +887,7 @@ selection_update(struct terminal *term, int col, int row)
|
|||
case SELECTION_LEFT: {
|
||||
struct coord end = {0, row};
|
||||
selection_find_line_boundary_left(
|
||||
term, &end, term->selection.spaces_only);
|
||||
term, &end);
|
||||
new_end = (struct coord){end.col, term->grid->view + end.row};
|
||||
break;
|
||||
}
|
||||
|
|
@ -897,7 +895,7 @@ selection_update(struct terminal *term, int col, int row)
|
|||
case SELECTION_RIGHT: {
|
||||
struct coord end = {col, row};
|
||||
selection_find_line_boundary_right(
|
||||
term, &end, term->selection.spaces_only);
|
||||
term, &end);
|
||||
new_end = (struct coord){end.col, term->grid->view + end.row};
|
||||
break;
|
||||
}
|
||||
|
|
@ -1040,8 +1038,8 @@ selection_extend_normal(struct terminal *term, int col, int row,
|
|||
struct coord pivot_start = {new_start.col, new_start.row - term->grid->view};
|
||||
struct coord pivot_end = pivot_start;
|
||||
|
||||
selection_find_line_boundary_left(term, &pivot_start, spaces_only);
|
||||
selection_find_line_boundary_right(term, &pivot_end, spaces_only);
|
||||
selection_find_line_boundary_left(term, &pivot_start);
|
||||
selection_find_line_boundary_right(term, &pivot_end);
|
||||
|
||||
term->selection.pivot.start =
|
||||
(struct coord){pivot_start.col, term->grid->view + pivot_start.row};
|
||||
|
|
|
|||
|
|
@ -81,5 +81,8 @@ void selection_find_word_boundary_right(
|
|||
struct terminal *term, struct coord *pos, bool spaces_only,
|
||||
bool stop_on_space_to_word_boundary);
|
||||
|
||||
void selection_find_line_boundary_right(
|
||||
struct terminal *term, struct coord *pos);
|
||||
|
||||
struct coord selection_get_start(const struct terminal *term);
|
||||
struct coord selection_get_end(const struct terminal *term);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue