From 397b58e88fc09f63440170401d92b1cfea91e88f Mon Sep 17 00:00:00 2001 From: crondog Date: Wed, 30 Dec 2015 18:34:58 +1100 Subject: split toggle Not sure if you will accept this, but i find it useful (I use it when opening new terminal windows on a workspace v2: add short hand command and docs --- sway/commands.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index 4d5018a0..6c24395f 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -61,6 +61,7 @@ static sway_cmd cmd_scratchpad; static sway_cmd cmd_set; static sway_cmd cmd_split; static sway_cmd cmd_splith; +static sway_cmd cmd_splitt; static sway_cmd cmd_splitv; static sway_cmd cmd_sticky; static sway_cmd cmd_workspace; @@ -1340,6 +1341,13 @@ static struct cmd_results *cmd_split(int argc, char **argv) { _do_split(argc - 1, argv + 1, L_VERT); } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) { _do_split(argc - 1, argv + 1, L_HORIZ); + } else if (strcasecmp(argv[0], "t") == 0 || strcasecmp(argv[0], "toggle") == 0) { + swayc_t *focused = get_focused_container(&root_container); + if (focused->parent->layout == L_VERT) { + _do_split(argc - 1, argv + 1, L_HORIZ); + } else { + _do_split(argc - 1, argv + 1, L_VERT); + } } else { error = cmd_results_new(CMD_FAILURE, "split", "Invalid split command (expected either horiziontal or vertical)."); @@ -1356,6 +1364,15 @@ static struct cmd_results *cmd_splith(int argc, char **argv) { return _do_split(argc, argv, L_HORIZ); } +static struct cmd_results *cmd_splitt(int argc, char **argv) { + swayc_t *focused = get_focused_container(&root_container); + if (focused->parent->layout == L_VERT) { + return _do_split(argc, argv, L_HORIZ); + } else { + return _do_split(argc, argv, L_VERT); + } +} + static struct cmd_results *cmd_sticky(int argc, char **argv) { struct cmd_results *error = NULL; if (config->reading) return cmd_results_new(CMD_FAILURE, "sticky", "Can't be used in config file."); @@ -1567,6 +1584,7 @@ static struct cmd_handler handlers[] = { { "set", cmd_set }, { "split", cmd_split }, { "splith", cmd_splith }, + { "splitt", cmd_splitt }, { "splitv", cmd_splitv }, { "sticky", cmd_sticky }, { "workspace", cmd_workspace }, -- cgit v1.2.3