From 243fb87c27ffb4f8301fb63d7f0b7d17e61f83df Mon Sep 17 00:00:00 2001 From: sewn Date: Thu, 1 Feb 2024 18:43:30 +0300 Subject: [PATCH] allow disabling of statusbar --- sam.c | 6 ++++++ vis-cmds.c | 2 ++ vis-lua.c | 10 ++++++++++ 3 files changed, 18 insertions(+) diff --git a/sam.c b/sam.c index 686fa1e3a..5f9e8f9c5 100644 --- a/sam.c +++ b/sam.c @@ -292,6 +292,7 @@ enum { OPTION_SHOW_TABS, OPTION_SHOW_NEWLINES, OPTION_SHOW_EOF, + OPTION_STATUSBAR, OPTION_NUMBER, OPTION_NUMBER_RELATIVE, OPTION_CURSOR_LINE, @@ -359,6 +360,11 @@ static const OptionDef options[] = { NULL, "show-eof" }, + [OPTION_STATUSBAR] = { + { "statusbar", "sb" }, + VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW, + VIS_HELP("Display status bar") + }, [OPTION_NUMBER] = { { "numbers", "nu" }, VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW, diff --git a/vis-cmds.c b/vis-cmds.c index 9e4ed21b6..05b18a5bb 100644 --- a/vis-cmds.c +++ b/vis-cmds.c @@ -267,12 +267,14 @@ static bool cmd_set(Vis *vis, Win *win, Command *cmd, const char *argv[], Select case OPTION_SHOW_TABS: case OPTION_SHOW_NEWLINES: case OPTION_SHOW_EOF: + case OPTION_STATUSBAR: { const int values[] = { [OPTION_SHOW_SPACES] = UI_OPTION_SYMBOL_SPACE, [OPTION_SHOW_TABS] = UI_OPTION_SYMBOL_TAB|UI_OPTION_SYMBOL_TAB_FILL, [OPTION_SHOW_NEWLINES] = UI_OPTION_SYMBOL_EOL, [OPTION_SHOW_EOF] = UI_OPTION_SYMBOL_EOF, + [OPTION_STATUSBAR] = UI_OPTION_STATUSBAR, }; int flags = view_options_get(win->view); if (arg.b || (toggle && !(flags & values[opt_index]))) diff --git a/vis-lua.c b/vis-lua.c index 7c5da2a2e..98a524993 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -1960,6 +1960,12 @@ static int window_options_assign(Win *win, lua_State *L, const char *key, int ne else flags &= ~UI_OPTION_SYMBOL_TAB; view_options_set(win->view, flags); + } else if (strcmp(key, "statusbar") == 0) { + if (lua_toboolean(L, next)) + flags |= UI_OPTION_STATUSBAR; + else + flags &= ~UI_OPTION_STATUSBAR; + view_options_set(win->view, flags); } else if (strcmp(key, "wrapcolumn") == 0 || strcmp(key, "wc") == 0) { view_wrapcolumn_set(win->view, luaL_checkint(L, next)); } else if (strcmp(key, "tabwidth") == 0 || strcmp(key, "tw") == 0) { @@ -2175,6 +2181,7 @@ static const struct luaL_Reg window_funcs[] = { * @tfield[opt=false] boolean shownewlines * @tfield[opt=false] boolean showspaces * @tfield[opt=false] boolean showtabs + * @tfield[opt=true] boolean statusbar * @tfield[opt=8] int tabwidth {tw} * @tfield[opt=0] int wrapcolumn {wc} * @see Vis.options @@ -2216,6 +2223,9 @@ static int window_options_index(lua_State *L) { } else if (strcmp(key, "showtabs") == 0) { lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_SYMBOL_TAB); return 1; + } else if (strcmp(key, "statusbar") == 0) { + lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_STATUSBAR); + return 1; } else if (strcmp(key, "tabwidth") == 0 || strcmp(key, "tw") == 0) { lua_pushinteger(L, view_tabwidth_get(win->view)); return 1;