]> Sergey Matveev's repositories - nnn.git/commitdiff
Add 'c' command to change into a destination directory by typing the path
authorsin <sin@2f30.org>
Tue, 21 Oct 2014 14:13:21 +0000 (15:13 +0100)
committersin <sin@2f30.org>
Tue, 21 Oct 2014 14:14:04 +0000 (15:14 +0100)
README
noice.c

diff --git a/README b/README
index a023074a2f8a1c1df77e98c93cddc77d977c355b..c43bf087d5fe3109e76406ae539d86dbf72fd273 100644 (file)
--- a/README
+++ b/README
@@ -35,8 +35,9 @@ You can navigate the list using the following keybinds (hardcoded):
 | l    | RIGHT | ^M    | open file / directory (see section "File opening")
 | h    | LEFT  | ^?    | navigate up one directory
 | /    | &     |       | filter output
-| q    |       |       | exit program
 | !    |       |       | spawn shell in current directory
+| c    |       |       | type and change into destination directory
+| q    |       |       | exit program
 +------+-------+-------+---------------------------------------------------
 
 File opening
diff --git a/noice.c b/noice.c
index b15a5edf9dc1c16bcd0803a48b4975707539443f..ba2774aea8f0c85173f0bad860477a2f364c4ed3 100644 (file)
--- a/noice.c
+++ b/noice.c
@@ -204,6 +204,7 @@ enum {
        SEL_GOIN,
        SEL_FLTR,
        SEL_SH,
+       SEL_CD,
 };
 
 int
@@ -258,6 +259,8 @@ nextsel(int *cur, int max)
                break;
        case '!':
                return SEL_SH;
+       case 'c':
+               return SEL_CD;
        }
 
        return 0;
@@ -604,6 +607,28 @@ nochange:
                        if (chdir(ipath) == -1)
                                printwarn();
                        break;
+               case SEL_CD:
+                       /* Read target dir */
+                       printmsg("");
+                       move(LINES - 1, 0);
+                       printw("chdir: ");
+                       tmp = readln();
+                       if (tmp == NULL) {
+                               printmsg("");
+                               goto nochange;
+                       }
+                       if (testopendir(tmp) == 0) {
+                               printwarn();
+                               goto nochange;
+                       } else {
+                               free(path);
+                               path = strdup(tmp);
+                               free(filter);
+                               filter = strdup(ifilter); /* Reset filter */
+                               DPRINTF_S(path);
+                               cur = 0;
+                               goto out;
+                       }
                }
        }