Skip to content

Commit

Permalink
allow disabling of statusbar
Browse files Browse the repository at this point in the history
apprehensions committed Feb 1, 2024
1 parent 5cd6d03 commit 243fb87
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sam.c
Original file line number Diff line number Diff line change
@@ -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,
2 changes: 2 additions & 0 deletions vis-cmds.c
Original file line number Diff line number Diff line change
@@ -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])))
10 changes: 10 additions & 0 deletions vis-lua.c
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 243fb87

Please sign in to comment.