Indicate when range selection and plugin picker are waiting for input (#406)

* Use [1:*] as indicator that range selection is in progress

* Fix review comments

* Add prompt for plugin selection
This commit is contained in:
Maxim Baz 2019-12-17 00:07:48 +01:00 committed by Mischievous Meerkat
parent 5c76187b61
commit d6a4e449d3

View file

@ -332,6 +332,7 @@ static kv plug[PLUGIN_MAX];
static uchar g_tmpfplen;
static uchar blk_shift = BLK_SHIFT_512;
static bool interrupted = FALSE;
static bool rangesel = FALSE;
/* Retain old signal handlers */
#ifdef __linux__
@ -451,15 +452,14 @@ static char * const utils[] = {
#define MSG_EMPTY_FILE 29
#define MSG_UNSUPPORTED 30
#define MSG_NOT_SET 31
#define MSG_RANGE_SEL_ON 32
#define MSG_DIR_CHANGED 33
#define MSG_0_FILES 34
#define MSG_EXISTS 35
#define MSG_FEW_COLOUMNS 36
#define MSG_REMOTE_OPTS 37
#define MSG_RCLONE_DELAY 38
#define MSG_APP_NAME 39
#define MSG_ARCHIVE_OPTS 40
#define MSG_DIR_CHANGED 32
#define MSG_0_FILES 33
#define MSG_EXISTS 34
#define MSG_FEW_COLOUMNS 35
#define MSG_REMOTE_OPTS 36
#define MSG_RCLONE_DELAY 37
#define MSG_APP_NAME 38
#define MSG_ARCHIVE_OPTS 39
static const char * const messages[] = {
"no traversal",
@ -494,7 +494,6 @@ static const char * const messages[] = {
"empty: edit or open with",
"unsupported file",
"not set",
"range sel on",
"dir changed, range sel off",
"0 files",
"entry exists",
@ -3433,6 +3432,14 @@ static void printkv(kv *kvarr, FILE *fp, uchar max)
fprintf(fp, " %c: %s\n", (char)kvarr[i].key, kvarr[i].val);
}
static void sprintkv(kv *kvarr, char *buf, uchar max)
{
uchar i = 0;
for (; i < max && kvarr[i].key; ++i)
buf += snprintf(buf, CMD_LEN_MAX, " %c=%s", (char)kvarr[i].key, kvarr[i].val);
}
/*
* The help string tokens (each line) start with a HEX value
* which indicates the number of spaces to print before the
@ -4137,7 +4144,8 @@ static void redraw(char *path)
c = cfg.apparentsz ? 'a' : 'd';
mvprintw(lastln, 0, "%d/%d [%d:%s] %cu:%s free:%s files:%lu %lldB %s",
cur + 1, ndents, cfg.selmode, (nselected ? xitoa(nselected) : ""),
cur + 1, ndents, cfg.selmode,
(rangesel ? "*" : (nselected ? xitoa(nselected) : "")),
c, buf, coolsize(get_fs_info(path, FREE)), num_files,
(ll)pent->blocks << blk_shift, ptr);
} else { /* light or detail mode */
@ -4150,7 +4158,8 @@ static void redraw(char *path)
buf[sizeof(buf)-1] = '\0';
mvprintw(lastln, 0, "%d/%d [%d:%s] %s%s %s %s %s [%s]",
cur + 1, ndents, cfg.selmode, (nselected ? xitoa(nselected) : ""),
cur + 1, ndents, cfg.selmode,
(rangesel ? "*" : (nselected ? xitoa(nselected) : "")),
sort, buf, get_lsperms(pent->mode), coolsize(pent->size), ptr, base);
}
} else
@ -4167,7 +4176,7 @@ static void browse(char *ipath, const char *session)
int r = -1, fd, presel, selstartid = 0, selendid = 0;
ino_t inode = 0;
enum action sel;
bool dir_changed = FALSE, rangesel = FALSE;
bool dir_changed = FALSE;
struct stat sb;
char *path, *lastdir, *lastname, *dir, *tmp;
MEVENT event;
@ -4857,8 +4866,6 @@ nochange:
if (rangesel) { /* Range selection started */
inode = sb.st_ino;
selstartid = cur;
printmsg(messages[MSG_RANGE_SEL_ON]);
xdelay(XDELAY_INTERVAL_MS);
continue;
}
@ -5181,10 +5188,15 @@ nochange:
}
if (sel == SEL_PLUGKEY) {
xstrlcpy(g_buf, "pick plugin:", CMD_LEN_MAX);
sprintkv(plug, g_buf + strlen(g_buf), PLUGIN_MAX);
printprompt(g_buf);
r = get_input(NULL);
tmp = get_kv_val(plug, NULL, r, PLUGIN_MAX, FALSE);
if (!tmp)
if (!tmp) {
clearprompt();
goto nochange;
}
if (tmp[0] == '_' && tmp[1]) {
xstrlcpy(newpath, ++tmp, PATH_MAX);