aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-09-27 22:58:40 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-09-27 23:33:10 +0200
commit91df92f49a82d082c864274e0d75858876833340 (patch)
tree9779858e9fa261ffc53bf662a82735f3f953248b
parentbff886841b91ceb394b7f515a90be0ed13b1dfdc (diff)
downloadsdn-91df92f49a82d082c864274e0d75858876833340.tar.gz
sdn-91df92f49a82d082c864274e0d75858876833340.tar.xz
sdn-91df92f49a82d082c864274e0d75858876833340.zip
Make F3 change directories
Best complemented with a less(1) configuration that also quits on F3, just like mcview. Or invoke sdn with PAGER=mcview, even though you lose the ability to view the help that way (but gain filters).
-rw-r--r--sdn.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/sdn.cpp b/sdn.cpp
index f97f0ca..f7b19b5 100644
--- a/sdn.cpp
+++ b/sdn.cpp
@@ -1141,6 +1141,10 @@ fun handle (wint_t c) -> bool {
}
const auto &current = g.entries[g.cursor];
+ bool is_directory =
+ S_ISDIR (current.info.st_mode) ||
+ S_ISDIR (current.target_info.st_mode);
+
auto i = g_normal_actions.find (c);
switch (i == g_normal_actions.end () ? ACTION_NONE : i->second) {
case ACTION_CHOOSE_FULL:
@@ -1152,7 +1156,8 @@ fun handle (wint_t c) -> bool {
choose (current);
break;
case ACTION_VIEW:
- view (current.filename);
+ // Mimic mc, it does not seem sensible to page directories
+ (is_directory ? change_dir : view) (current.filename);
break;
case ACTION_EDIT:
edit (current.filename);