diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2024-12-28 00:28:22 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2024-12-28 04:58:13 +0100 |
commit | 3075d47aeb52f6549e957023d353d4c5cb857e54 (patch) | |
tree | 1a0c0fbf331d78a8a62106aeea7662bbf6af1ba9 /sdn.cpp | |
parent | 85b2d8a2ee966794768f26cfc2404c850d33e096 (diff) | |
download | sdn-3075d47aeb52f6549e957023d353d4c5cb857e54.tar.gz sdn-3075d47aeb52f6549e957023d353d4c5cb857e54.tar.xz sdn-3075d47aeb52f6549e957023d353d4c5cb857e54.zip |
Add and integrate a script to execute mc.ext.ini
Tsk, tsk, parasiting on what we wanted to replace.
macOS is annoying to port to.
Unfortunately, this script is also very slow, for some reason.
Diffstat (limited to 'sdn.cpp')
-rw-r--r-- | sdn.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -428,7 +428,8 @@ enum { ALT = 1 << 24, SYM = 1 << 25 }; // Outside the range of Unicode #define CTRL(char) ((char) == '?' ? 0x7f : (char) & 0x1f) #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(CHOOSE) XX(CHOOSE_FULL) XX(VIEW_RAW) 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(CENTER) \ XX(CHDIR) XX(PARENT) XX(GO_START) XX(GO_HOME) \ @@ -451,7 +452,8 @@ static map<wint_t, action> g_normal_actions { {ALT | '\r', ACTION_CHOOSE_FULL}, {ALT | KEY (ENTER), ACTION_CHOOSE_FULL}, {'\r', ACTION_CHOOSE}, {KEY (ENTER), ACTION_CHOOSE}, {KEY (F (1)), ACTION_HELP}, {'h', ACTION_HELP}, - {KEY (F (3)), ACTION_VIEW}, {KEY (F (4)), ACTION_EDIT}, + {KEY (F (3)), ACTION_VIEW}, {KEY (F (13)), ACTION_VIEW_RAW}, + {KEY (F (4)), ACTION_EDIT}, {'q', ACTION_QUIT}, {ALT | 'q', ACTION_QUIT_NO_CHDIR}, // M-o ought to be the same shortcut the navigator is launched with {ALT | 'o', ACTION_QUIT}, @@ -1015,12 +1017,17 @@ fun run_program (initializer_list<const char *> list, const string &filename) { update (); } -fun view (const string &filename) { +fun view_raw (const string &filename) { // XXX: we cannot realistically detect that the pager hasn't made a pause // at the end of the file, so we can't ensure all contents have been seen run_program ({(const char *) getenv ("PAGER"), "less", "cat"}, filename); } +fun view (const string &filename) { + run_program ({(const char *) getenv ("SDN_VIEWER"), "sdn-view", + (const char *) getenv ("PAGER"), "less", "cat"}, filename); +} + fun edit (const string &filename) { run_program ({(const char *) getenv ("VISUAL"), (const char *) getenv ("EDITOR"), "vi"}, filename); @@ -1445,8 +1452,11 @@ fun handle (wint_t c) -> bool { case ACTION_CHOOSE: choose (current); break; - case ACTION_VIEW: + case ACTION_VIEW_RAW: // Mimic mc, it does not seem sensible to page directories + (is_directory ? change_dir : view_raw) (current.filename); + break; + case ACTION_VIEW: (is_directory ? change_dir : view) (current.filename); break; case ACTION_EDIT: |