diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-command.c | 78 | ||||
-rw-r--r-- | src/core/wee-config.c | 67 | ||||
-rw-r--r-- | src/core/weechat.c | 2 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-keyboard.c | 219 | ||||
-rw-r--r-- | src/gui/gui-keyboard.c | 43 | ||||
-rw-r--r-- | src/gui/gui-keyboard.h | 5 | ||||
-rw-r--r-- | src/plugins/irc/irc-buffer.c | 7 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 3 | ||||
-rw-r--r-- | src/plugins/jabber/jabber-buffer.c | 7 | ||||
-rw-r--r-- | src/plugins/jabber/jabber-server.c | 3 |
10 files changed, 243 insertions, 191 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index f9b3a6092..cd11607c3 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -1705,28 +1705,16 @@ command_input (void *data, struct t_gui_buffer *buffer, */ void -command_key_display (struct t_gui_key *key, int new_key) +command_key_display (struct t_gui_key *key) { char *expanded_name; - + expanded_name = gui_keyboard_get_expanded_name (key->key); - if (new_key) - { - gui_chat_printf (NULL, - _("New key binding: %s%s => %s%s"), - (expanded_name) ? expanded_name : key->key, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - key->command); - } - else - { - gui_chat_printf (NULL, " %20s%s => %s%s", - (expanded_name) ? expanded_name : key->key, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - key->command); - } + gui_chat_printf (NULL, " %20s%s => %s%s", + (expanded_name) ? expanded_name : key->key, + GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), + GUI_COLOR(GUI_COLOR_CHAT), + key->command); if (expanded_name) free (expanded_name); } @@ -1741,6 +1729,7 @@ command_key (void *data, struct t_gui_buffer *buffer, { char *internal_code; struct t_gui_key *ptr_key; + int old_keys_count, keys_added; /* make C compiler happy */ (void) data; @@ -1749,11 +1738,17 @@ command_key (void *data, struct t_gui_buffer *buffer, /* display all key bindings */ if (argc == 1) { - gui_chat_printf (NULL, ""); - gui_chat_printf (NULL, _("Key bindings:")); - for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key) + if (gui_keys_count == 0) + gui_chat_printf (NULL, _("No key binding defined")); + else { - command_key_display (ptr_key, 0); + gui_chat_printf (NULL, ""); + gui_chat_printf (NULL, _("Key bindings (%d):"), + gui_keys_count); + for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key) + { + command_key_display (ptr_key); + } } return WEECHAT_RC_OK; } @@ -1764,7 +1759,7 @@ command_key (void *data, struct t_gui_buffer *buffer, if ((argc >= 3) && (string_strcasecmp (argv[2], "-yes") == 0)) { gui_keyboard_free_all (&gui_keys, &last_gui_key); - gui_keyboard_init (); + gui_keyboard_default_bindings (); gui_chat_printf (NULL, _("Default key bindings restored")); } @@ -1779,6 +1774,21 @@ command_key (void *data, struct t_gui_buffer *buffer, return WEECHAT_RC_OK; } + /* add missing keys */ + if (string_strcasecmp (argv[1], "missing") == 0) + { + old_keys_count = gui_keys_count; + gui_keyboard_verbose = 1; + gui_keyboard_default_bindings (); + gui_keyboard_verbose = 0; + keys_added = (gui_keys_count > old_keys_count) ? + gui_keys_count - old_keys_count : 0; + gui_chat_printf (NULL, + NG_("%d new key added", "%d new keys added", keys_added), + keys_added); + return WEECHAT_RC_OK; + } + /* unbind a key */ if (string_strcasecmp (argv[1], "unbind") == 0) { @@ -1813,7 +1823,7 @@ command_key (void *data, struct t_gui_buffer *buffer, { gui_chat_printf (NULL, ""); gui_chat_printf (NULL, _("Key:")); - command_key_display (ptr_key, 0); + command_key_display (ptr_key); } else { @@ -1824,14 +1834,12 @@ command_key (void *data, struct t_gui_buffer *buffer, free (internal_code); return WEECHAT_RC_OK; } - + /* bind new key */ + gui_keyboard_verbose = 1; ptr_key = gui_keyboard_bind (NULL, argv[1], argv_eol[2]); - if (ptr_key) - { - command_key_display (ptr_key, 1); - } - else + gui_keyboard_verbose = 0; + if (!ptr_key) { gui_chat_printf (NULL, _("%sError: unable to bind key \"%s\""), @@ -3783,12 +3791,14 @@ command_init () &command_input, NULL); hook_command (NULL, "key", N_("bind/unbind keys"), - N_("[key [command [args]]] | [unbind key] | [reset -yes]"), + N_("[key [command [args]]] | [unbind key] | [reset -yes] | " + "[missing]"), N_(" key: display or bind this key to a command\n" " unbind: unbind a key\n" " reset: restore bindings to the default values and " - "delete ALL personal bindings (use carefully!)"), - "unbind|reset", + "delete ALL personal bindings (use carefully!)\n" + " missing: add missing keys (using default bindings)"), + "unbind|reset|missing", &command_key, NULL); hook_command (NULL, "layout", N_("save/apply/reset layout for buffers and windows"), diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 38c549663..5841516f0 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -395,15 +395,15 @@ config_change_day_change (void *data, struct t_config_option *option) } /* - * config_weechat_reload: reload WeeChat configuration file - * return one of these values: - * WEECHAT_CONFIG_READ_OK - * WEECHAT_CONFIG_READ_MEMORY_ERROR - * WEECHAT_CONFIG_READ_FILE_NOT_FOUND + * config_weechat_reload_cb: reload WeeChat configuration file + * return one of these values: + * WEECHAT_CONFIG_READ_OK + * WEECHAT_CONFIG_READ_MEMORY_ERROR + * WEECHAT_CONFIG_READ_FILE_NOT_FOUND */ int -config_weechat_reload (void *data, struct t_config_file *config_file) +config_weechat_reload_cb (void *data, struct t_config_file *config_file) { int rc; @@ -412,7 +412,6 @@ config_weechat_reload (void *data, struct t_config_file *config_file) /* remove all keys */ gui_keyboard_free_all (&gui_keys, &last_gui_key); - gui_keyboard_default_bindings (); /* remove all proxies */ proxy_free_all (); @@ -434,6 +433,9 @@ config_weechat_reload (void *data, struct t_config_file *config_file) proxy_use_temp_proxies (); gui_bar_use_temp_bars (); gui_bar_create_default (); + /* if no key was found config file, then we use default bindings */ + if (!gui_keys) + gui_keyboard_default_bindings (); } return rc; @@ -476,12 +478,12 @@ config_weechat_debug_set_all () } /* - * config_weechat_debug_change: called when a debug option is changed + * config_weechat_debug_change_cb: called when a debug option is changed */ void -config_weechat_debug_change (void *data, - struct t_config_option *option) +config_weechat_debug_change_cb (void *data, + struct t_config_option *option) { /* make C compiler happy */ (void) data; @@ -491,15 +493,15 @@ config_weechat_debug_change (void *data, } /* - * config_weechat_debug_create_option: create option in "debug" section + * config_weechat_debug_create_option_cb: create option in "debug" section */ int -config_weechat_debug_create_option (void *data, - struct t_config_file *config_file, - struct t_config_section *section, - const char *option_name, - const char *value) +config_weechat_debug_create_option_cb (void *data, + struct t_config_file *config_file, + struct t_config_section *section, + const char *option_name, + const char *value) { struct t_config_option *ptr_option; int rc; @@ -532,7 +534,7 @@ config_weechat_debug_create_option (void *data, option_name, "integer", _("debug level for plugin (\"core\" for WeeChat core)"), NULL, 0, 32, "0", value, 0, NULL, NULL, - &config_weechat_debug_change, NULL, + &config_weechat_debug_change_cb, NULL, NULL, NULL); rc = (ptr_option) ? WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR; @@ -549,14 +551,14 @@ config_weechat_debug_create_option (void *data, } /* - * config_weechat_debug_delete_option: delete option in "debug" section + * config_weechat_debug_delete_option_cb: delete option in "debug" section */ int -config_weechat_debug_delete_option (void *data, - struct t_config_file *config_file, - struct t_config_section *section, - struct t_config_option *option) +config_weechat_debug_delete_option_cb (void *data, + struct t_config_file *config_file, + struct t_config_section *section, + struct t_config_option *option) { /* make C compiler happy */ (void) data; @@ -577,11 +579,11 @@ config_weechat_debug_delete_option (void *data, int config_weechat_debug_set (const char *plugin_name, const char *value) { - return config_weechat_debug_create_option (NULL, - weechat_config_file, - weechat_config_section_debug, - plugin_name, - value); + return config_weechat_debug_create_option_cb (NULL, + weechat_config_file, + weechat_config_section_debug, + plugin_name, + value); } /* @@ -994,7 +996,7 @@ config_weechat_init_options () struct t_config_section *ptr_section; weechat_config_file = config_file_new (NULL, WEECHAT_CONFIG_NAME, - &config_weechat_reload, NULL); + &config_weechat_reload_cb, NULL); if (!weechat_config_file) return 0; @@ -1003,8 +1005,8 @@ config_weechat_init_options () 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, - &config_weechat_debug_create_option, NULL, - &config_weechat_debug_delete_option, NULL); + &config_weechat_debug_create_option_cb, NULL, + &config_weechat_debug_delete_option_cb, NULL); if (!ptr_section) { config_file_free (weechat_config_file); @@ -1863,8 +1865,11 @@ config_weechat_read () proxy_use_temp_proxies (); gui_bar_use_temp_bars (); gui_bar_create_default (); + /* if no key was found config file, then we use default bindings */ + if (!gui_keys) + gui_keyboard_default_bindings (); } - + if (rc != WEECHAT_CONFIG_READ_OK) { gui_chat_printf (NULL, diff --git a/src/core/weechat.c b/src/core/weechat.c index fb4b48092..236f5c3db 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -388,7 +388,7 @@ main (int argc, char *argv[]) gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */ weechat_init_vars (); /* initialize some variables */ command_init (); /* initialize WeeChat commands */ - gui_keyboard_init (); /* init keyb. (default key bindings)*/ + gui_keyboard_init (); /* init keyboard */ if (!config_weechat_init ()) /* init options with default values */ exit (EXIT_FAILURE); weechat_parse_args (argc, argv); /* parse command line args */ diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c index 269926f41..e0d187502 100644 --- a/src/gui/curses/gui-curses-keyboard.c +++ b/src/gui/curses/gui-curses-keyboard.c @@ -45,6 +45,28 @@ /* + * gui_keyboard_default_bind: create key bind, only if it does not exist yet + */ + +void +gui_keyboard_default_bind (const char *key, const char *command) +{ + struct t_gui_key *ptr_key; + char *internal_code; + + internal_code = gui_keyboard_get_internal_code (key); + + ptr_key = gui_keyboard_search (NULL, (internal_code) ? internal_code : key); + if (!ptr_key) + { + gui_keyboard_new (NULL, key, command); + } + + if (internal_code) + free (internal_code); +} + +/* * gui_keyboard_default_bindings: create default key bindings */ @@ -54,110 +76,111 @@ gui_keyboard_default_bindings () int i; char key_str[32], command[32]; - gui_keyboard_bind (NULL, /* RC */ "ctrl-M", "/input return"); - gui_keyboard_bind (NULL, /* RC */ "ctrl-J", "/input return"); - gui_keyboard_bind (NULL, /* tab */ "ctrl-I", "/input complete_next"); - gui_keyboard_bind (NULL, /* s-tab */ "meta2-Z", "/input complete_previous"); - gui_keyboard_bind (NULL, /* ^R */ "ctrl-R", "/input search_text"); - gui_keyboard_bind (NULL, /* basckpace */ "ctrl-H", "/input delete_previous_char"); - gui_keyboard_bind (NULL, /* basckpace */ "ctrl-?", "/input delete_previous_char"); - gui_keyboard_bind (NULL, /* del */ "meta2-3~", "/input delete_next_char"); - gui_keyboard_bind (NULL, /* ^D */ "ctrl-D", "/input delete_next_char"); - gui_keyboard_bind (NULL, /* ^W */ "ctrl-W", "/input delete_previous_word"); - gui_keyboard_bind (NULL, /* m-d */ "meta-d", "/input delete_next_word"); - gui_keyboard_bind (NULL, /* ^K */ "ctrl-K", "/input delete_end_of_line"); - gui_keyboard_bind (NULL, /* m-r */ "meta-r", "/input delete_line"); - gui_keyboard_bind (NULL, /* ^T */ "ctrl-T", "/input transpose_chars"); - gui_keyboard_bind (NULL, /* ^U */ "ctrl-U", "/input delete_beginning_of_line"); - gui_keyboard_bind (NULL, /* ^Y */ "ctrl-Y", "/input clipboard_paste"); - gui_keyboard_bind (NULL, /* home */ "meta2-1~", "/input move_beginning_of_line"); - gui_keyboard_bind (NULL, /* home */ "meta2-H", "/input move_beginning_of_line"); - gui_keyboard_bind (NULL, /* home */ "meta2-7~", "/input move_beginning_of_line"); - gui_keyboard_bind (NULL, /* ^A */ "ctrl-A", "/input move_beginning_of_line"); - gui_keyboard_bind (NULL, /* end */ "meta2-4~", "/input move_end_of_line"); - gui_keyboard_bind (NULL, /* end */ "meta2-F", "/input move_end_of_line"); - gui_keyboard_bind (NULL, /* end */ "meta2-8~", "/input move_end_of_line"); - gui_keyboard_bind (NULL, /* ^E */ "ctrl-E", "/input move_end_of_line"); - gui_keyboard_bind (NULL, /* left */ "meta2-D", "/input move_previous_char"); - gui_keyboard_bind (NULL, /* ^B */ "ctrl-B", "/input move_previous_char"); - gui_keyboard_bind (NULL, /* right */ "meta2-C", "/input move_next_char"); - gui_keyboard_bind (NULL, /* ^F */ "ctrl-F", "/input move_next_char"); - gui_keyboard_bind (NULL, /* m-b */ "meta-b", "/input move_previous_word"); - gui_keyboard_bind (NULL, /* ^left */ "meta-Od", "/input move_previous_word"); - gui_keyboard_bind (NULL, /* m-f */ "meta-f", "/input move_next_word"); - gui_keyboard_bind (NULL, /* ^right */ "meta-Oc", "/input move_next_word"); - gui_keyboard_bind (NULL, /* up */ "meta2-A", "/input history_previous"); - gui_keyboard_bind (NULL, /* down */ "meta2-B", "/input history_next"); - gui_keyboard_bind (NULL, /* ^up */ "meta-Oa", "/input history_global_previous"); - gui_keyboard_bind (NULL, /* ^down */ "meta-Ob", "/input history_global_next"); - gui_keyboard_bind (NULL, /* m-a */ "meta-a", "/input jump_smart"); - gui_keyboard_bind (NULL, /* m-j,m-l */ "meta-jmeta-l", "/input jump_last_buffer"); - gui_keyboard_bind (NULL, /* m-j,m-p */ "meta-jmeta-p", "/input jump_previous_buffer"); - gui_keyboard_bind (NULL, /* m-j,m-r */ "meta-jmeta-r", "/server raw"); - gui_keyboard_bind (NULL, /* m-h */ "meta-h", "/input hotlist_clear"); - gui_keyboard_bind (NULL, /* m-k */ "meta-k", "/input grab_key"); - gui_keyboard_bind (NULL, /* m-u */ "meta-u", "/input scroll_unread"); - gui_keyboard_bind (NULL, /* ^S^U */ "ctrl-Sctrl-U", "/input set_unread"); - gui_keyboard_bind (NULL, /* ^Cb */ "ctrl-Cb", "/input insert \\x02"); - gui_keyboard_bind (NULL, /* ^Cc */ "ctrl-Cc", "/input insert \\x03"); - gui_keyboard_bind (NULL, /* ^Cc */ "ctrl-Ci", "/input insert \\x1D"); - gui_keyboard_bind (NULL, /* ^Co */ "ctrl-Co", "/input insert \\x0F"); - gui_keyboard_bind (NULL, /* ^Cr */ "ctrl-Cr", "/input insert \\x12"); - gui_keyboard_bind (NULL, /* ^Cu */ "ctrl-Cu", "/input insert \\x15"); - gui_keyboard_bind (NULL, /* m-left */ "meta-meta2-D", "/buffer -1"); - gui_keyboard_bind (NULL, /* m-left (kde) */ "meta2-1;3D", "/buffer -1"); - gui_keyboard_bind (NULL, /* m-up */ "meta-meta2-A", "/buffer -1"); - gui_keyboard_bind (NULL, /* F5 */ "meta2-15~", "/buffer -1"); - gui_keyboard_bind (NULL, /* ^P */ "ctrl-P", "/buffer -1"); - gui_keyboard_bind (NULL, /* m-right */ "meta-meta2-C", "/buffer +1"); - gui_keyboard_bind (NULL, /* m-right (kde) */ "meta2-1;3C", "/buffer +1"); - gui_keyboard_bind (NULL, /* m-down */ "meta-meta2-B", "/buffer +1"); - gui_keyboard_bind (NULL, /* F6 */ "meta2-17~", "/buffer +1"); - gui_keyboard_bind (NULL, /* ^N */ "ctrl-N", "/buffer +1"); - gui_keyboard_bind (NULL, /* pgup */ "meta2-5~", "/window page_up"); - gui_keyboard_bind (NULL, /* pgup */ "meta2-I", "/window page_up"); - gui_keyboard_bind (NULL, /* pgdn */ "meta2-6~", "/window page_down"); - gui_keyboard_bind (NULL, /* pgdn */ "meta2-G", "/window page_down"); - gui_keyboard_bind (NULL, /* m-pgup */ "meta-meta2-5~", "/window scroll_up"); - gui_keyboard_bind (NULL, /* m-pgdn */ "meta-meta2-6~", "/window scroll_down"); - gui_keyboard_bind (NULL, /* m-home */ "meta-meta2-1~", "/window scroll_top"); - gui_keyboard_bind (NULL, /* m-home */ "meta-meta2-7~", "/window scroll_top"); - gui_keyboard_bind (NULL, /* m-end */ "meta-meta2-4~", "/window scroll_bottom"); - gui_keyboard_bind (NULL, /* m-end */ "meta-meta2-8~", "/window scroll_bottom"); - gui_keyboard_bind (NULL, /* m-n */ "meta-n", "/window scroll_next_highlight"); - gui_keyboard_bind (NULL, /* m-p */ "meta-p", "/window scroll_previous_highlight"); - gui_keyboard_bind (NULL, /* F9 */ "meta2-20~", "/bar scroll title * x-50%"); - gui_keyboard_bind (NULL, /* F10 */ "meta2-21~", "/bar scroll title * x+50%"); - gui_keyboard_bind (NULL, /* F11 */ "meta2-23~", "/bar scroll nicklist * y-100%"); - gui_keyboard_bind (NULL, /* F12 */ "meta2-24~", "/bar scroll nicklist * y+100%"); - gui_keyboard_bind (NULL, /* m-F11 */ "meta-meta2-23~", "/bar scroll nicklist * yb"); - gui_keyboard_bind (NULL, /* m-F12 */ "meta-meta2-24~", "/bar scroll nicklist * ye"); - gui_keyboard_bind (NULL, /* ^L */ "ctrl-L", "/window refresh"); - gui_keyboard_bind (NULL, /* F7 */ "meta2-18~", "/window -1"); - gui_keyboard_bind (NULL, /* F8 */ "meta2-19~", "/window +1"); - gui_keyboard_bind (NULL, /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up"); - gui_keyboard_bind (NULL, /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down"); - gui_keyboard_bind (NULL, /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left"); - gui_keyboard_bind (NULL, /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right"); - gui_keyboard_bind (NULL, /* m-z */ "meta-z", "/window zoom"); - gui_keyboard_bind (NULL, /* m-= */ "meta-=", "/filter toggle"); - gui_keyboard_bind (NULL, /* m-0 */ "meta-0", "/buffer 10"); - gui_keyboard_bind (NULL, /* m-1 */ "meta-1", "/buffer 1"); - gui_keyboard_bind (NULL, /* m-2 */ "meta-2", "/buffer 2"); - gui_keyboard_bind (NULL, /* m-3 */ "meta-3", "/buffer 3"); - gui_keyboard_bind (NULL, /* m-4 */ "meta-4", "/buffer 4"); - gui_keyboard_bind (NULL, /* m-5 */ "meta-5", "/buffer 5"); - gui_keyboard_bind (NULL, /* m-6 */ "meta-6", "/buffer 6"); - gui_keyboard_bind (NULL, /* m-7 */ "meta-7", "/buffer 7"); - gui_keyboard_bind (NULL, /* m-8 */ "meta-8", "/buffer 8"); - gui_keyboard_bind (NULL, /* m-9 */ "meta-9", "/buffer 9"); + gui_keyboard_default_bind (/* RC */ "ctrl-M", "/input return"); + gui_keyboard_default_bind (/* RC */ "ctrl-J", "/input return"); + gui_keyboard_default_bind (/* tab */ "ctrl-I", "/input complete_next"); + gui_keyboard_default_bind (/* s-tab */ "meta2-Z", "/input complete_previous"); + gui_keyboard_default_bind (/* ^R */ "ctrl-R", "/input search_text"); + gui_keyboard_default_bind (/* basckpace */ "ctrl-H", "/input delete_previous_char"); + gui_keyboard_default_bind (/* basckpace */ "ctrl-?", "/input delete_previous_char"); + gui_keyboard_default_bind (/* del */ "meta2-3~", "/input delete_next_char"); + gui_keyboard_default_bind (/* ^D */ "ctrl-D", "/input delete_next_char"); + gui_keyboard_default_bind (/* ^W */ "ctrl-W", "/input delete_previous_word"); + gui_keyboard_default_bind (/* m-d */ "meta-d", "/input delete_next_word"); + gui_keyboard_default_bind (/* ^K */ "ctrl-K", "/input delete_end_of_line"); + gui_keyboard_default_bind (/* m-r */ "meta-r", "/input delete_line"); + gui_keyboard_default_bind (/* ^T */ "ctrl-T", "/input transpose_chars"); + gui_keyboard_default_bind (/* ^U */ "ctrl-U", "/input delete_beginning_of_line"); + gui_keyboard_default_bind (/* ^Y */ "ctrl-Y", "/input clipboard_paste"); + gui_keyboard_default_bind (/* home */ "meta2-1~", "/input move_beginning_of_line"); + gui_keyboard_default_bind (/* home */ "meta2-H", "/input move_beginning_of_line"); + gui_keyboard_default_bind (/* home */ "meta2-7~", "/input move_beginning_of_line"); + gui_keyboard_default_bind (/* ^A */ "ctrl-A", "/input move_beginning_of_line"); + gui_keyboard_default_bind (/* end */ "meta2-4~", "/input move_end_of_line"); + gui_keyboard_default_bind (/* end */ "meta2-F", "/input move_end_of_line"); + gui_keyboard_default_bind (/* end */ "meta2-8~", "/input move_end_of_line"); + gui_keyboard_default_bind (/* ^E */ "ctrl-E", "/input move_end_of_line"); + gui_keyboard_default_bind (/* left */ "meta2-D", "/input move_previous_char"); + gui_keyboard_default_bind (/* ^B */ "ctrl-B", "/input move_previous_char"); + gui_keyboard_default_bind (/* right */ "meta2-C", "/input move_next_char"); + gui_keyboard_default_bind (/* ^F */ "ctrl-F", "/input move_next_char"); + gui_keyboard_default_bind (/* m-b */ "meta-b", "/input move_previous_word"); + gui_keyboard_default_bind (/* ^left */ "meta-Od", "/input move_previous_word"); + gui_keyboard_default_bind (/* m-f */ "meta-f", "/input move_next_word"); + gui_keyboard_default_bind (/* ^right */ "meta-Oc", "/input move_next_word"); + gui_keyboard_default_bind (/* up */ "meta2-A", "/input history_previous"); + gui_keyboard_default_bind (/* down */ "meta2-B", "/input history_next"); + gui_keyboard_default_bind (/* ^up */ "meta-Oa", "/input history_global_previous"); + gui_keyboard_default_bind (/* ^down */ "meta-Ob", "/input history_global_next"); + gui_keyboard_default_bind (/* m-a */ "meta-a", "/input jump_smart"); + gui_keyboard_default_bind (/* m-j,m-l */ "meta-jmeta-l", "/input jump_last_buffer"); + gui_keyboard_default_bind (/* m-j,m-p */ "meta-jmeta-p", "/input jump_previous_buffer"); + gui_keyboard_default_bind (/* m-j,m-r */ "meta-jmeta-r", "/server raw"); + gui_keyboard_default_bind (/* m-h */ "meta-h", "/input hotlist_clear"); + gui_keyboard_default_bind (/* m-k */ "meta-k", "/input grab_key"); + gui_keyboard_default_bind (/* m-s */ "meta-s", "/server switch"); + gui_keyboard_default_bind (/* m-u */ "meta-u", "/input scroll_unread"); + gui_keyboard_default_bind (/* ^S^U */ "ctrl-Sctrl-U", "/input set_unread"); + gui_keyboard_default_bind (/* ^Cb */ "ctrl-Cb", "/input insert \\x02"); + gui_keyboard_default_bind (/* ^Cc */ "ctrl-Cc", "/input insert \\x03"); + gui_keyboard_default_bind (/* ^Cc */ "ctrl-Ci", "/input insert \\x1D"); + gui_keyboard_default_bind (/* ^Co */ "ctrl-Co", "/input insert \\x0F"); + gui_keyboard_default_bind (/* ^Cr */ "ctrl-Cr", "/input insert \\x12"); + gui_keyboard_default_bind (/* ^Cu */ "ctrl-Cu", "/input insert \\x15"); + gui_keyboard_default_bind (/* m-left */ "meta-meta2-D", "/buffer -1"); + gui_keyboard_default_bind (/* m-left (kde) */ "meta2-1;3D", "/buffer -1"); + gui_keyboard_default_bind (/* m-up */ "meta-meta2-A", "/buffer -1"); + gui_keyboard_default_bind (/* F5 */ "meta2-15~", "/buffer -1"); + gui_keyboard_default_bind (/* ^P */ "ctrl-P", "/buffer -1"); + gui_keyboard_default_bind (/* m-right */ "meta-meta2-C", "/buffer +1"); + gui_keyboard_default_bind (/* m-right (kde) */ "meta2-1;3C", "/buffer +1"); + gui_keyboard_default_bind (/* m-down */ "meta-meta2-B", "/buffer +1"); + gui_keyboard_default_bind (/* F6 */ "meta2-17~", "/buffer +1"); + gui_keyboard_default_bind (/* ^N */ "ctrl-N", "/buffer +1"); + gui_keyboard_default_bind (/* pgup */ "meta2-5~", "/window page_up"); + gui_keyboard_default_bind (/* pgup */ "meta2-I", "/window page_up"); + gui_keyboard_default_bind (/* pgdn */ "meta2-6~", "/window page_down"); + gui_keyboard_default_bind (/* pgdn */ "meta2-G", "/window page_down"); + gui_keyboard_default_bind (/* m-pgup */ "meta-meta2-5~", "/window scroll_up"); + gui_keyboard_default_bind (/* m-pgdn */ "meta-meta2-6~", "/window scroll_down"); + gui_keyboard_default_bind (/* m-home */ "meta-meta2-1~", "/window scroll_top"); + gui_keyboard_default_bind (/* m-home */ "meta-meta2-7~", "/window scroll_top"); + gui_keyboard_default_bind (/* m-end */ "meta-meta2-4~", "/window scroll_bottom"); + gui_keyboard_default_bind (/* m-end */ "meta-meta2-8~", "/window scroll_bottom"); + gui_keyboard_default_bind (/* m-n */ "meta-n", "/window scroll_next_highlight"); + gui_keyboard_default_bind (/* m-p */ "meta-p", "/window scroll_previous_highlight"); + gui_keyboard_default_bind (/* F9 */ "meta2-20~", "/bar scroll title * x-50%"); + gui_keyboard_default_bind (/* F10 */ "meta2-21~", "/bar scroll title * x+50%"); + gui_keyboard_default_bind (/* F11 */ "meta2-23~", "/bar scroll nicklist * y-100%"); + gui_keyboard_default_bind (/* F12 */ "meta2-24~", "/bar scroll nicklist * y+100%"); + gui_keyboard_default_bind (/* m-F11 */ "meta-meta2-23~", "/bar scroll nicklist * yb"); + gui_keyboard_default_bind (/* m-F12 */ "meta-meta2-24~", "/bar scroll nicklist * ye"); + gui_keyboard_default_bind (/* ^L */ "ctrl-L", "/window refresh"); + gui_keyboard_default_bind (/* F7 */ "meta2-18~", "/window -1"); + gui_keyboard_default_bind (/* F8 */ "meta2-19~", "/window +1"); + gui_keyboard_default_bind (/* m-w,m-up */ "meta-wmeta-meta2-A", "/window up"); + gui_keyboard_default_bind (/* m-w,m-down */ "meta-wmeta-meta2-B", "/window down"); + gui_keyboard_default_bind (/* m-w,m-left */ "meta-wmeta-meta2-D", "/window left"); + gui_keyboard_default_bind (/* m-w,m-right */ "meta-wmeta-meta2-C", "/window right"); + gui_keyboard_default_bind (/* m-z */ "meta-z", "/window zoom"); + gui_keyboard_default_bind (/* m-= */ "meta-=", "/filter toggle"); + gui_keyboard_default_bind (/* m-0 */ "meta-0", "/buffer 10"); + gui_keyboard_default_bind (/* m-1 */ "meta-1", "/buffer 1"); + gui_keyboard_default_bind (/* m-2 */ "meta-2", "/buffer 2"); + gui_keyboard_default_bind (/* m-3 */ "meta-3", "/buffer 3"); + gui_keyboard_default_bind (/* m-4 */ "meta-4", "/buffer 4"); + gui_keyboard_default_bind (/* m-5 */ "meta-5", "/buffer 5"); + gui_keyboard_default_bind (/* m-6 */ "meta-6", "/buffer 6"); + gui_keyboard_default_bind (/* m-7 */ "meta-7", "/buffer 7"); + gui_keyboard_default_bind (/* m-8 */ "meta-8", "/buffer 8"); + gui_keyboard_default_bind (/* m-9 */ "meta-9", "/buffer 9"); /* bind meta-j + {01..99} to switch to buffers # > 10 */ for (i = 1; i < 100; i++) { sprintf (key_str, "meta-j%02d", i); sprintf (command, "/buffer %d", i); - gui_keyboard_bind (NULL, key_str, command); + gui_keyboard_default_bind (key_str, command); } } diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c index f14aa14ae..70ac6d817 100644 --- a/src/gui/gui-keyboard.c +++ b/src/gui/gui-keyboard.c @@ -34,6 +34,8 @@ #include "../plugins/plugin.h" #include "gui-keyboard.h" #include "gui-buffer.h" +#include "gui-chat.h" +#include "gui-color.h" #include "gui-completion.h" #include "gui-input.h" #include "gui-window.h" @@ -41,6 +43,9 @@ struct t_gui_key *gui_keys = NULL; /* key bindings */ struct t_gui_key *last_gui_key = NULL; /* last key binding */ +int gui_keys_count = 0; /* number of defined keys */ + +int gui_keyboard_verbose = 0; /* 1 to see some messages */ char gui_key_combo_buffer[128]; /* buffer used for combos */ int gui_key_grab = 0; /* 1 if grab mode enabled (alt-k) */ @@ -67,8 +72,6 @@ gui_keyboard_init () gui_key_combo_buffer[0] = '\0'; gui_key_grab = 0; gui_key_grab_count = 0; - - gui_keyboard_default_bindings (); } /* @@ -273,6 +276,8 @@ gui_keyboard_insert_sorted (struct t_gui_key **keys, struct t_gui_key **last_key *keys = key; *last_key = key; } + + gui_keys_count++; } /* @@ -286,20 +291,42 @@ gui_keyboard_new (struct t_gui_buffer *buffer, const char *key, const char *command) { struct t_gui_key *new_key; - char *internal_code; + char *expanded_name; if ((new_key = malloc (sizeof (*new_key)))) { - internal_code = gui_keyboard_get_internal_code (key); - new_key->key = (internal_code) ? strdup (internal_code) : strdup (key); - if (internal_code) - free (internal_code); + new_key->key = gui_keyboard_get_internal_code (key); + if (!new_key->key) + new_key->key = strdup (key); + if (!new_key->key) + { + free (new_key); + return NULL; + } new_key->command = (command) ? strdup (command) : NULL; + if (!new_key->command) + { + free (new_key); + return NULL; + } if (buffer) gui_keyboard_insert_sorted (&buffer->keys, &buffer->last_key, new_key); else gui_keyboard_insert_sorted (&gui_keys, &last_gui_key, new_key); + + if (gui_keyboard_verbose) + { + expanded_name = gui_keyboard_get_expanded_name (new_key->key); + gui_chat_printf (NULL, + _("New key binding: %s%s => %s%s"), + (expanded_name) ? expanded_name : new_key->key, + GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), + GUI_COLOR(GUI_COLOR_CHAT), + new_key->command); + if (expanded_name) + free (expanded_name); + } } else return NULL; @@ -525,6 +552,8 @@ gui_keyboard_free (struct t_gui_key **keys, struct t_gui_key **last_key, *last_key = key->prev_key; free (key); + + gui_keys_count--; } /* diff --git a/src/gui/gui-keyboard.h b/src/gui/gui-keyboard.h index 0fba1e557..5aea4b427 100644 --- a/src/gui/gui-keyboard.h +++ b/src/gui/gui-keyboard.h @@ -36,6 +36,8 @@ struct t_gui_key extern struct t_gui_key *gui_keys; extern struct t_gui_key *last_gui_key; +extern int gui_keys_count; +extern int gui_keyboard_verbose; extern char gui_key_combo_buffer[]; extern int gui_key_grab; extern int gui_key_grab_count; @@ -51,6 +53,9 @@ extern void gui_keyboard_grab_init (); extern void gui_keyboard_grab_end (); extern char *gui_keyboard_get_internal_code (const char *key); extern char *gui_keyboard_get_expanded_name (const char *key); +extern struct t_gui_key *gui_keyboard_new (struct t_gui_buffer *buffer, + const char *key, + const char *command); extern struct t_gui_key *gui_keyboard_search (struct t_gui_buffer *buffer, const char *key); extern struct t_gui_key *gui_keyboard_bind (struct t_gui_buffer *buffer, diff --git a/src/plugins/irc/irc-buffer.c b/src/plugins/irc/irc-buffer.c index 2539d3b21..8d6989a09 100644 --- a/src/plugins/irc/irc-buffer.c +++ b/src/plugins/irc/irc-buffer.c @@ -185,8 +185,6 @@ irc_buffer_merge_servers () "name", IRC_BUFFER_ALL_SERVERS_NAME); weechat_buffer_set (irc_buffer_servers, "short_name", IRC_BUFFER_ALL_SERVERS_NAME); - weechat_buffer_set (irc_buffer_servers, "key_bind_meta-s", - "/command irc /server switch"); weechat_buffer_set (irc_buffer_servers, "localvar_set_server", IRC_BUFFER_ALL_SERVERS_NAME); weechat_buffer_set (irc_buffer_servers, @@ -230,11 +228,6 @@ irc_buffer_split_server () struct t_irc_server *ptr_server; char buffer_name[256], charset_modifier[256]; - if (irc_buffer_servers) - { - weechat_buffer_set (irc_buffer_servers, "key_unbind_meta-s", ""); - } - for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) { diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 6f6918c4d..c4b77dabc 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -2184,9 +2184,6 @@ irc_server_connect (struct t_irc_server *server) weechat_buffer_set (server->buffer, "display", "auto"); weechat_bar_item_update ("buffer_name"); - - weechat_buffer_set (server->buffer, "key_bind_meta-s", - "/command irc /server switch"); } if (!server->addresses_array) diff --git a/src/plugins/jabber/jabber-buffer.c b/src/plugins/jabber/jabber-buffer.c index a52200f9b..bee32ae35 100644 --- a/src/plugins/jabber/jabber-buffer.c +++ b/src/plugins/jabber/jabber-buffer.c @@ -185,8 +185,6 @@ jabber_buffer_merge_servers () "name", JABBER_BUFFER_ALL_SERVERS_NAME); weechat_buffer_set (jabber_buffer_servers, "short_name", JABBER_BUFFER_ALL_SERVERS_NAME); - weechat_buffer_set (jabber_buffer_servers, "key_bind_meta-s", - "/command jabber /jabber switch"); weechat_buffer_set (jabber_buffer_servers, "localvar_set_server", JABBER_BUFFER_ALL_SERVERS_NAME); weechat_buffer_set (jabber_buffer_servers, @@ -230,11 +228,6 @@ jabber_buffer_split_server () struct t_jabber_server *ptr_server; char buffer_name[256], charset_modifier[256]; - if (jabber_buffer_servers) - { - weechat_buffer_set (jabber_buffer_servers, "key_unbind_meta-s", ""); - } - for (ptr_server = jabber_servers; ptr_server; ptr_server = ptr_server->next_server) { diff --git a/src/plugins/jabber/jabber-server.c b/src/plugins/jabber/jabber-server.c index bb2053e0c..811e1e17b 100644 --- a/src/plugins/jabber/jabber-server.c +++ b/src/plugins/jabber/jabber-server.c @@ -1172,9 +1172,6 @@ jabber_server_connect (struct t_jabber_server *server) weechat_buffer_set (server->buffer, "display", "auto"); weechat_bar_item_update ("buffer_name"); - - weechat_buffer_set (server->buffer, "key_bind_meta-s", - "/command jabber /jabber switch"); } if (!server->address) |