Refactor plugin handling

This commit is contained in:
Arun Prakash Jana 2019-12-27 13:19:23 +05:30
parent 5676dfe682
commit bffadf09c5
No known key found for this signature in database
GPG key ID: A75979F35C080412
2 changed files with 75 additions and 75 deletions

View file

@ -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);

View file

@ -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 */