From 1b252b6ecbb8e754069a33b6cf585e41f705604a Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Tue, 14 Jan 2020 21:01:59 +0530 Subject: [PATCH] Keybind changes --- plugins/README.md | 2 +- src/nnn.c | 66 ++++++++++++++++++++++++----------------------- src/nnn.h | 19 ++++++++------ 3 files changed, 46 insertions(+), 41 deletions(-) diff --git a/plugins/README.md b/plugins/README.md index 1433e11f..507572cd 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -65,7 +65,7 @@ Plugins are installed to `${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins`. ## Invoking a plugin -Use the plugin shortcut (;key or ^Pkey) to list the defined plugin keys and press the required key. E.g., with the below config: +Use the plugin shortcut (;key or ^Skey) to list the defined plugin keys and press the required key. E.g., with the below config: export NNN_PLUG='o:fzopen;p:mocplay;d:diffs;m:nmount;n:notes;v:imgviu;t:imgthumb' diff --git a/src/nnn.c b/src/nnn.c index e4e28200..fdc1c228 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -1571,7 +1571,7 @@ static bool cpmvrm_selection(enum action sel, char *path, int *presel) return FALSE; } break; - default: /* SEL_RMMUL */ + default: /* SEL_RM */ rmmulstr(g_buf); break; } @@ -3606,7 +3606,7 @@ static void show_help(const char *path) "9Up k Up%-16cPgUp ^U Scroll up\n" "9Dn j Down%-14cPgDn ^D Scroll down\n" "9Lt h Parent%-12c~ ` @ - HOME, /, start, last\n" - "5Ret Rt l Open%-20cf First file\n" + "5Ret Rt l Open%-20c' First file\n" "9g ^A Top%-21c. Toggle hidden\n" "9G ^E End%-21c0 Lock terminal\n" "9b ^/ Bookmark key%-12c, Pin CWD\n" @@ -3616,20 +3616,19 @@ static void show_help(const char *path) "c? Help, conf%-13c^G QuitCD\n" "9Q ^Q Quit%-20cq Quit context\n" "1FILES\n" - "b^O Open with...%-12cn Create new/link\n" - "b^F File details%-12cd Detail view toggle\n" + "9o ^O Open with...%-12cn Create new/link\n" + "9f ^F File details%-12cd Detail view toggle\n" "b^R Rename/dup%-14cr Batch rename\n" - "cz Archive entry%-11c* Toggle exe\n" + "cz Archive%-17c* Toggle exe\n" "5Space ^J (Un)select%-11cm ^K Mark range/clear\n" - "cp Copy sel here%-11ca Select all\n" - "cv Move sel here%-10c^V Copy/move sel as\n" - "cx Delete sel%-13c^X Delete entry\n" - "9o ^T Sort toggles%-12ce Edit sel\n" + "9p ^P Copy sel here%-11ca Select all\n" + "9v ^V Move sel here%-8cw ^W Copy/move sel as\n" + "9x ^X Delete%-18ce Edit sel\n" "1MISC\n" - "9; ^P Plugin%-18c= Launch app\n" + "9; ^S Select plugin%-11c= Launch app\n" "9! ^] Shell%-19c] Cmd prompt\n" - "cs Manage session%-10cu Unmount\n" - "cc Connect remote%-0c\n" + "cc Connect remote%-10cu Unmount\n" + "9t ^T Sort toggles%-12cs Manage session\n" }; fd = create_tmp_file(); @@ -5240,8 +5239,30 @@ nochange: case SEL_CP: // fallthrough case SEL_MV: // fallthrough case SEL_CPMVAS: // fallthrough - case SEL_RMMUL: + case SEL_RM: { + if (sel == SEL_RM) { + r = get_cur_or_sel(); + if (!r) { + statusbar(path); + goto nochange; + } + + if (r == 'c') { + mkpath(path, dents[cur].name, newpath); + xrm(newpath); + + if (cur && access(newpath, F_OK) == -1) { + move_cursor(cur - 1, 0); + copycurname(); + } + + if (cfg.filtermode) + presel = FILTER; + goto begin; + } + } + endselection(); if (!cpmvrm_selection(sel, path, &presel)) @@ -5257,25 +5278,6 @@ nochange: copycurname(); goto begin; } - case SEL_RM: - { - if (!ndents) - break; - - mkpath(path, dents[cur].name, newpath); - xrm(newpath); - - if (cur && access(newpath, F_OK) == -1) - move_cursor(cur - 1, 0); - - /* We reduce cur only if it is > 0, so it's at least 0 */ - copycurname(); - - if (cfg.filtermode) - presel = FILTER; - - goto begin; - } case SEL_ARCHIVE: // fallthrough case SEL_OPENWITH: // fallthrough case SEL_NEW: // fallthrough diff --git a/src/nnn.h b/src/nnn.h index d5f353d6..d65febf2 100644 --- a/src/nnn.h +++ b/src/nnn.h @@ -76,7 +76,6 @@ enum action { SEL_CP, SEL_MV, SEL_CPMVAS, - SEL_RMMUL, SEL_RM, SEL_OPENWITH, SEL_NEW, @@ -136,7 +135,7 @@ static struct key bindings[] = { { 'G', SEL_END }, { CONTROL('E'), SEL_END }, /* Go to first file */ - { 'f', SEL_FIRST }, + { '\'', SEL_FIRST }, /* HOME */ { '~', SEL_CDHOME }, /* Initial directory */ @@ -168,13 +167,14 @@ static struct key bindings[] = { /* Detailed listing */ { 'd', SEL_DETAIL }, /* File details */ + { 'f', SEL_STATS }, { CONTROL('F'), SEL_STATS }, /* Toggle executable status */ { '*', SEL_CHMODX }, /* Create archive */ { 'z', SEL_ARCHIVE }, - /* Order toggle */ - { 'o', SEL_ORDER }, + /* Sort toggles */ + { 't', SEL_ORDER }, { CONTROL('T'), SEL_ORDER }, /* Redraw window */ { CONTROL('L'), SEL_REDRAW }, @@ -190,15 +190,18 @@ static struct key bindings[] = { { 'e', SEL_SELEDIT }, /* Copy from selection buffer */ { 'p', SEL_CP }, + { CONTROL('P'), SEL_CP }, /* Move from selection buffer */ { 'v', SEL_MV }, + { CONTROL('V'), SEL_MV }, /* Copy/move from selection buffer and rename */ - { CONTROL('V'), SEL_CPMVAS }, + { 'w', SEL_CPMVAS }, + { CONTROL('W'), SEL_CPMVAS }, /* Delete from selection buffer */ - { 'x', SEL_RMMUL }, - /* Delete currently selected */ + { 'x', SEL_RM }, { CONTROL('X'), SEL_RM }, /* Open in a custom application */ + { 'o', SEL_OPENWITH }, { CONTROL('O'), SEL_OPENWITH }, /* Create a new file */ { 'n', SEL_NEW }, @@ -214,7 +217,7 @@ static struct key bindings[] = { { '?', SEL_HELP }, /* Run a plugin */ { ';', SEL_PLUGIN }, - { CONTROL('P'), SEL_PLUGIN }, + { CONTROL('S'), SEL_PLUGIN }, /* Run command */ { '!', SEL_SHELL }, { CONTROL(']'), SEL_SHELL },