From 547e3defc23e52cd4896ddde03f676385308acd0 Mon Sep 17 00:00:00 2001 From: Emanuele Giaquinta Date: Mon, 19 May 2008 11:25:14 +0000 Subject: [PATCH] Add 'list' option to bind command to list all the available commands and remove hardcoded list in bind help. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4835 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- docs/help/in/bind.in | 64 +---------------------------- src/fe-common/core/keyboard.c | 17 +++++++- src/fe-common/core/module-formats.c | 1 + src/fe-common/core/module-formats.h | 1 + 4 files changed, 18 insertions(+), 65 deletions(-) diff --git a/docs/help/in/bind.in b/docs/help/in/bind.in index 2501293c..d48dcd69 100644 --- a/docs/help/in/bind.in +++ b/docs/help/in/bind.in @@ -36,69 +36,7 @@ some other key than ^W, then it would be better done as: /BIND window-^K /WINDOW KILL -Command can be one of: - - command - Run any /COMMAND (you could use /COMMAND directly without - specifying this) - -(Cursor movement) - backward_character - forward_character - backward_word - forward_word - beginning_of_line - end_of_line - -(Scrollback movement) - scroll_backward - Previous page - scroll_forward - Next page - scroll_start - Beginning of the window - scroll_end - End of the window - -(Switching windows) - change_window - previous_window - next_window - upper_window - lower_window - active_window - Go to next window with the highest activity - next_window_item - Next channel/query. In empty windows change - to next server - previous_window_item - Previous channel/query. In empty windows change - to previous server - -(History) - backward_history - forward_history - -(Deleting text) - backspace - delete_character - delete_next_word - delete_previous_word - delete_to_next_space - delete_to_previous_space - erase_line - erase_to_beg_of_line - erase_to_end_of_line - -(Word completion) - word_completion - erase_completion - check_replaces - Check word replaces - -(Misc) - nothing - use this to disable a built-in key - refresh_screen - yank_from_cutbuffer - "Undelete" line - transpose_characters - Swap current and previous character - transpose_words - Swap current and previous word - capitalize_word - Capitalize word from current position - downcase_word - Downcase word from current position - upcase_word - Upcase word from current position - escape_char - Insert the next character exactly as-is to input line - insert_text - Insert data to entry line, data may contain $variables. - stop_irc - Send SIGSTOP to client (^Z) +To get a list of all bindable commands use /bind -list. Examples: diff --git a/src/fe-common/core/keyboard.c b/src/fe-common/core/keyboard.c index d97f5c05..6154cb99 100644 --- a/src/fe-common/core/keyboard.c +++ b/src/fe-common/core/keyboard.c @@ -670,7 +670,7 @@ static void cmd_show_keys(const char *searchkey, int full) printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_BIND_FOOTER); } -/* SYNTAX: BIND [-delete] [ [ []]] */ +/* SYNTAX: BIND [-list] [-delete] [ [ []]] */ static void cmd_bind(const char *data) { GHashTable *optlist; @@ -682,6 +682,19 @@ static void cmd_bind(const char *data) "bind", &optlist, &key, &id, &keydata)) return; + if (g_hash_table_lookup(optlist, "list")) { + GSList *tmp; + + for (tmp = keyinfos; tmp != NULL; tmp = tmp->next) { + KEYINFO_REC *rec = tmp->data; + + printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_BIND_COMMAND_LIST, + rec->id, rec->description ? rec->description : ""); + } + cmd_params_free(free_arg); + return; + } + if (*key != '\0' && g_hash_table_lookup(optlist, "delete")) { /* delete key */ key_configure_remove(key); @@ -840,7 +853,7 @@ void keyboard_init(void) signal_add("complete command bind", (SIGNAL_FUNC) sig_complete_bind); command_bind("bind", NULL, (SIGNAL_FUNC) cmd_bind); - command_set_options("bind", "delete"); + command_set_options("bind", "delete list"); } void keyboard_deinit(void) diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index 7c9506e6..10ada9ec 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -269,6 +269,7 @@ FORMAT_REC fecommon_core_formats[] = { { "perl_error", "Perl error: $0", 1, { 0 } }, { "bind_header", "%#Key Action", 0 }, { "bind_list", "%#$[!20]0 $1 $2", 3, { 0, 0, 0 } }, + { "bind_command_list", "$[!30]0 $1", 2, { 0, 0 } }, { "bind_footer", "", 0 }, { "bind_unknown_id", "Unknown bind action: $0", 1, { 0 } }, { "config_saved", "Saved configuration to file $0", 1, { 0 } }, diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h index bed3be3a..64dde0f9 100644 --- a/src/fe-common/core/module-formats.h +++ b/src/fe-common/core/module-formats.h @@ -234,6 +234,7 @@ enum { TXT_PERL_ERROR, TXT_BIND_HEADER, TXT_BIND_LIST, + TXT_BIND_COMMAND_LIST, TXT_BIND_FOOTER, TXT_BIND_UNKNOWN_ID, TXT_CONFIG_SAVED,