mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-23 00:23:08 +01: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:
parent
fa8333eddb
commit
22d51ec1ea
@ -105,8 +105,9 @@ mode_key_lookup_vi(struct mode_key_data *mdata, int key)
|
|||||||
return (MODEKEYCMD_CHOOSE);
|
return (MODEKEYCMD_CHOOSE);
|
||||||
return (MODEKEYCMD_COPYSELECTION);
|
return (MODEKEYCMD_COPYSELECTION);
|
||||||
case '0':
|
case '0':
|
||||||
case '^':
|
|
||||||
return (MODEKEYCMD_STARTOFLINE);
|
return (MODEKEYCMD_STARTOFLINE);
|
||||||
|
case '^':
|
||||||
|
return (MODEKEYCMD_BACKTOINDENTATION);
|
||||||
case '\033':
|
case '\033':
|
||||||
return (MODEKEYCMD_CLEARSELECTION);
|
return (MODEKEYCMD_CLEARSELECTION);
|
||||||
case 'j':
|
case 'j':
|
||||||
@ -160,6 +161,8 @@ mode_key_lookup_emacs(struct mode_key_data *mdata, int key)
|
|||||||
return (MODEKEYCMD_CHOOSE);
|
return (MODEKEYCMD_CHOOSE);
|
||||||
case '\001':
|
case '\001':
|
||||||
return (MODEKEYCMD_STARTOFLINE);
|
return (MODEKEYCMD_STARTOFLINE);
|
||||||
|
case KEYC_ADDESC('m'):
|
||||||
|
return (MODEKEYCMD_BACKTOINDENTATION);
|
||||||
case '\007':
|
case '\007':
|
||||||
return (MODEKEYCMD_CLEARSELECTION);
|
return (MODEKEYCMD_CLEARSELECTION);
|
||||||
case '\027':
|
case '\027':
|
||||||
|
1
status.c
1
status.c
@ -709,6 +709,7 @@ status_prompt_key(struct client *c, int key)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MODEKEYCMD_STARTOFLINE:
|
case MODEKEYCMD_STARTOFLINE:
|
||||||
|
case MODEKEYCMD_BACKTOINDENTATION:
|
||||||
if (c->prompt_index != 0) {
|
if (c->prompt_index != 0) {
|
||||||
c->prompt_index = 0;
|
c->prompt_index = 0;
|
||||||
c->flags |= CLIENT_STATUS;
|
c->flags |= CLIENT_STATUS;
|
||||||
|
3
tmux.1
3
tmux.1
@ -306,7 +306,8 @@ option).
|
|||||||
The following keys are supported as appropriate for the mode:
|
The following keys are supported as appropriate for the mode:
|
||||||
.Bl -column "FunctionXXXXXXXXXXXX" "viXXXXXX" "emacs" -offset indent
|
.Bl -column "FunctionXXXXXXXXXXXX" "viXXXXXX" "emacs" -offset indent
|
||||||
.It Sy "Function" Ta Sy "vi" Ta Sy "emacs"
|
.It Sy "Function" Ta Sy "vi" Ta Sy "emacs"
|
||||||
.It Li "Start of line" Ta "0 or ^" Ta "C-a"
|
.It Li "Start of line" Ta "0" Ta "C-a"
|
||||||
|
.It Li "Back to indentation" Ta "^" Ta "M-m"
|
||||||
.It Li "Clear selection" Ta "Escape" Ta "C-g"
|
.It Li "Clear selection" Ta "Escape" Ta "C-g"
|
||||||
.It Li "Copy selection" Ta "Enter" Ta "M-w"
|
.It Li "Copy selection" Ta "Enter" Ta "M-w"
|
||||||
.It Li "Cursor down" Ta "j" Ta "Down"
|
.It Li "Cursor down" Ta "j" Ta "Down"
|
||||||
|
1
tmux.h
1
tmux.h
@ -357,6 +357,7 @@ struct msg_resize_data {
|
|||||||
/* Editing keys. */
|
/* Editing keys. */
|
||||||
enum mode_key_cmd {
|
enum mode_key_cmd {
|
||||||
MODEKEYCMD_BACKSPACE = 0x1000,
|
MODEKEYCMD_BACKSPACE = 0x1000,
|
||||||
|
MODEKEYCMD_BACKTOINDENTATION,
|
||||||
MODEKEYCMD_CHOOSE,
|
MODEKEYCMD_CHOOSE,
|
||||||
MODEKEYCMD_CLEARSELECTION,
|
MODEKEYCMD_CLEARSELECTION,
|
||||||
MODEKEYCMD_COMPLETE,
|
MODEKEYCMD_COMPLETE,
|
||||||
|
@ -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);
|
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_set_cursor_x(struct window_pane *, u_int);
|
||||||
void window_copy_cursor_start_of_line(struct window_pane *);
|
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_end_of_line(struct window_pane *);
|
||||||
void window_copy_cursor_left(struct window_pane *);
|
void window_copy_cursor_left(struct window_pane *);
|
||||||
void window_copy_cursor_right(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:
|
case MODEKEYCMD_STARTOFLINE:
|
||||||
window_copy_cursor_start_of_line(wp);
|
window_copy_cursor_start_of_line(wp);
|
||||||
break;
|
break;
|
||||||
|
case MODEKEYCMD_BACKTOINDENTATION:
|
||||||
|
window_copy_cursor_back_to_indentation(wp);
|
||||||
|
break;
|
||||||
case MODEKEYCMD_ENDOFLINE:
|
case MODEKEYCMD_ENDOFLINE:
|
||||||
window_copy_cursor_end_of_line(wp);
|
window_copy_cursor_end_of_line(wp);
|
||||||
break;
|
break;
|
||||||
@ -600,6 +604,33 @@ window_copy_cursor_start_of_line(struct window_pane *wp)
|
|||||||
window_copy_update_cursor(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
|
void
|
||||||
window_copy_cursor_end_of_line(struct window_pane *wp)
|
window_copy_cursor_end_of_line(struct window_pane *wp)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user