mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-18 06:46:23 -04:00
key-binding: add bind to clear scrollback but keep current line
This commit is contained in:
parent
d7a4f9e99e
commit
a3fc484028
7 changed files with 29 additions and 0 deletions
14
commands.c
14
commands.c
|
|
@ -113,3 +113,17 @@ cmd_scrollback_down(struct terminal *term, int rows)
|
|||
render_refresh_urls(term);
|
||||
render_refresh(term);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_scrollback_clear_keepcur(struct terminal *term) {
|
||||
const struct coord cursor = term->grid->cursor.point;
|
||||
int real_row = grid_row_absolute(term->grid, cursor.row - 1);
|
||||
struct row *row;
|
||||
while (row = term->grid->rows[real_row], row && !row->linebreak)
|
||||
real_row = (real_row - 1) & (term->grid->num_rows - 1);
|
||||
int screen_row = (real_row + 1 - term->grid->offset) & (term->grid->num_rows - 1);
|
||||
term_scroll_partial(term, (struct scroll_region){0, term->rows}, screen_row);
|
||||
term_cursor_to(term, cursor.row - screen_row, cursor.col);
|
||||
term_erase_scrollback(term);
|
||||
render_refresh(term);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue