diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2024-05-23 22:21:40 -0600 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2024-05-24 15:23:41 -0600 |
| commit | 70fa1e8594be04c203179e8249a27ae648a81e71 (patch) | |
| tree | e4160703953dfef02ba74df0f78840088e46c91c /vis-lua.c | |
| parent | 66c7dfeec6367eac5f7b0f9eff451a0577d8eae7 (diff) | |
| download | vis-70fa1e8594be04c203179e8249a27ae648a81e71.tar.gz vis-70fa1e8594be04c203179e8249a27ae648a81e71.tar.xz | |
combine Win and UiWin
These are not seperate things and keeping them this way makes
gives this convoluted mess where both Wins and UiWins must have
linked lists to the other Wins and UiWins in the program despite
the fact that neither of them can exist in isolation.
This, like my previous cleanup commits, is part of a larger goal
of properly isolating the various subsystems in vis. Doing so is
required if we ever want to be able to have a vis-server and a
vis-client.
Diffstat (limited to 'vis-lua.c')
| -rw-r--r-- | vis-lua.c | 48 |
1 files changed, 24 insertions, 24 deletions
@@ -1786,12 +1786,12 @@ static int window_index(lua_State *L) { } if (strcmp(key, "width") == 0) { - lua_pushunsigned(L, win->ui->width); + lua_pushunsigned(L, win->width); return 1; } if (strcmp(key, "height") == 0) { - lua_pushunsigned(L, win->ui->height); + lua_pushunsigned(L, win->height); return 1; } @@ -1825,7 +1825,7 @@ static int window_index(lua_State *L) { } static int window_options_assign(Win *win, lua_State *L, const char *key, int next) { - enum UiOption flags = UI_OPTIONS_GET(win->view.ui); + enum UiOption flags = win->options; if (strcmp(key, "breakat") == 0 || strcmp(key, "brk") == 0) { if (lua_isstring(L, next)) view_breakat_set(&win->view, lua_tostring(L, next)); @@ -1836,49 +1836,49 @@ static int window_options_assign(Win *win, lua_State *L, const char *key, int ne flags |= UI_OPTION_CURSOR_LINE; else flags &= ~UI_OPTION_CURSOR_LINE; - view_options_set(&win->view, flags); + win_options_set(win, flags); } else if (strcmp(key, "numbers") == 0 || strcmp(key, "nu") == 0) { if (lua_toboolean(L, next)) flags |= UI_OPTION_LINE_NUMBERS_ABSOLUTE; else flags &= ~UI_OPTION_LINE_NUMBERS_ABSOLUTE; - view_options_set(&win->view, flags); + win_options_set(win, flags); } else if (strcmp(key, "relativenumbers") == 0 || strcmp(key, "rnu") == 0) { if (lua_toboolean(L, next)) flags |= UI_OPTION_LINE_NUMBERS_RELATIVE; else flags &= ~UI_OPTION_LINE_NUMBERS_RELATIVE; - view_options_set(&win->view, flags); + win_options_set(win, flags); } else if (strcmp(key, "showeof") == 0) { if (lua_toboolean(L, next)) flags |= UI_OPTION_SYMBOL_EOF; else flags &= ~UI_OPTION_SYMBOL_EOF; - view_options_set(&win->view, flags); + win_options_set(win, flags); } else if (strcmp(key, "shownewlines") == 0) { if (lua_toboolean(L, next)) flags |= UI_OPTION_SYMBOL_EOL; else flags &= ~UI_OPTION_SYMBOL_EOL; - view_options_set(&win->view, flags); + win_options_set(win, flags); } else if (strcmp(key, "showspaces") == 0) { if (lua_toboolean(L, next)) flags |= UI_OPTION_SYMBOL_SPACE; else flags &= ~UI_OPTION_SYMBOL_SPACE; - view_options_set(&win->view, flags); + win_options_set(win, flags); } else if (strcmp(key, "showtabs") == 0) { if (lua_toboolean(L, next)) flags |= UI_OPTION_SYMBOL_TAB; else flags &= ~UI_OPTION_SYMBOL_TAB; - view_options_set(&win->view, flags); + win_options_set(win, 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); + win_options_set(win, flags); } else if (strcmp(key, "wrapcolumn") == 0 || strcmp(key, "wc") == 0) { win->view.wrapcolumn = luaL_checkunsigned(L, next); } else if (strcmp(key, "tabwidth") == 0 || strcmp(key, "tw") == 0) { @@ -1986,7 +1986,7 @@ static int window_style_define(lua_State *L) { Win *win = obj_ref_check(L, 1, VIS_LUA_TYPE_WINDOW); enum UiStyle id = luaL_checkunsigned(L, 2); const char *style = luaL_checkstring(L, 3); - bool ret = ui_style_define(win->view.ui, id, style); + bool ret = ui_style_define(win, id, style); lua_pushboolean(L, ret); return 1; } @@ -2008,7 +2008,7 @@ static int window_style(lua_State *L) { enum UiStyle style = luaL_checkunsigned(L, 2); size_t start = checkpos(L, 3); size_t end = checkpos(L, 4); - view_style(&win->view, style, start, end); + win_style(win, style, start, end); return 0; } @@ -2033,7 +2033,7 @@ static int window_style_pos(lua_State *L) { enum UiStyle style = luaL_checkunsigned(L, 2); size_t x = checkpos(L, 3); size_t y = checkpos(L, 4); - bool ret = ui_window_style_set_pos(win->ui, (int)x, (int)y, style); + bool ret = ui_window_style_set_pos(win, (int)x, (int)y, style); lua_pushboolean(L, ret); return 1; } @@ -2048,7 +2048,7 @@ static int window_style_pos(lua_State *L) { static int window_status(lua_State *L) { Win *win = obj_ref_check(L, 1, VIS_LUA_TYPE_WINDOW); char status[1024] = ""; - int width = win->ui->width; + int width = win->width; const char *left = luaL_checkstring(L, 2); const char *right = luaL_optstring(L, 3, ""); int left_width = text_string_width(left, strlen(left)); @@ -2057,7 +2057,7 @@ static int window_status(lua_State *L) { if (spaces < 1) spaces = 1; snprintf(status, sizeof(status)-1, "%s%*s%s", left, spaces, " ", right); - ui_window_status(win->ui, status); + ui_window_status(win, status); return 0; } @@ -2146,31 +2146,31 @@ static int window_options_index(lua_State *L) { lua_pushunsigned(L, win->view.colorcolumn); return 1; } else if (strcmp(key, "cursorline") == 0 || strcmp(key, "cul") == 0) { - lua_pushboolean(L, UI_OPTIONS_GET(win->view.ui) & UI_OPTION_CURSOR_LINE); + lua_pushboolean(L, win->options & UI_OPTION_CURSOR_LINE); return 1; } else if (strcmp(key, "expandtab") == 0 || strcmp(key, "et") == 0) { lua_pushboolean(L, win->expandtab); return 1; } else if (strcmp(key, "numbers") == 0 || strcmp(key, "nu") == 0) { - lua_pushboolean(L, UI_OPTIONS_GET(win->view.ui) & UI_OPTION_LINE_NUMBERS_ABSOLUTE); + lua_pushboolean(L, win->options & UI_OPTION_LINE_NUMBERS_ABSOLUTE); return 1; } else if (strcmp(key, "relativenumbers") == 0 || strcmp(key, "rnu") == 0) { - lua_pushboolean(L, UI_OPTIONS_GET(win->view.ui) & UI_OPTION_LINE_NUMBERS_RELATIVE); + lua_pushboolean(L, win->options & UI_OPTION_LINE_NUMBERS_RELATIVE); return 1; } else if (strcmp(key, "showeof") == 0) { - lua_pushboolean(L, UI_OPTIONS_GET(win->view.ui) & UI_OPTION_SYMBOL_EOF); + lua_pushboolean(L, win->options & UI_OPTION_SYMBOL_EOF); return 1; } else if (strcmp(key, "shownewlines") == 0) { - lua_pushboolean(L, UI_OPTIONS_GET(win->view.ui) & UI_OPTION_SYMBOL_EOL); + lua_pushboolean(L, win->options & UI_OPTION_SYMBOL_EOL); return 1; } else if (strcmp(key, "showspaces") == 0) { - lua_pushboolean(L, UI_OPTIONS_GET(win->view.ui) & UI_OPTION_SYMBOL_SPACE); + lua_pushboolean(L, win->options & UI_OPTION_SYMBOL_SPACE); return 1; } else if (strcmp(key, "showtabs") == 0) { - lua_pushboolean(L, UI_OPTIONS_GET(win->view.ui) & UI_OPTION_SYMBOL_TAB); + lua_pushboolean(L, win->options & UI_OPTION_SYMBOL_TAB); return 1; } else if (strcmp(key, "statusbar") == 0) { - lua_pushboolean(L, UI_OPTIONS_GET(win->view.ui) & UI_OPTION_STATUSBAR); + lua_pushboolean(L, win->options & UI_OPTION_STATUSBAR); return 1; } else if (strcmp(key, "tabwidth") == 0 || strcmp(key, "tw") == 0) { lua_pushinteger(L, win->view.tabwidth); |
