vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 97df0ab3fce49cbbbca9ea8403a97594fbabd314
parent aa26e59b167a9314d387b27cb73565495c3c915b
Author: Karl Schultheisz <kdsch@protonmail.com>
Date:   Thu, 23 May 2019 10:48:36 -0400

Add layout option

This introduces a new `set` option for setting the layout to
vertical or horizontal, which previously could not be done
without creating a new window (via `split` or `vsplit`).
Now, `set layout|lay h|v` will control this without creating
a new window.

Diffstat:
Msam.c | 6++++++
Mvis-cmds.c | 13+++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/sam.c b/sam.c @@ -297,6 +297,7 @@ enum { OPTION_SAVE_METHOD, OPTION_LOAD_METHOD, OPTION_CHANGE_256COLORS, + OPTION_LAYOUT, }; static const OptionDef options[] = { @@ -380,6 +381,11 @@ static const OptionDef options[] = { VIS_OPTION_TYPE_BOOL, VIS_HELP("Change 256 color palette to support 24bit colors") }, + [OPTION_LAYOUT] = { + { "layout", "lay" }, + VIS_OPTION_TYPE_STRING, + VIS_HELP("Vertical or horizontal window layout") + }, }; bool sam_init(Vis *vis) { diff --git a/vis-cmds.c b/vis-cmds.c @@ -348,6 +348,19 @@ static bool cmd_set(Vis *vis, Win *win, Command *cmd, const char *argv[], Select case OPTION_CHANGE_256COLORS: vis->change_colors = toggle ? !vis->change_colors : arg.b; break; + case OPTION_LAYOUT: { + enum UiLayout layout; + if (strcmp("h", arg.s) == 0) { + layout = UI_LAYOUT_HORIZONTAL; + } else if (strcmp("v", arg.s) == 0) { + layout = UI_LAYOUT_VERTICAL; + } else { + vis_info_show(vis, "Invalid layout `%s', expected 'h' or 'v'", arg.s); + return false; + } + windows_arrange(vis, layout); + break; + } default: if (!opt->func) return false;