Support vim movements: H M L

Vim movements H, M and L implemented and documented.
This commit is contained in:
Jonatan Vela 2017-01-17 02:06:29 +01:00 committed by Jonatan Vela
parent 3c2753bab2
commit 8dad4e51e4
3 changed files with 38 additions and 0 deletions

View File

@ -118,6 +118,12 @@ SELECTION MODE
+-----------------------------------+-----------------------------------------------------------+ +-----------------------------------+-----------------------------------------------------------+
| ``B`` or ``ctrl-left`` | backward WORD (non-whitespace) | | ``B`` or ``ctrl-left`` | backward WORD (non-whitespace) |
+-----------------------------------+-----------------------------------------------------------+ +-----------------------------------+-----------------------------------------------------------+
| ``H`` | jump to the top of the screen |
+-----------------------------------+-----------------------------------------------------------+
| ``M`` | jump to the middle of the screen |
+-----------------------------------+-----------------------------------------------------------+
| ``L`` | jump to the bottom of the screen |
+-----------------------------------+-----------------------------------------------------------+
| ``0`` or ``home`` | move cursor to the first column in the row | | ``0`` or ``home`` | move cursor to the first column in the row |
+-----------------------------------+-----------------------------------------------------------+ +-----------------------------------+-----------------------------------------------------------+
| ``^`` | beginning-of-line (first non-blank character) | | ``^`` | beginning-of-line (first non-blank character) |

View File

@ -109,6 +109,12 @@ forward \fIWORD\fP (non-whitespace)
forward to end of \fIWORD\fP (non-whitespace) forward to end of \fIWORD\fP (non-whitespace)
.IP "\fBB\fP or \fBctrl-left\fP" .IP "\fBB\fP or \fBctrl-left\fP"
backward \fIWORD\fP (non-whitespace) backward \fIWORD\fP (non-whitespace)
.IP "\fBH\fP"
move cursor to the top of the screen
.IP "\fBM\fP"
move cursor to the middle of the screen
.IP "\fBL\fP"
move cursor to the bottom of the screen
.IP "\fB0\fP or \fBhome\fP" .IP "\fB0\fP or \fBhome\fP"
move cursor to the first column in the row\fP" move cursor to the first column in the row\fP"
.IP "\fB^\fP" .IP "\fB^\fP"

View File

@ -507,6 +507,23 @@ static long last_row(VteTerminal *vte) {
return (long)gtk_adjustment_get_upper(adjust) - 1; return (long)gtk_adjustment_get_upper(adjust) - 1;
} }
static long top_row(VteTerminal *vte) {
GtkAdjustment *adjust = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vte));
return (long)gtk_adjustment_get_value(adjust);
}
static long middle_row(VteTerminal *vte) {
GtkAdjustment *adjust = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vte));
return (long)gtk_adjustment_get_value(adjust) +
(long)vte_terminal_get_row_count(vte) / 2;
}
static long bottom_row(VteTerminal *vte) {
GtkAdjustment *adjust = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vte));
return (long)gtk_adjustment_get_value(adjust) +
(long)vte_terminal_get_row_count(vte) - 1;
}
static void update_scroll(VteTerminal *vte) { static void update_scroll(VteTerminal *vte) {
GtkAdjustment *adjust = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vte)); GtkAdjustment *adjust = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vte));
const double scroll_row = gtk_adjustment_get_value(adjust); const double scroll_row = gtk_adjustment_get_value(adjust);
@ -894,6 +911,15 @@ gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info)
case GDK_KEY_G: case GDK_KEY_G:
move_to_row_start(vte, &info->select, last_row(vte)); move_to_row_start(vte, &info->select, last_row(vte));
break; break;
case GDK_KEY_H:
move_to_row_start(vte, &info->select, top_row(vte));
break;
case GDK_KEY_M:
move_to_row_start(vte, &info->select, middle_row(vte));
break;
case GDK_KEY_L:
move_to_row_start(vte, &info->select, bottom_row(vte));
break;
case GDK_KEY_v: case GDK_KEY_v:
toggle_visual(vte, &info->select, vi_mode::visual); toggle_visual(vte, &info->select, vi_mode::visual);
break; break;