aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-09-15 19:15:30 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-09-15 19:15:30 +0200
commit98da5f6d35c1192e7660a02a34a5e5be5ce3ab6c (patch)
tree9546639624dc97c12ac01ba15f03de9ad4e23593
parentf4eebf59afce7cd3901d7f0d7d05e475e115258b (diff)
downloadsdn-98da5f6d35c1192e7660a02a34a5e5be5ce3ab6c.tar.gz
sdn-98da5f6d35c1192e7660a02a34a5e5be5ce3ab6c.tar.xz
sdn-98da5f6d35c1192e7660a02a34a5e5be5ce3ab6c.zip
Add an action to go to the parent directory
-rw-r--r--sdn.cpp9
1 files 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;