summaryrefslogtreecommitdiffstats
authorRaghavendra D Prabhu <[email protected]>2013-05-14 04:39:45 (GMT)
committer Raghavendra D Prabhu <[email protected]>2013-05-14 04:43:48 (GMT)
commit760268ce58b2db2216e3aaff0a84315e6c045de3 (patch) (side-by-side diff)
tree478ececc62a0336c4a21a95598b1a307dc7a08bd
parent4ad5f7bbc9b5b453f47b9179d5e2a1f4e220b642 (diff)
downloadweechat-rprabhu.zip
weechat-rprabhu.tar.gz
weechat-rprabhu.tar.bz2
core: Add /layout next|prev commands to switch betwene layouts.HEADrprabhu
This commit adds /layout next|prev to switch between layouts in both directions. It will also be useful to bind this to a key. Also fixes https://savannah.nongnu.org/task/?12613
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/core/wee-command.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 10d92a4..0bbc2b4 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -3266,6 +3266,61 @@ COMMAND_CALLBACK(layout)
return WEECHAT_RC_OK;
}
+ /* next layout */
+ if (string_strcasecmp (argv[1], "next") == 0)
+ {
+ command_layout_get_arguments (argc, argv, &layout_name, &ptr_layout,
+ &flag_buffers, &flag_windows);
+
+ ptr_layout = gui_layout_current->next_layout;
+
+ /* If last layout then wrap around to the first one */
+ if (!ptr_layout) {
+ for (ptr_layout = gui_layouts; ptr_layout->prev_layout;
+ ptr_layout = ptr_layout->prev_layout);
+ }
+
+ if (ptr_layout)
+ {
+ if (flag_buffers)
+ gui_layout_buffer_apply (ptr_layout);
+ if (flag_windows)
+ gui_layout_window_apply (ptr_layout, -1);
+ gui_layout_current = ptr_layout;
+ }
+
+ gui_chat_printf (NULL, "New layout %s", ptr_layout->name);
+
+ return WEECHAT_RC_OK;
+ }
+
+ /* previous layout */
+ if (string_strcasecmp (argv[1], "prev") == 0)
+ {
+ command_layout_get_arguments (argc, argv, &layout_name, &ptr_layout,
+ &flag_buffers, &flag_windows);
+
+ ptr_layout = gui_layout_current->prev_layout;
+
+ /* If the first layout, then wrap around to the last one */
+ if (!ptr_layout) {
+ for (ptr_layout = gui_layouts; ptr_layout->next_layout;
+ ptr_layout = ptr_layout->next_layout);
+ }
+
+ if (ptr_layout)
+ {
+ if (flag_buffers)
+ gui_layout_buffer_apply (ptr_layout);
+ if (flag_windows)
+ gui_layout_window_apply (ptr_layout, -1);
+ gui_layout_current = ptr_layout;
+ }
+
+ gui_chat_printf (NULL, "New layout %s", ptr_layout->name);
+ return WEECHAT_RC_OK;
+ }
+
/* leave current layout */
if (string_strcasecmp (argv[1], "leave") == 0)
{