mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-17 00:51:36 +02:00
Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another from Kalle Olavi Niemitalo, thanks.
This commit is contained in:
@ -50,6 +50,7 @@ int window_copy_is_space(struct window_pane *, u_int, u_int);
|
||||
u_int window_copy_find_length(struct window_pane *, u_int);
|
||||
void window_copy_set_cursor_x(struct window_pane *, u_int);
|
||||
void window_copy_cursor_start_of_line(struct window_pane *);
|
||||
void window_copy_cursor_back_to_indentation(struct window_pane *);
|
||||
void window_copy_cursor_end_of_line(struct window_pane *);
|
||||
void window_copy_cursor_left(struct window_pane *);
|
||||
void window_copy_cursor_right(struct window_pane *);
|
||||
@ -207,6 +208,9 @@ window_copy_key(struct window_pane *wp, struct client *c, int key)
|
||||
case MODEKEYCMD_STARTOFLINE:
|
||||
window_copy_cursor_start_of_line(wp);
|
||||
break;
|
||||
case MODEKEYCMD_BACKTOINDENTATION:
|
||||
window_copy_cursor_back_to_indentation(wp);
|
||||
break;
|
||||
case MODEKEYCMD_ENDOFLINE:
|
||||
window_copy_cursor_end_of_line(wp);
|
||||
break;
|
||||
@ -600,6 +604,33 @@ window_copy_cursor_start_of_line(struct window_pane *wp)
|
||||
window_copy_update_cursor(wp);
|
||||
}
|
||||
|
||||
void
|
||||
window_copy_cursor_back_to_indentation(struct window_pane *wp)
|
||||
{
|
||||
struct window_copy_mode_data *data = wp->modedata;
|
||||
u_int px, py, xx;
|
||||
const struct grid_cell *gc;
|
||||
|
||||
px = 0;
|
||||
py = screen_hsize(&wp->base) + data->cy - data->oy;
|
||||
xx = window_copy_find_length(wp, py);
|
||||
|
||||
/*
|
||||
* Don't use window_copy_is_space because that treats some word
|
||||
* delimiters as spaces.
|
||||
*/
|
||||
while (px < xx) {
|
||||
gc = grid_peek_cell(wp->base.grid, px, py);
|
||||
if (gc->flags & GRID_FLAG_UTF8)
|
||||
break;
|
||||
if (gc->data != ' ')
|
||||
break;
|
||||
px++;
|
||||
}
|
||||
|
||||
window_copy_set_cursor_x(wp, px);
|
||||
}
|
||||
|
||||
void
|
||||
window_copy_cursor_end_of_line(struct window_pane *wp)
|
||||
{
|
||||
|
Reference in New Issue
Block a user