diff options
author | Paul Fariello <paul@fariello.eu> | 2018-03-22 04:47:52 +0220 |
---|---|---|
committer | Paul Fariello <paul@fariello.eu> | 2018-09-05 13:49:40 +0200 |
commit | c9f6a78f574ce2a90ae7871a08a5ddcfb9ab7270 (patch) | |
tree | f56d2e25e1d5d127c57dd78c82634674774687f7 /src/ui | |
parent | ca022ec75e12d28e6ce71447fe877b90518de310 (diff) | |
download | profani-tty-c9f6a78f574ce2a90ae7871a08a5ddcfb9ab7270.tar.gz |
Add command subcommands: list and exec
Also handle list result
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/ui.h | 2 | ||||
-rw-r--r-- | src/ui/window.c | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/ui/ui.h b/src/ui/ui.h index d344f855..f1d8161f 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -377,6 +377,8 @@ void win_show_info(ProfWin *window, PContact contact); void win_clear(ProfWin *window); char* win_get_tab_identifier(ProfWin *window); char* win_to_string(ProfWin *window); +void win_command_list_error(ProfWin *window, const char *const error); +void win_handle_command_list(ProfWin *window, GSList *cmds); // desktop notifications void notifier_initialise(void); diff --git a/src/ui/window.c b/src/ui/window.c index 5543707d..3ba6b387 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1724,3 +1724,31 @@ win_sub_newline_lazy(WINDOW *win) wmove(win, cury+1, 0); } } + +void +win_command_list_error(ProfWin *window, const char *const error) +{ + assert(window != NULL); + + win_println(window, THEME_ERROR, '!', "Error retrieving command list: %s", error); +} + +void +win_handle_command_list(ProfWin *window, GSList *cmds) +{ + assert(window != NULL); + + if (cmds) { + win_println(window, THEME_DEFAULT, '!', "Ad hoc commands:"); + GSList *curr_cmd = cmds; + while (curr_cmd) { + const char *cmd = curr_cmd->data; + win_println(window, THEME_DEFAULT, '!', " %s", cmd); + curr_cmd = g_slist_next(curr_cmd); + } + win_println(window, THEME_DEFAULT, '!', ""); + } else { + win_println(window, THEME_DEFAULT, '!', "No commands found"); + win_println(window, THEME_DEFAULT, '!', ""); + } +} |