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

View file

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