diff --git a/include/simpleswitcher.h b/include/simpleswitcher.h index 391767ca..54b78b70 100644 --- a/include/simpleswitcher.h +++ b/include/simpleswitcher.h @@ -12,11 +12,12 @@ typedef enum { WINDOW_SWITCHER, RUN_DIALOG, SSH_DIALOG, - MODE_EXIT + NUM_DIALOGS, + MODE_EXIT, + NEXT_DIALOG } SwitcherMode; - typedef int ( *menu_match_cb )( char **tokens, const char *input, int index, void *data ); int menu( char **lines, char **input, char *prompt, int selected, Time *time, int *shift, menu_match_cb mmc, void *mmc_data ); diff --git a/source/run-dialog.c b/source/run-dialog.c index 28d2cbb8..66115b5f 100644 --- a/source/run-dialog.c +++ b/source/run-dialog.c @@ -256,7 +256,7 @@ SwitcherMode run_switcher_dialog ( char **input ) int n = menu( cmd_list, input, "$ ", 0, NULL, &shift,token_match, NULL ); if ( n == -2 ) { - retv = SSH_DIALOG; + retv = NEXT_DIALOG; } else if ( n >=0 && cmd_list[n] != NULL ) { exec_cmd( cmd_list[n], shift ); } else if ( n == -3 && *input != NULL && *input[0] != '\0' ) { diff --git a/source/simpleswitcher.c b/source/simpleswitcher.c index fe48bf7e..928e27bc 100644 --- a/source/simpleswitcher.c +++ b/source/simpleswitcher.c @@ -1097,7 +1097,7 @@ SwitcherMode run_switcher_window ( char **input ) int n = menu( list, input, "> ", 0, &time, NULL,window_match, ids ); if ( n == -2 ) { - retv = RUN_DIALOG; + retv = NEXT_DIALOG; } else if ( n >= 0 && list[n] ) { #ifdef I3 @@ -1142,12 +1142,18 @@ void run_switcher( int fmode, SwitcherMode mode ) char *input = NULL; do { + SwitcherMode retv = MODE_EXIT; if ( mode == WINDOW_SWITCHER ) { - mode = run_switcher_window( &input ); + retv = run_switcher_window( &input ); } else if ( mode == RUN_DIALOG ) { - mode = run_switcher_dialog( &input ); + retv = run_switcher_dialog( &input ); } else if ( mode == SSH_DIALOG ) { - mode = ssh_switcher_dialog( &input ); + retv = ssh_switcher_dialog( &input ); + } + if(retv == NEXT_DIALOG) { + mode = (mode+1)%NUM_DIALOGS; + } else { + mode = retv; } } while ( mode != MODE_EXIT ); diff --git a/source/ssh-dialog.c b/source/ssh-dialog.c index 3db2362c..341345a8 100644 --- a/source/ssh-dialog.c +++ b/source/ssh-dialog.c @@ -252,7 +252,7 @@ SwitcherMode ssh_switcher_dialog ( char **input ) int n = menu( cmd_list, input, "ssh ", 0, NULL, &shift,token_match, NULL ); if ( n == -2 ) { - retv = WINDOW_SWITCHER; + retv = NEXT_DIALOG; } else if ( n >=0 && cmd_list[n] != NULL ) { exec_ssh( cmd_list[n] ); } else if ( n == -3 && *input != NULL && *input[0] != '\0' ) {