summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6677ecc)
raw | patch | inline | side by side (parent: 6677ecc)
author | Jeffrey Middleton <jefromi@gmail.com> | |
Tue, 3 Mar 2009 22:14:38 +0000 (23:14 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 3 Mar 2009 22:14:38 +0000 (23:14 +0100) |
Commands to move cursor to top, middle, and bottom of screen, mapped
by default to H, M, and L like in Vim.
by default to H, M, and L like in Vim.
src/command.c | patch | blob | history | |
src/command.h | patch | blob | history | |
src/list_window.c | patch | blob | history | |
src/screen_help.c | patch | blob | history |
diff --git a/src/command.c b/src/command.c
index ad8b8d49322e15ba25b77539450e580a41e8ee0b..3a16e801409ffd09d8cdcc9b82472515d4335c17 100644 (file)
--- a/src/command.c
+++ b/src/command.c
N_("Move cursor up") },
{ { DWN, 'j', 0 }, 0, CMD_LIST_NEXT, "down",
N_("Move cursor down") },
+ { { 'H', 0, 0 }, 0, CMD_LIST_TOP, "top",
+ N_("Move cursor to top of screen") },
+ { { 'M', 0, 0 }, 0, CMD_LIST_MIDDLE, "middle",
+ N_("Move cursor to middle of screen") },
+ { { 'L', 0, 0 }, 0, CMD_LIST_BOTTOM, "bottom",
+ N_("Move cursor to bottom of screen") },
{ { HOME, 0x01, 0 }, 0, CMD_LIST_FIRST, "home",
N_("Home") },
{ { END, 0x05, 0 }, 0, CMD_LIST_LAST, "end",
diff --git a/src/command.h b/src/command.h
index 7111a2b2f619f1a7bb4f2cd350d487b5a62f50f1..c7514c421a4159eb30cd1e5f9e19d42303558c90 100644 (file)
--- a/src/command.h
+++ b/src/command.h
CMD_SEARCH_MODE,
CMD_LIST_PREVIOUS,
CMD_LIST_NEXT,
+ CMD_LIST_TOP,
+ CMD_LIST_MIDDLE,
+ CMD_LIST_BOTTOM,
CMD_LIST_FIRST,
CMD_LIST_LAST,
CMD_LIST_NEXT_PAGE,
diff --git a/src/list_window.c b/src/list_window.c
index 17107d67768bbc44c15b50d4d01bf9e4815b6bfd..bf0f45aa18dd2019e6a634bf805859d31188570b 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
list_window_set_selected(lw, length-1);
}
+static void
+list_window_top(struct list_window *lw)
+{
+ list_window_set_selected(lw, lw->start);
+}
+
+static void
+list_window_middle(struct list_window *lw, unsigned length)
+{
+ if (length >= lw->rows)
+ list_window_set_selected(lw, lw->start + lw->rows / 2);
+ else
+ list_window_set_selected(lw, length / 2);
+}
+
+static void
+list_window_bottom(struct list_window *lw, unsigned length)
+{
+ if (length >= lw->rows)
+ list_window_set_selected(lw, lw->start + lw->rows - 1);
+ else
+ list_window_set_selected(lw, length - 1);
+}
+
static void
list_window_first(struct list_window *lw)
{
case CMD_LIST_NEXT:
list_window_next(lw, rows);
break;
+ case CMD_LIST_TOP:
+ list_window_top(lw);
+ break;
+ case CMD_LIST_MIDDLE:
+ list_window_middle(lw,rows);
+ break;
+ case CMD_LIST_BOTTOM:
+ list_window_bottom(lw,rows);
+ break;
case CMD_LIST_FIRST:
list_window_first(lw);
break;
diff --git a/src/screen_help.c b/src/screen_help.c
index f8438dccaa3f5b7b34be579c8838fef85b739bfb..5a0654fb3b6d3df9482a54a947d61b49db893151 100644 (file)
--- a/src/screen_help.c
+++ b/src/screen_help.c
{ 2, CMD_NONE, NULL },
{ 0, CMD_LIST_PREVIOUS, NULL },
{ 0, CMD_LIST_NEXT, NULL },
+ { 0, CMD_LIST_TOP, NULL },
+ { 0, CMD_LIST_MIDDLE, NULL },
+ { 0, CMD_LIST_BOTTOM, NULL },
{ 0, CMD_LIST_PREVIOUS_PAGE, NULL },
{ 0, CMD_LIST_NEXT_PAGE, NULL },
{ 0, CMD_LIST_FIRST, NULL },