summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-10-05 16:42:49 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-10-05 16:42:49 +0200
commit2bfe49d28b241d7dcd7e410863a27052e9fdbc79 (patch)
tree480ce850c4514ad16c6064b997519032d7c1513a /src
parent7b2f578ac4026ea0f94b9060801a9f97bb243d2c (diff)
downloadweechat-2bfe49d28b241d7dcd7e410863a27052e9fdbc79.zip
Add option grab_key_command for /input (bound by default to alt-k)
New binding for alt-k is not automatic (for existing config), if you want to use it, you can do: /key bind meta-k /input grab_key_command
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-command.c9
-rw-r--r--src/gui/curses/gui-curses-keyboard.c2
-rw-r--r--src/gui/gui-input.c14
-rw-r--r--src/gui/gui-input.h1
-rw-r--r--src/gui/gui-keyboard.c15
-rw-r--r--src/gui/gui-keyboard.h2
6 files changed, 36 insertions, 7 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index ebe15ea19..0b25435e8 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -1843,6 +1843,8 @@ command_input (void *data, struct t_gui_buffer *buffer,
gui_input_hotlist_clear ();
else if (string_strcasecmp (argv[1], "grab_key") == 0)
gui_input_grab_key ();
+ else if (string_strcasecmp (argv[1], "grab_key_command") == 0)
+ gui_input_grab_key_command ();
else if (string_strcasecmp (argv[1], "scroll_unread") == 0)
gui_input_scroll_unread ();
else if (string_strcasecmp (argv[1], "set_unread") == 0)
@@ -4123,8 +4125,8 @@ command_init ()
"jump_smart | jump_last_buffer | "
"jump_previously_visited_buffer | "
"jump_next_visited_buffer | hotlist_clear | grab_key | "
- "scroll_unread | set_unread | set_unread_current_buffer | "
- "insert [args]",
+ "grab_key_command | scroll_unread | set_unread | "
+ "set_unread_current_buffer | insert [args]",
N_("This command is used by key bindings or plugins."),
"return|complete_next|complete_previous|search_next|"
"delete_previous_char|delete_next_char|"
@@ -4137,7 +4139,8 @@ command_init ()
"history_global_previous|history_global_next|"
"jump_smart|jump_last_buffer|jump_previously_visited_buffer|"
"jump_next_visited_buffer|hotlist_clear|grab_key|"
- "scroll_unread|set_unread|set_unread_current_buffer|insert",
+ "grab_key_command|scroll_unread|set_unread|"
+ "set_unread_current_buffer|insert",
&command_input, NULL);
hook_command (NULL, "key",
N_("bind/unbind keys"),
diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c
index 08495a2c8..64db0cf48 100644
--- a/src/gui/curses/gui-curses-keyboard.c
+++ b/src/gui/curses/gui-curses-keyboard.c
@@ -118,7 +118,7 @@ gui_keyboard_default_bindings ()
gui_keyboard_default_bind (/* m-j,m-r */ "meta-jmeta-r", "/server raw");
gui_keyboard_default_bind (/* m-j,m-s */ "meta-jmeta-s", "/server jump");
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-k */ "meta-k", "/input grab_key_command");
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");
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index 806a97b9d..b40013718 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -1224,7 +1224,19 @@ void
gui_input_grab_key ()
{
if (gui_current_window->buffer->input)
- gui_keyboard_grab_init ();
+ gui_keyboard_grab_init (0);
+}
+
+/*
+ * gui_input_grab_key_command: init "grab key mode" (next key and command
+ * bound will be inserted into input buffer)
+ */
+
+void
+gui_input_grab_key_command ()
+{
+ if (gui_current_window->buffer->input)
+ gui_keyboard_grab_init (1);
}
/*
diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h
index 0a1e4983d..d930e158c 100644
--- a/src/gui/gui-input.h
+++ b/src/gui/gui-input.h
@@ -63,6 +63,7 @@ extern void gui_input_jump_previously_visited_buffer ();
extern void gui_input_jump_next_visited_buffer ();
extern void gui_input_hotlist_clear ();
extern void gui_input_grab_key ();
+extern void gui_input_grab_key_command ();
extern void gui_input_scroll_unread ();
extern void gui_input_set_unread ();
extern void gui_input_set_unread_current_buffer ();
diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c
index e3ee919ee..79de71a3b 100644
--- a/src/gui/gui-keyboard.c
+++ b/src/gui/gui-keyboard.c
@@ -53,6 +53,7 @@ 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) */
int gui_key_grab_count = 0; /* number of keys pressed in grab mode */
+int gui_key_grab_command = 0; /* grab command bound to key? */
int *gui_keyboard_buffer = NULL; /* input buffer (for paste detection) */
int gui_keyboard_buffer_alloc = 0; /* input buffer allocated size */
@@ -96,10 +97,11 @@ gui_keyboard_init_last_activity_time ()
*/
void
-gui_keyboard_grab_init ()
+gui_keyboard_grab_init (int grab_command)
{
gui_key_grab = 1;
gui_key_grab_count = 0;
+ gui_key_grab_command = grab_command;
}
/*
@@ -110,6 +112,7 @@ void
gui_keyboard_grab_end ()
{
char *expanded_key;
+ struct t_gui_key *ptr_key;
/* get expanded name (for example: ^U => ctrl-u) */
expanded_key = gui_keyboard_get_expanded_name (gui_key_combo_buffer);
@@ -119,6 +122,15 @@ gui_keyboard_grab_end ()
if (gui_current_window->buffer->input)
{
gui_input_insert_string (gui_current_window->buffer, expanded_key, -1);
+ if (gui_key_grab_command)
+ {
+ ptr_key = gui_keyboard_search (NULL, gui_key_combo_buffer);
+ if (ptr_key)
+ {
+ gui_input_insert_string (gui_current_window->buffer, " ", -1);
+ gui_input_insert_string (gui_current_window->buffer, ptr_key->command, -1);
+ }
+ }
if (gui_current_window->buffer->completion)
gui_completion_stop (gui_current_window->buffer->completion, 1);
gui_input_text_changed_modifier_and_signal (gui_current_window->buffer);
@@ -129,6 +141,7 @@ gui_keyboard_grab_end ()
/* end grab mode */
gui_key_grab = 0;
gui_key_grab_count = 0;
+ gui_key_grab_command = 0;
gui_key_combo_buffer[0] = '\0';
}
diff --git a/src/gui/gui-keyboard.h b/src/gui/gui-keyboard.h
index b58c56e8c..708778025 100644
--- a/src/gui/gui-keyboard.h
+++ b/src/gui/gui-keyboard.h
@@ -49,7 +49,7 @@ extern time_t gui_keyboard_last_activity_time;
/* keyboard functions */
extern void gui_keyboard_init ();
-extern void gui_keyboard_grab_init ();
+extern void gui_keyboard_grab_init (int grab_command);
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);