From 3075d47aeb52f6549e957023d353d4c5cb857e54 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Sat, 28 Dec 2024 00:28:22 +0100 Subject: 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. --- sdn.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'sdn.cpp') diff --git a/sdn.cpp b/sdn.cpp index 07f56a2..af2e09e 100644 --- a/sdn.cpp +++ b/sdn.cpp @@ -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 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 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: -- cgit v1.2.3-70-g09d2