aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-12-13 01:46:50 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-12-13 01:46:50 +0530
commit1b035d6ffdd9809d4469fcde9da937368f67e709 (patch)
tree3ca9bcddb70e29651c910f9ab9702facdd39b5cb
parent1473416228d5feccd966cb213d9f9799e092715e (diff)
downloadnnn-1b035d6ffdd9809d4469fcde9da937368f67e709.tar.gz
Process keypress by probable frequency
-rw-r--r--nnn.c76
-rw-r--r--nnn.h34
2 files changed, 55 insertions, 55 deletions
diff --git a/nnn.c b/nnn.c
index cccecc2..ecbdc79 100644
--- a/nnn.c
+++ b/nnn.c
@@ -2146,26 +2146,6 @@ nochange:
sel = nextsel(&run, &env, &presel);
switch (sel) {
- case SEL_CDQUIT:
- {
- char *tmpfile = "/tmp/nnn";
-
- tmp = getenv("NNN_TMPFILE");
- if (tmp)
- tmpfile = tmp;
-
- FILE *fp = fopen(tmpfile, "w");
-
- if (fp) {
- fprintf(fp, "cd \"%s\"", path);
- fclose(fp);
- }
-
- /* Fall through to exit */
- } // fallthrough
- case SEL_QUIT:
- dentfree(dents);
- return;
case SEL_BACK:
/* There is no going back */
if (istopdir(path)) {
@@ -2264,24 +2244,6 @@ nochange:
printmsg("Unsupported file");
goto nochange;
}
- case SEL_FLTR:
- presel = filterentries(path);
- xstrlcpy(fltr, ifilter, LINE_MAX);
- DPRINTF_S(fltr);
- /* Save current */
- if (ndents > 0)
- mkpath(path, dents[cur].name, oldpath, PATH_MAX);
- goto nochange;
- case SEL_MFLTR:
- cfg.filtermode ^= 1;
- if (cfg.filtermode)
- presel = FILTER;
- else
- printmsg("navigate-as-you-type off");
- goto nochange;
- case SEL_SEARCH:
- spawn(player, path, "search", NULL, F_NORMAL);
- break;
case SEL_NEXT:
if (cur < ndents - 1)
++cur;
@@ -2567,6 +2529,24 @@ nochange:
xstrlcpy(mark, path, PATH_MAX);
printmsg(mark);
goto nochange;
+ case SEL_FLTR:
+ presel = filterentries(path);
+ xstrlcpy(fltr, ifilter, LINE_MAX);
+ DPRINTF_S(fltr);
+ /* Save current */
+ if (ndents > 0)
+ mkpath(path, dents[cur].name, oldpath, PATH_MAX);
+ goto nochange;
+ case SEL_MFLTR:
+ cfg.filtermode ^= 1;
+ if (cfg.filtermode)
+ presel = FILTER;
+ else
+ printmsg("navigate-as-you-type off");
+ goto nochange;
+ case SEL_SEARCH:
+ spawn(player, path, "search", NULL, F_NORMAL);
+ break;
case SEL_TOGGLEDOT:
cfg.showhidden ^= 1;
initfilter(cfg.showhidden, &ifilter);
@@ -2785,6 +2765,26 @@ nochange:
run = xgetenv(env, run);
spawn(run, dents[cur].name, NULL, path, F_NORMAL);
break;
+ case SEL_CDQUIT:
+ {
+ char *tmpfile = "/tmp/nnn";
+
+ tmp = getenv("NNN_TMPFILE");
+ if (tmp)
+ tmpfile = tmp;
+
+ FILE *fp = fopen(tmpfile, "w");
+
+ if (fp) {
+ fprintf(fp, "cd \"%s\"", path);
+ fclose(fp);
+ }
+
+ /* Fall through to exit */
+ } // fallthrough
+ case SEL_QUIT:
+ dentfree(dents);
+ return;
}
/* Screensaver */
if (idletimeout != 0 && idle == idletimeout) {
diff --git a/nnn.h b/nnn.h
index e904c84..6bf6477 100644
--- a/nnn.h
+++ b/nnn.h
@@ -3,13 +3,8 @@
/* Supported actions */
enum action {
- SEL_QUIT = 1,
- SEL_CDQUIT,
- SEL_BACK,
+ SEL_BACK = 1,
SEL_GOIN,
- SEL_FLTR,
- SEL_MFLTR,
- SEL_SEARCH,
SEL_NEXT,
SEL_PREV,
SEL_PGDN,
@@ -23,6 +18,9 @@ enum action {
SEL_CDBM,
SEL_PIN,
SEL_VISIT,
+ SEL_FLTR,
+ SEL_MFLTR,
+ SEL_SEARCH,
SEL_TOGGLEDOT,
SEL_DETAIL,
SEL_STATS,
@@ -41,6 +39,8 @@ enum action {
SEL_HELP,
SEL_RUN,
SEL_RUNARG,
+ SEL_CDQUIT,
+ SEL_QUIT,
};
/* Associate a pressed key to an action */
@@ -62,11 +62,6 @@ static struct assoc assocs[] = {
};
static struct key bindings[] = {
- /* Quit */
- { 'q', SEL_QUIT, "", "" },
- { CONTROL('Q'), SEL_QUIT, "", "" },
- /* Change dir on quit */
- { 'Q', SEL_CDQUIT, "", "" },
/* Back */
{ KEY_BACKSPACE, SEL_BACK, "", "" },
{ KEY_LEFT, SEL_BACK, "", "" },
@@ -77,12 +72,6 @@ static struct key bindings[] = {
{ '\r', SEL_GOIN, "", "" },
{ KEY_RIGHT, SEL_GOIN, "", "" },
{ 'l', SEL_GOIN, "", "" },
- /* Filter */
- { '/', SEL_FLTR, "", "" },
- /* Toggle filter mode */
- { KEY_IC, SEL_MFLTR, "", "" },
- /* Desktop search */
- { CONTROL('_'), SEL_SEARCH, "", "" },
/* Next */
{ 'j', SEL_NEXT, "", "" },
{ KEY_DOWN, SEL_NEXT, "", "" },
@@ -121,6 +110,12 @@ static struct key bindings[] = {
{ CONTROL('B'), SEL_PIN, "", "" },
/* Visit marked directory */
{ CONTROL('V'), SEL_VISIT, "", "" },
+ /* Filter */
+ { '/', SEL_FLTR, "", "" },
+ /* Toggle filter mode */
+ { KEY_IC, SEL_MFLTR, "", "" },
+ /* Desktop search */
+ { CONTROL('_'), SEL_SEARCH, "", "" },
/* Toggle hide .dot files */
{ '.', SEL_TOGGLEDOT, "", "" },
/* Detailed listing */
@@ -160,4 +155,9 @@ static struct key bindings[] = {
/* Run command with argument */
{ 'e', SEL_RUNARG, "vi", "EDITOR" },
{ 'p', SEL_RUNARG, "less", "PAGER" },
+ /* Change dir on quit */
+ { 'Q', SEL_CDQUIT, "", "" },
+ /* Quit */
+ { 'q', SEL_QUIT, "", "" },
+ { CONTROL('Q'), SEL_QUIT, "", "" },
};