From 4e06d502553cc8414f9164e2bb9a4d2b4bfc6448 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 11 May 2001 13:44:23 +0000 Subject: [PATCH] updated /BIND help, removed special_char bind command and added insert_text. It can be used to add text to entry line, $variables also works with it (eg. /BIND ^T /TOPIC $topic) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1476 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- docs/help/in/bind.in | 54 ++++++++++++++++++++++++-------------- src/fe-text/gui-readline.c | 28 +++++++++++--------- 2 files changed, 50 insertions(+), 32 deletions(-) diff --git a/docs/help/in/bind.in b/docs/help/in/bind.in index c6785e99..0d0d2ab1 100644 --- a/docs/help/in/bind.in +++ b/docs/help/in/bind.in @@ -1,28 +1,43 @@ @SYNTAX:bind@ -Bind some action to specified keystroke. +Bind some action to specified keystroke. Remember that all characters +in keystrokes are case-sensitive! Uppercase letter usually means that +you need to keep SHIFT pressed to get the key to work. -Keystroke can have modifiers: +Most most commonly used keystrokes are: - ctrl-x - alt-x - alt-shift-x + ^X - Ctrl-X + meta-x - Meta-x (Meta is quite often Alt-key in PCs, ESC-x works too) -Where x being either a single character, or one of the special keys: +Irssi has by default also defined several other keys which you can use: - Backspace Delete - Home End Prior Next - Up Down Left Right - Insert Return Tab + return - The return/enter key + up, down, left, right - Arrow keys + home, end, prior, next - prior = Page Up, next = Page Down + insert, delete + +The keystroke can contain as many key presses as you want, and you can +define names for different key sequences to use them more easily (the +keys above are done like that). For example, you may want to manage +windows with ^W key, so that ^W^C creates new window, ^W^K kills the +active window, etc. you may do it like: + + /BIND ^W^C /WINDOW NEW HIDE + /BIND ^W^K /WINDOW KILL + +But maybe you wish to give these binds to other people who want to use +some other key than ^W, then it would be better done as: + + /BIND ^W key window + /BIND window-^C /WINDOW NEW HIDE + /BIND window-^K /WINDOW KILL -(these key specifications will some day change to be more epic-like -when I have time to implement it) Command can be one of: - command - Run any IRC command (you could use /command directly without - specifying this) + command - Run any /COMMAND (you could use /COMMAND directly without + specifying this) (Cursor movement) backward_character @@ -73,14 +88,13 @@ Command can be one of: refresh_screen yank_from_cutbuffer - "Undelete" line transpose_characters - Swap current and previous character - special_char - Insert special character, data specifies the character. - This is used mostly for setting bold, underline, color, etc. + insert_text - Insert data to entry line, data may contain $variables. Examples: Clear screen: - /BIND Alt-C /CLEAR + /BIND meta-c /CLEAR -People with qwertz layout probably want to swap Alt-Y and Alt-Z: - /BIND Alt-Z change_window 16 - /BIND -delete Alt-Y +People with qwertz layout probably want to swap meta-y and meta-z: + /BIND meta-z change_window 16 + /BIND -delete meta-y diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index aab1c156..527df019 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -22,6 +22,7 @@ #include "signals.h" #include "misc.h" #include "settings.h" +#include "special-vars.h" #include "completion.h" #include "command-history.h" @@ -447,8 +448,10 @@ static void key_next_window_item(void) SERVER_REC *server; int index; - if (active_win->items != NULL) - signal_emit("command window item next", 3, "", active_win->active_server, active_win->active); + if (active_win->items != NULL) { + signal_emit("command window item next", 3, "", + active_win->active_server, active_win->active); + } else if (servers != NULL) { /* change server */ if (active_win->active_server == NULL) @@ -458,13 +461,19 @@ static void key_next_window_item(void) server = index > 0 ? g_slist_nth(servers, index-1)->data : g_slist_last(servers)->data; } - signal_emit("command window server", 3, server->tag, active_win->active_server, active_win->active); + signal_emit("command window server", 3, server->tag, + active_win->active_server, active_win->active); } } -static void key_addchar(const char *data) +static void key_insert_text(const char *data) { - gui_entry_insert_char(*data); + char *str; + + str = parse_special_string(data, active_win->active_server, + active_win->active, "", NULL, 0); + gui_entry_insert_text(str); + g_free(str); } static void sig_window_auto_changed(void) @@ -589,12 +598,7 @@ void gui_readline_init(void) key_bind("scroll_end", "End of the window", "", NULL, (SIGNAL_FUNC) key_scroll_end); /* inserting special input characters to line.. */ - key_bind("special_char", "Insert special character", "^B", "\002", (SIGNAL_FUNC) key_addchar); - key_bind("special_char", NULL, "^-", "\037", NULL); - key_bind("special_char", NULL, "^C", "\003", NULL); - key_bind("special_char", NULL, "^V", "\026", NULL); - key_bind("special_char", NULL, "^G", "\007", NULL); - key_bind("special_char", NULL, "^O", "\017", NULL); + key_bind("insert_text", "Append text to line", NULL, NULL, (SIGNAL_FUNC) key_insert_text); key_bind("multi", NULL, "return", "check_replaces;send_line", NULL); @@ -656,7 +660,7 @@ void gui_readline_deinit(void) key_unbind("scroll_start", (SIGNAL_FUNC) key_scroll_start); key_unbind("scroll_end", (SIGNAL_FUNC) key_scroll_end); - key_unbind("special_char", (SIGNAL_FUNC) key_addchar); + key_unbind("insert_text", (SIGNAL_FUNC) key_insert_text); key_unbind("change_window", (SIGNAL_FUNC) key_change_window); keyboard_destroy(keyboard);