Combine archive operations

This commit is contained in:
Arun Prakash Jana 2019-12-10 03:56:38 +05:30
parent 8dd1946d1d
commit 847bda4380
No known key found for this signature in database
GPG Key ID: A75979F35C080412
3 changed files with 24 additions and 28 deletions

View File

@ -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

View File

@ -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))

View File

@ -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 */