Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request thestinger#441 from wbangna/vim-movement-top-middl…
Browse files Browse the repository at this point in the history
…e-bottom

Vim movement top middle bottom
  • Loading branch information
jelly authored Aug 18, 2017
2 parents 3c2753b + 8dad4e5 commit 01f8542
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ SELECTION MODE
+-----------------------------------+-----------------------------------------------------------+
| ``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 |
+-----------------------------------+-----------------------------------------------------------+
| ``^`` | beginning-of-line (first non-blank character) |
Expand Down
6 changes: 6 additions & 0 deletions man/termite.1
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ forward \fIWORD\fP (non-whitespace)
forward to end of \fIWORD\fP (non-whitespace)
.IP "\fBB\fP or \fBctrl-left\fP"
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"
move cursor to the first column in the row\fP"
.IP "\fB^\fP"
Expand Down
26 changes: 26 additions & 0 deletions termite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,23 @@ static long last_row(VteTerminal *vte) {
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) {
GtkAdjustment *adjust = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vte));
const double scroll_row = gtk_adjustment_get_value(adjust);
Expand Down Expand Up @@ -894,6 +911,15 @@ gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info)
case GDK_KEY_G:
move_to_row_start(vte, &info->select, last_row(vte));
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:
toggle_visual(vte, &info->select, vi_mode::visual);
break;
Expand Down

0 comments on commit 01f8542

Please sign in to comment.