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
This commit is contained in:
crondog 2015-12-30 18:34:58 +11:00
parent b5a21a08c7
commit 397b58e88f
2 changed files with 24 additions and 2 deletions

View file

@ -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 },

View file

@ -163,8 +163,9 @@ Commands
Creates a substitution for _value_ that can be used with $_name_ in other
commands.
**split** <vertical|v|horizontal|h>::
Splits the current container, vertically or horizontally.
**split** <vertical|v|horizontal|h|toggle|t>::
Splits the current container, vertically or horizontally. If toggled then the
current container is split opposite to the parent container.
**splith**::
Equivalent to **split horizontal**.
@ -172,6 +173,9 @@ Commands
**splitv**::
Equivalent to **split vertical**.
**splitt**::
Equivalent to **split toggle**.
**sticky** <enable|disable|toggle>::
If enabled and the windows is floating it will always be present on the active
workspace on that output.