mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Refactor plugin handling
This commit is contained in:
parent
5676dfe682
commit
bffadf09c5
36
src/nnn.c
36
src/nnn.c
|
@ -5245,23 +5245,6 @@ nochange:
|
|||
xstrlcpy(lastname, tmp, NAME_MAX + 1);
|
||||
goto begin;
|
||||
}
|
||||
case SEL_EXEC: // fallthrough
|
||||
case SEL_SHELL: // fallthrough
|
||||
case SEL_PLUGKEY: // fallthrough
|
||||
case SEL_PLUGIN: // fallthrough
|
||||
case SEL_LAUNCH: // fallthrough
|
||||
case SEL_RUNCMD:
|
||||
endselection();
|
||||
|
||||
switch (sel) {
|
||||
case SEL_EXEC:
|
||||
if (!execute_file(cur, path, newpath, &presel))
|
||||
goto nochange;
|
||||
break;
|
||||
case SEL_SHELL:
|
||||
setenv(envs[ENV_NCUR], (ndents ? dents[cur].name : ""), 1);
|
||||
spawn(shell, NULL, NULL, path, F_CLI);
|
||||
break;
|
||||
case SEL_PLUGKEY: // fallthrough
|
||||
case SEL_PLUGIN:
|
||||
/* Check if directory is accessible */
|
||||
|
@ -5315,7 +5298,9 @@ nochange:
|
|||
setdirwatch();
|
||||
goto begin;
|
||||
}
|
||||
break;
|
||||
|
||||
/* Otherwise, initiate choosing plugin again */
|
||||
cfg.runplugin = 1;
|
||||
}
|
||||
|
||||
xstrlcpy(rundir, path, PATH_MAX);
|
||||
|
@ -5328,6 +5313,21 @@ nochange:
|
|||
setdirwatch();
|
||||
clearfilter();
|
||||
goto begin;
|
||||
case SEL_EXEC: // fallthrough
|
||||
case SEL_SHELL: // fallthrough
|
||||
case SEL_LAUNCH: // fallthrough
|
||||
case SEL_RUNCMD:
|
||||
endselection();
|
||||
|
||||
switch (sel) {
|
||||
case SEL_EXEC:
|
||||
if (!execute_file(cur, path, newpath, &presel))
|
||||
goto nochange;
|
||||
break;
|
||||
case SEL_SHELL:
|
||||
setenv(envs[ENV_NCUR], (ndents ? dents[cur].name : ""), 1);
|
||||
spawn(shell, NULL, NULL, path, F_CLI);
|
||||
break;
|
||||
case SEL_LAUNCH:
|
||||
launch_app(path, newpath);
|
||||
|
||||
|
|
14
src/nnn.h
14
src/nnn.h
|
@ -91,10 +91,10 @@ enum action {
|
|||
SEL_REMOTE,
|
||||
SEL_UMOUNT,
|
||||
SEL_HELP,
|
||||
SEL_EXEC,
|
||||
SEL_SHELL,
|
||||
SEL_PLUGKEY,
|
||||
SEL_PLUGIN,
|
||||
SEL_EXEC,
|
||||
SEL_SHELL,
|
||||
SEL_LAUNCH,
|
||||
SEL_RUNCMD,
|
||||
SEL_RUNEDIT,
|
||||
|
@ -237,17 +237,17 @@ static struct key bindings[] = {
|
|||
{ 'u', SEL_UMOUNT },
|
||||
/* Show help */
|
||||
{ '?', SEL_HELP },
|
||||
/* Execute file */
|
||||
{ 'C', SEL_EXEC },
|
||||
/* Run command */
|
||||
{ '!', SEL_SHELL },
|
||||
{ CONTROL(']'), SEL_SHELL },
|
||||
/* Plugin key */
|
||||
{ 'x', SEL_PLUGKEY },
|
||||
{ ';', SEL_PLUGKEY },
|
||||
/* Run a plugin */
|
||||
{ 'i', SEL_PLUGIN },
|
||||
{ CONTROL('V'), SEL_PLUGIN },
|
||||
/* Execute file */
|
||||
{ 'C', SEL_EXEC },
|
||||
/* Run command */
|
||||
{ '!', SEL_SHELL },
|
||||
{ CONTROL(']'), SEL_SHELL },
|
||||
/* Launcher */
|
||||
{ '=', SEL_LAUNCH },
|
||||
/* Run a command */
|
||||
|
|
Loading…
Reference in a new issue