From 98da5f6d35c1192e7660a02a34a5e5be5ce3ab6c Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Tue, 15 Sep 2020 19:15:30 +0200 Subject: Add an action to go to the parent directory --- sdn.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sdn.cpp b/sdn.cpp index ae6ec74..2de9f4e 100644 --- a/sdn.cpp +++ b/sdn.cpp @@ -388,8 +388,8 @@ 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(CHDIR) XX(GO_START) XX(GO_HOME) \ + XX(PAGE_PREVIOUS) XX(PAGE_NEXT) XX(SCROLL_UP) XX(SCROLL_DOWN) \ + XX(CHDIR) XX(PARENT) XX(GO_START) XX(GO_HOME) \ XX(SEARCH) XX(RENAME) XX(RENAME_PREFILL) \ XX(TOGGLE_FULL) XX(REVERSE_SORT) XX(SHOW_HIDDEN) XX(REDRAW) XX(RELOAD) \ XX(INPUT_ABORT) XX(INPUT_CONFIRM) XX(INPUT_B_DELETE) @@ -1000,6 +1000,8 @@ fun absolutize (const string &abs_base, const string &path) -> string { return abs_base + "/" + path; } +/// If `path` is equal to the `current` directory, or lies underneath it, +/// return it as a relative path fun relativize (string current, const string &path) -> string { if (current == path) return "."; @@ -1217,6 +1219,9 @@ fun handle (wint_t c) -> bool { change_dir (to_mb (g.editor_line)); }; break; + case ACTION_PARENT: + change_dir (".."); + break; case ACTION_GO_START: change_dir (g.start_dir); break; -- cgit v1.2.3-70-g09d2