]> Sergey Matveev's repositories - nnn.git/commitdiff
Add keys: Shift+TAB, '
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 5 Oct 2019 01:29:43 +0000 (06:59 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 5 Oct 2019 01:29:43 +0000 (06:59 +0530)
README.md
src/nnn.c
src/nnn.h

index ae6dfbc020d40773aa728c1369bd3926c82fcf04..21b3429f44ff156e328ce4ec78a720eec4228ba9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -196,11 +196,11 @@ The list below is from the **dev branch**. Press <kbd>?</kbd> in `nnn` to see th
         ↵ → l  Open file/dir     .  Toggle show hidden
          g ^A  First entry    G ^E  Last entry
             b  Pin current dir  ^B  Go to pinned dir
-       Tab ^I  Next context      d  Toggle detail view
+      (Sh)Tab  Cycle context     d  Toggle detail view
          , ^/  Lead key    N LeadN  Context N
             /  Filter/Lead  Ins ^T  Toggle nav-as-you-type
           Esc  Exit prompt   ^L F5  Redraw/clear prompt
-            ?  Help, config  Lead'  First file
+            ?  Help, conf  ' Lead'  First file
          Q ^Q  Quit  ^G  QuitCD  q  Quit context
  FILES
            ^O  Open with...      n  Create new/link
@@ -242,8 +242,6 @@ The Leader/Lead key provides a powerful multi-functional navigation mechanism. I
 | Key | Function |
 |:---:| --- |
 | <kbd>1-4</kbd> | Go to/create selected context |
-| <kbd>]</kbd> | Go to next active context |
-| <kbd>[</kbd> | Go to previous active context |
 | key | Go to bookmarked location |
 | <kbd>'</kbd> | Go to first file in directory |
 | <kbd>~</kbd> <kbd>`</kbd> <kbd>@</kbd> <kbd>-</kbd> | Visit HOME, `/`, start, last visited dir |
index b1c15cc677e336619c4805cc55dd8737a9dc81cd..9bc8591c1c0976cd909214b18cabcd7bf3e764db 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2823,11 +2823,11 @@ static void show_help(const char *path)
              "8↵ → l  Open file/dir     .  Toggle show hidden\n"
               "9g ^A  First entry    G ^E  Last entry\n"
                  "cb  Pin current dir  ^B  Go to pinned dir\n"
-            "7Tab ^I  Next context      d  Toggle detail view\n"
+           "6(Sh)Tab  Next context      d  Toggle detail view\n"
               "9, ^/  Lead key    N LeadN  Context N\n"
                  "c/  Filter/Lead  Ins ^T  Toggle nav-as-you-type\n"
                "aEsc  Exit prompt   ^L F5  Redraw/clear prompt\n"
-                 "c?  Help, config  Lead'  First file\n"
+                 "c?  Help, conf  ' Lead'  First file\n"
               "9Q ^Q  Quit  ^G  QuitCD  q  Quit context\n"
                "1FILES\n"
                 "b^O  Open with...      n  Create new/link\n"
@@ -3744,16 +3744,31 @@ nochange:
                        goto begin;
                case SEL_LEADER: // fallthrough
                case SEL_CYCLE: // fallthrough
+               case SEL_CYCLER: // fallthrough
+               case SEL_FIRST: // fallthrough
                case SEL_CTX1: // fallthrough
                case SEL_CTX2: // fallthrough
                case SEL_CTX3: // fallthrough
                case SEL_CTX4:
-                       if (sel == SEL_CYCLE)
-                               fd = ']';
-                       else if (sel >= SEL_CTX1 && sel <= SEL_CTX4)
+                       switch (sel) {
+                       case SEL_CYCLE:
+                               fd = '\t';
+                               break;
+                       case SEL_CYCLER:
+                               fd = KEY_BTAB;
+                               break;
+                       case SEL_FIRST:
+                               fd = '\'';
+                               break;
+                       case SEL_CTX1: // fallthrough
+                       case SEL_CTX2: // fallthrough
+                       case SEL_CTX3: // fallthrough
+                       case SEL_CTX4:
                                fd = sel - SEL_CTX1 + '1';
-                       else
+                               break;
+                       default:
                                fd = get_input(NULL);
+                       }
 
                        switch (fd) {
                        case '~': // fallthrough
@@ -3778,18 +3793,18 @@ nochange:
                                if (ndents)
                                        copycurname();
                                goto begin;
-                       case ']': // fallthrough
-                       case '[': // fallthrough
+                       case '\t': // fallthrough
+                       case KEY_BTAB:
                                /* visit next and previous contexts */
                                r = cfg.curctx;
-                               if (fd == ']')
+                               if (fd == '\t')
                                        do
                                                r = (r + 1) & ~CTX_MAX;
                                        while (!g_ctx[r].c_cfg.ctxactive);
                                else
                                        do
                                                r = (r + (CTX_MAX - 1)) & (CTX_MAX - 1);
-                                       while (!g_ctx[r].c_cfg.ctxactive); // fallthrough
+                                       while (!g_ctx[r].c_cfg.ctxactive);
                                fd = '1' + r; // fallthrough
                        case '1': // fallthrough
                        case '2': // fallthrough
index e2a9a62b634034911fe628104b552add823c6d65..ad6a02624ace45ab90f790ae6e3b8c9c6360b23f 100644 (file)
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -47,6 +47,7 @@ enum action {
        SEL_CTRL_U,
        SEL_HOME,
        SEL_END,
+       SEL_FIRST,
        SEL_CDHOME,
        SEL_CDBEGIN,
        SEL_CDLAST,
@@ -54,6 +55,7 @@ enum action {
        SEL_VISIT,
        SEL_LEADER,
        SEL_CYCLE,
+       SEL_CYCLER,
        SEL_CTX1,
        SEL_CTX2,
        SEL_CTX3,
@@ -141,6 +143,8 @@ static struct key bindings[] = {
        { KEY_END,        SEL_END },
        { 'G',            SEL_END },
        { CONTROL('E'),   SEL_END },
+       /* Go to first file */
+       { '\'',           SEL_FIRST },
        /* HOME */
        { '~',            SEL_CDHOME },
        /* Initial directory */
@@ -155,8 +159,9 @@ static struct key bindings[] = {
        { CONTROL('_'),   SEL_LEADER },
        { ',',            SEL_LEADER },
        /* Cycle contexts in forward direction */
-       { '\t',           SEL_CYCLE },
-       { CONTROL('I'),   SEL_CYCLE },
+       { '\t',        SEL_CYCLE },
+       /* Cycle contexts in reverse direction */
+       { KEY_BTAB,       SEL_CYCLER },
        /* Go to/create context N */
        { '1',            SEL_CTX1 },
        { '2',            SEL_CTX2 },