summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-01-08 11:13:08 +0100
committerPřemysl Eric Janouch <p@janouch.name>2022-01-08 11:17:24 +0100
commit2bfb4907986f14e7b087d1372a8b641f40536846 (patch)
treeffe741d81188e51de4dd14da6a777727bc4d5431
parent338d00d6054b7832cf4da83ca7a052258bf5aad4 (diff)
downloadsdn-2bfb4907986f14e7b087d1372a8b641f40536846.tar.gz
sdn-2bfb4907986f14e7b087d1372a8b641f40536846.tar.xz
sdn-2bfb4907986f14e7b087d1372a8b641f40536846.zip
Add and bind an action to center the cursor
"z" stands for VIM's "zz".
-rw-r--r--sdn.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/sdn.cpp b/sdn.cpp
index 6d0ac40..294f15c 100644
--- a/sdn.cpp
+++ b/sdn.cpp
@@ -410,7 +410,7 @@ enum { ALT = 1 << 24, SYM = 1 << 25 }; // Outside the range of Unicode
#define ACTIONS(XX) XX(NONE) XX(HELP) XX(QUIT) XX(QUIT_NO_CHDIR) \
XX(CHOOSE) XX(CHOOSE_FULL) XX(VIEW) XX(EDIT) XX(SORT_LEFT) XX(SORT_RIGHT) \
XX(UP) XX(DOWN) XX(TOP) XX(BOTTOM) XX(HIGH) XX(MIDDLE) XX(LOW) \
- XX(PAGE_PREVIOUS) XX(PAGE_NEXT) XX(SCROLL_UP) XX(SCROLL_DOWN) \
+ XX(PAGE_PREVIOUS) XX(PAGE_NEXT) XX(SCROLL_UP) XX(SCROLL_DOWN) XX(CENTER) \
XX(CHDIR) XX(PARENT) XX(GO_START) XX(GO_HOME) \
XX(SEARCH) XX(RENAME) XX(RENAME_PREFILL) XX(MKDIR) \
XX(TOGGLE_FULL) XX(REVERSE_SORT) XX(SHOW_HIDDEN) XX(REDRAW) XX(RELOAD) \
@@ -442,6 +442,7 @@ static map<wint_t, action> g_normal_actions {
{'H', ACTION_HIGH}, {'M', ACTION_MIDDLE}, {'L', ACTION_LOW},
{KEY (PPAGE), ACTION_PAGE_PREVIOUS}, {KEY (NPAGE), ACTION_PAGE_NEXT},
{CTRL ('Y'), ACTION_SCROLL_UP}, {CTRL ('E'), ACTION_SCROLL_DOWN},
+ {'z', ACTION_CENTER},
{'c', ACTION_CHDIR}, {ALT | KEY (UP), ACTION_PARENT},
{'&', ACTION_GO_START}, {'~', ACTION_GO_HOME},
{'/', ACTION_SEARCH}, {'s', ACTION_SEARCH}, {CTRL ('S'), ACTION_SEARCH},
@@ -1420,6 +1421,8 @@ fun handle (wint_t c) -> bool {
break;
case ACTION_SCROLL_UP:
g.offset--;
+ case ACTION_CENTER:
+ g.offset = g.cursor - (visible_lines () - 1) / 2;
break;
case ACTION_CHDIR: