summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-02-02 16:35:44 +0100
committerSebastien Helleu <flashcode@flashtux.org>2010-02-02 16:35:44 +0100
commit8109368f7c0b505b7b3674348f8b18a03f1a3f0f (patch)
treedbf9d666fb81edeb01093ec1aec99a484fe3e122 /src
parent69b53c8f3db9e52f4bbc0bb2ce02c19568e9e695 (diff)
downloadweechat-8109368f7c0b505b7b3674348f8b18a03f1a3f0f.zip
Add option "switch_active_buffer_previous" for command /input (task #10141)
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-command.c7
-rw-r--r--src/gui/gui-buffer.c28
-rw-r--r--src/gui/gui-buffer.h1
-rw-r--r--src/gui/gui-input.c23
-rw-r--r--src/gui/gui-input.h1
5 files changed, 56 insertions, 4 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 9e687fcf4..445d97a43 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -1879,6 +1879,8 @@ command_input (void *data, struct t_gui_buffer *buffer,
gui_input_set_unread_buffer (gui_current_window->buffer);
else if (string_strcasecmp (argv[1], "switch_active_buffer") == 0)
gui_input_switch_active_buffer (gui_current_window);
+ else if (string_strcasecmp (argv[1], "switch_active_buffer_previous") == 0)
+ gui_input_switch_active_buffer_previous (gui_current_window);
else if (string_strcasecmp (argv[1], "insert") == 0)
{
if (argc > 2)
@@ -4160,7 +4162,7 @@ command_init ()
"jump_next_visited_buffer | hotlist_clear | grab_key | "
"grab_key_command | scroll_unread | set_unread | "
"set_unread_current_buffer | switch_active_buffer | "
- "insert [args]",
+ "switch_active_buffer_previous | 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|"
@@ -4174,7 +4176,8 @@ command_init ()
"jump_smart|jump_last_buffer|jump_previously_visited_buffer|"
"jump_next_visited_buffer|hotlist_clear|grab_key|"
"grab_key_command|scroll_unread|set_unread|"
- "set_unread_current_buffer|switch_active_buffer|insert",
+ "set_unread_current_buffer|switch_active_buffer|"
+ "switch_active_buffer_previous|insert",
&command_input, NULL);
hook_command (NULL, "key",
N_("bind/unbind keys"),
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 1d1acf5c2..f2df9dbf2 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -1732,6 +1732,34 @@ gui_buffer_get_next_active_buffer (struct t_gui_buffer *buffer)
}
/*
+ * gui_buffer_get_previous_active_buffer: get previous active buffer (when many
+ * buffers are merged)
+ */
+
+struct t_gui_buffer *
+gui_buffer_get_previous_active_buffer (struct t_gui_buffer *buffer)
+{
+ struct t_gui_buffer *ptr_buffer;
+
+ if (buffer->prev_buffer
+ && (buffer->prev_buffer->number == buffer->number))
+ return buffer->prev_buffer;
+ else
+ {
+ for (ptr_buffer = last_gui_buffer; ptr_buffer;
+ ptr_buffer = ptr_buffer->prev_buffer)
+ {
+ if ((ptr_buffer != buffer)
+ && (ptr_buffer->number == buffer->number))
+ {
+ return ptr_buffer;
+ }
+ }
+ }
+ return buffer;
+}
+
+/*
* gui_buffer_move_to_number: move a buffer to another number
*/
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index fd0ed41ba..77ded8b52 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -233,6 +233,7 @@ extern void gui_buffer_switch_by_number (struct t_gui_window *window,
int number);
extern void gui_buffer_set_active_buffer (struct t_gui_buffer *buffer);
extern struct t_gui_buffer *gui_buffer_get_next_active_buffer (struct t_gui_buffer *buffer);
+extern struct t_gui_buffer *gui_buffer_get_previous_active_buffer (struct t_gui_buffer *buffer);
extern void gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number);
extern void gui_buffer_merge (struct t_gui_buffer *buffer,
struct t_gui_buffer *target_buffer);
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index 3dd4d431f..dce6be51b 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -1288,8 +1288,8 @@ gui_input_set_unread_buffer (struct t_gui_buffer *buffer)
}
/*
- * gui_input_switch_active_buffer: switch active buffer (when many buffers are
- * merged)
+ * gui_input_switch_active_buffer: switch active buffer to next buffer
+ * (when many buffers are merged)
*/
void
@@ -1306,6 +1306,25 @@ gui_input_switch_active_buffer (struct t_gui_window *window)
}
/*
+ * gui_input_switch_active_buffer_previous: switch active buffer to previous
+ * buffer (when many buffers are
+ * merged)
+ */
+
+void
+gui_input_switch_active_buffer_previous (struct t_gui_window *window)
+{
+ struct t_gui_buffer *ptr_buffer;
+
+ ptr_buffer = gui_buffer_get_previous_active_buffer (window->buffer);
+ if (ptr_buffer)
+ {
+ gui_buffer_set_active_buffer (ptr_buffer);
+ gui_window_switch_to_buffer (window, ptr_buffer, 1);
+ }
+}
+
+/*
* gui_input_insert: insert a string in command line
* (many default keys are bound to this function)
*/
diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h
index 9586b04ee..a03a6ec44 100644
--- a/src/gui/gui-input.h
+++ b/src/gui/gui-input.h
@@ -70,6 +70,7 @@ extern void gui_input_scroll_unread (struct t_gui_window *window);
extern void gui_input_set_unread ();
extern void gui_input_set_unread_buffer (struct t_gui_buffer *buffer);
extern void gui_input_switch_active_buffer (struct t_gui_window *window);
+extern void gui_input_switch_active_buffer_previous (struct t_gui_window *window);
extern void gui_input_insert (struct t_gui_buffer *buffer, const char *args);
#endif /* gui-input.h */