mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 13:51:31 +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);
|
xstrlcpy(lastname, tmp, NAME_MAX + 1);
|
||||||
goto begin;
|
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_PLUGKEY: // fallthrough
|
||||||
case SEL_PLUGIN:
|
case SEL_PLUGIN:
|
||||||
/* Check if directory is accessible */
|
/* Check if directory is accessible */
|
||||||
|
@ -5315,7 +5298,9 @@ nochange:
|
||||||
setdirwatch();
|
setdirwatch();
|
||||||
goto begin;
|
goto begin;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
/* Otherwise, initiate choosing plugin again */
|
||||||
|
cfg.runplugin = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
xstrlcpy(rundir, path, PATH_MAX);
|
xstrlcpy(rundir, path, PATH_MAX);
|
||||||
|
@ -5328,6 +5313,21 @@ nochange:
|
||||||
setdirwatch();
|
setdirwatch();
|
||||||
clearfilter();
|
clearfilter();
|
||||||
goto begin;
|
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:
|
case SEL_LAUNCH:
|
||||||
launch_app(path, newpath);
|
launch_app(path, newpath);
|
||||||
|
|
||||||
|
|
14
src/nnn.h
14
src/nnn.h
|
@ -91,10 +91,10 @@ enum action {
|
||||||
SEL_REMOTE,
|
SEL_REMOTE,
|
||||||
SEL_UMOUNT,
|
SEL_UMOUNT,
|
||||||
SEL_HELP,
|
SEL_HELP,
|
||||||
SEL_EXEC,
|
|
||||||
SEL_SHELL,
|
|
||||||
SEL_PLUGKEY,
|
SEL_PLUGKEY,
|
||||||
SEL_PLUGIN,
|
SEL_PLUGIN,
|
||||||
|
SEL_EXEC,
|
||||||
|
SEL_SHELL,
|
||||||
SEL_LAUNCH,
|
SEL_LAUNCH,
|
||||||
SEL_RUNCMD,
|
SEL_RUNCMD,
|
||||||
SEL_RUNEDIT,
|
SEL_RUNEDIT,
|
||||||
|
@ -237,17 +237,17 @@ static struct key bindings[] = {
|
||||||
{ 'u', SEL_UMOUNT },
|
{ 'u', SEL_UMOUNT },
|
||||||
/* Show help */
|
/* Show help */
|
||||||
{ '?', SEL_HELP },
|
{ '?', SEL_HELP },
|
||||||
/* Execute file */
|
|
||||||
{ 'C', SEL_EXEC },
|
|
||||||
/* Run command */
|
|
||||||
{ '!', SEL_SHELL },
|
|
||||||
{ CONTROL(']'), SEL_SHELL },
|
|
||||||
/* Plugin key */
|
/* Plugin key */
|
||||||
{ 'x', SEL_PLUGKEY },
|
{ 'x', SEL_PLUGKEY },
|
||||||
{ ';', SEL_PLUGKEY },
|
{ ';', SEL_PLUGKEY },
|
||||||
/* Run a plugin */
|
/* Run a plugin */
|
||||||
{ 'i', SEL_PLUGIN },
|
{ 'i', SEL_PLUGIN },
|
||||||
{ CONTROL('V'), SEL_PLUGIN },
|
{ CONTROL('V'), SEL_PLUGIN },
|
||||||
|
/* Execute file */
|
||||||
|
{ 'C', SEL_EXEC },
|
||||||
|
/* Run command */
|
||||||
|
{ '!', SEL_SHELL },
|
||||||
|
{ CONTROL(']'), SEL_SHELL },
|
||||||
/* Launcher */
|
/* Launcher */
|
||||||
{ '=', SEL_LAUNCH },
|
{ '=', SEL_LAUNCH },
|
||||||
/* Run a command */
|
/* Run a command */
|
||||||
|
|
Loading…
Reference in a new issue