(Sh)TAB should get a new context if required

This commit is contained in:
Arun Prakash Jana 2020-04-02 20:47:15 +05:30
parent 415a6edd4a
commit 38bd3c4900
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -485,7 +485,7 @@ static char * const utils[] = {
#define MSG_CP_MV_AS 7 #define MSG_CP_MV_AS 7
#define MSG_CUR_SEL_OPTS 8 #define MSG_CUR_SEL_OPTS 8
#define MSG_FORCE_RM 9 #define MSG_FORCE_RM 9
#define MSG_CREATE_CTX 10 #define MSG_LIMIT 10
#define MSG_NEW_OPTS 11 #define MSG_NEW_OPTS 11
#define MSG_CLI_MODE 12 #define MSG_CLI_MODE 12
#define MSG_OVERWRITE 13 #define MSG_OVERWRITE 13
@ -518,9 +518,8 @@ static char * const utils[] = {
#define MSG_RM_TMP 40 #define MSG_RM_TMP 40
#define MSG_NOCHNAGE 41 #define MSG_NOCHNAGE 41
#define MSG_CANCEL 42 #define MSG_CANCEL 42
#define MSG_LIMIT 43
#ifndef DIR_LIMITED_SELECTION #ifndef DIR_LIMITED_SELECTION
#define MSG_DIR_CHANGED 44 /* Must be the last entry */ #define MSG_DIR_CHANGED 43 /* Must be the last entry */
#endif #endif
static const char * const messages[] = { static const char * const messages[] = {
@ -534,7 +533,7 @@ static const char * const messages[] = {
"'c'p / 'm'v as?", "'c'p / 'm'v as?",
"'c'urrent / 's'el?", "'c'urrent / 's'el?",
"rm -rf %s file%s?", "rm -rf %s file%s?",
"create context %d?", "limit exceeded\n",
"'f'ile / 'd'ir / 's'ym / 'h'ard?", "'f'ile / 'd'ir / 's'ym / 'h'ard?",
"'c'li / 'g'ui?", "'c'li / 'g'ui?",
"overwrite?", "overwrite?",
@ -567,7 +566,6 @@ static const char * const messages[] = {
"remove tmp file?", "remove tmp file?",
"unchanged", "unchanged",
"cancelled", "cancelled",
"limit exceeded\n",
#ifndef DIR_LIMITED_SELECTION #ifndef DIR_LIMITED_SELECTION
"dir changed, range sel off", /* Must be the last entry */ "dir changed, range sel off", /* Must be the last entry */
#endif #endif
@ -4706,7 +4704,7 @@ static void handle_screen_move(enum action sel)
} }
} }
static int handle_context_switch(enum action sel, char *newpath) static int handle_context_switch(enum action sel)
{ {
int r = -1; int r = -1;
@ -4729,12 +4727,11 @@ static int handle_context_switch(enum action sel, char *newpath)
r = sel - SEL_CTX1; /* Save the next context id */ r = sel - SEL_CTX1; /* Save the next context id */
if (cfg.curctx == r) { if (cfg.curctx == r) {
if (sel != SEL_CYCLE) if (sel == SEL_CYCLE)
return -1;
(r == CTX_MAX - 1) ? (r = 0) : ++r; (r == CTX_MAX - 1) ? (r = 0) : ++r;
snprintf(newpath, PATH_MAX, messages[MSG_CREATE_CTX], r + 1); else if (sel == SEL_CYCLER)
if (!xconfirm(get_input(newpath))) (r == 0) ? (r = CTX_MAX - 1) : --r;
else
return -1; return -1;
} }
@ -5573,7 +5570,7 @@ nochange:
case SEL_CTX2: // fallthrough case SEL_CTX2: // fallthrough
case SEL_CTX3: // fallthrough case SEL_CTX3: // fallthrough
case SEL_CTX4: case SEL_CTX4:
r = handle_context_switch(sel, newpath); r = handle_context_switch(sel);
if (r < 0) if (r < 0)
continue; continue;
savecurctx(&cfg, path, dents[cur].name, r); savecurctx(&cfg, path, dents[cur].name, r);