]> Sergey Matveev's repositories - nnn.git/commitdiff
Combine archive operations
authorArun Prakash Jana <engineerarun@gmail.com>
Mon, 9 Dec 2019 22:26:38 +0000 (03:56 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Mon, 9 Dec 2019 22:26:38 +0000 (03:56 +0530)
README.md
src/nnn.c
src/nnn.h

index 97343d62a6da0acc5d0a16523b6b373ffaff957e..c90ccd72114d0c273201585f8a55fbb13588fdcb 100644 (file)
--- a/README.md
+++ b/README.md
@@ -223,8 +223,7 @@ The list below is from the **dev branch**. Press <kbd>?</kbd> in `nnn` to see th
             P  Copy selection    K  Edit, flush sel
             V  Move selection    w  Copy/move sel as
             X  Del selection    ^X  Del entry
-            f  Create archive    T  Mount archive
-           ^F  Extract archive   F  List archive
+            f  Archive        o ^F  Archive ops
             e  Edit in EDITOR    p  Open in PAGER
  ORDER TOGGLES
             A  Apparent du       S  du
index d6a1a515a363275cacd6a59f71a5c025ad14eee6..aaf4c33addc7dc2b86e6ae53a24f56b341699aa4 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -456,6 +456,7 @@ static char * const utils[] = {
 #define MSG_REMOTE_OPTS 39
 #define MSG_RCLONE_DELAY 40
 #define MSG_APP_NAME 41
+#define MSG_ARCHIVE_OPTS 42
 
 static const char * const messages[] = {
        "no traversal",
@@ -500,6 +501,7 @@ static const char * const messages[] = {
        "'s'shfs / 'r'clone?",
        "may take a while, try refresh",
        "app name: ",
+       "e'x'tract / 'l'ist / 'm'ount?",
 };
 
 /* Supported configuration environment variables */
@@ -3506,8 +3508,7 @@ static void show_help(const char *path)
                  "cP  Copy selection    K  Edit, flush sel\n"
                  "cV  Move selection    w  Copy/move sel as\n"
                  "cX  Del selection    ^X  Del entry\n"
-                 "cf  Create archive    T  Mount archive\n"
-                "b^F  Extract archive   F  List archive\n"
+                 "cf  Archive        o ^F  Archive ops\n"
                  "ce  Edit in EDITOR    p  Open in PAGER\n"
                "1ORDER TOGGLES\n"
                  "cA  Apparent du       S  du\n"
@@ -4775,8 +4776,6 @@ nochange:
                                }
                        }
                        break;
-               case SEL_ARCHIVELS: // fallthrough
-               case SEL_EXTRACT: // fallthrough
                case SEL_REDRAW: // fallthrough
                case SEL_RENAMEMUL: // fallthrough
                case SEL_HELP: // fallthrough
@@ -4788,19 +4787,10 @@ nochange:
 
                        if (ndents)
                                mkpath(path, dents[cur].name, newpath);
-                       else if (sel == SEL_ARCHIVELS || sel == SEL_EXTRACT
-                                || sel == SEL_RUNEDIT || sel == SEL_RUNPAGE)
+                       else if (sel == SEL_RUNEDIT || sel == SEL_RUNPAGE)
                                break;
 
                        switch (sel) {
-                       case SEL_ARCHIVELS:
-                               handle_archive(newpath, path, 'l');
-                               refresh = TRUE;
-                               break;
-                       case SEL_EXTRACT:
-                               handle_archive(newpath, path, 'x');
-                               refresh = TRUE;
-                               break;
                        case SEL_REDRAW:
                                refresh = TRUE;
                                break;
@@ -5010,9 +5000,10 @@ nochange:
                                        }
 
                                        tmp = NULL;
-                               } else if (!ndents)
+                               } else if (r != 'c' || !ndents) {
+                                       clearprompt();
                                        goto nochange;
-                               else
+                               else
                                        tmp = dents[cur].name;
                                tmp = xreadline(tmp, messages[MSG_ARCHIVE_NAME]);
                                break;
@@ -5305,8 +5296,19 @@ nochange:
 
                        /* Repopulate as directory content may have changed */
                        goto begin;
-               case SEL_ARCHIVEMNT:
-                       if (!ndents || !archive_mount(dents[cur].name, path, newpath, &presel))
+               case SEL_ARCHIVEOPS:
+                       if (!ndents)
+                               goto nochange;
+
+                       r = get_input(messages[MSG_ARCHIVE_OPTS]);
+                       if (r == 'l' || r == 'x') {
+                               mkpath(path, dents[cur].name, newpath);
+                               handle_archive(newpath, path, r);
+                               copycurname();
+                               goto begin;
+                       }
+
+                       if (r != 'm' || !archive_mount(dents[cur].name, path, newpath, &presel))
                                goto nochange; // fallthrough
                case SEL_REMOTE:
                        if (sel == SEL_REMOTE && !remote_mount(newpath, &presel))
index c5892ec0acc122a4f2f693887c83d5ea147f442b..9d4e490d5af0de88ce07cb0bb01f23b9f2806e83 100644 (file)
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -67,8 +67,6 @@ enum action {
        SEL_DETAIL,
        SEL_STATS,
        SEL_ARCHIVE,
-       SEL_ARCHIVELS,
-       SEL_EXTRACT,
        SEL_FSIZE,  /* file size */
        SEL_ASIZE,  /* apparent size */
        SEL_BSIZE,  /* block size */
@@ -89,7 +87,7 @@ enum action {
        SEL_NEW,
        SEL_RENAME,
        SEL_RENAMEMUL,
-       SEL_ARCHIVEMNT,
+       SEL_ARCHIVEOPS,
        SEL_REMOTE,
        SEL_UMOUNT,
        SEL_HELP,
@@ -186,10 +184,6 @@ static struct key bindings[] = {
        { 'D',            SEL_STATS },
        /* Create archive */
        { 'f',            SEL_ARCHIVE },
-       /* List archive */
-       { 'F',            SEL_ARCHIVELS },
-       /* Extract archive */
-       { CONTROL('F'),   SEL_EXTRACT },
        /* Toggle sort by size */
        { 'z',            SEL_FSIZE },
        /* Sort by apparent size including dir contents */
@@ -235,7 +229,8 @@ static struct key bindings[] = {
        /* Rename contents of current dir */
        { 'r',            SEL_RENAMEMUL },
        /* Mount an archive */
-       { 'T',            SEL_ARCHIVEMNT },
+       { 'o',            SEL_ARCHIVEOPS },
+       { CONTROL('F'),   SEL_ARCHIVEOPS },
        /* Connect to server over SSHFS */
        { 'c',            SEL_REMOTE },
        /* Disconnect a SSHFS mount point */