vis

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

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

commit daf14b90fe85e9f7c5faf56d62214ba6cfbfd045
parent 1508ee3ff3ea09b06eb6a3027abeae34aaa11fe5
Author: Jul <jul@9o.is>
Date:   Mon, 26 Jan 2026 10:45:56 -0500

allow lua scripts to show or hide cursor

Diffstat:
Mui-terminal-curses.c | 4++++
Mui-terminal.c | 4++++
Mui.h | 1+
Mvis-lua.c | 8++++++++
4 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/ui-terminal-curses.c b/ui-terminal-curses.c @@ -291,3 +291,7 @@ static void ui_term_backend_free(Ui *term) { static bool is_default_color(CellColor c) { return c == CELL_COLOR_DEFAULT; } + +static void cursor_visible(bool visible) { + curs_set(visible); +} diff --git a/ui-terminal.c b/ui-terminal.c @@ -125,6 +125,10 @@ static bool color_fromstring(Ui *ui, CellColor *color, const char *s) return false; } +void ui_showcursor(bool show) { + cursor_visible(show); +} + bool ui_style_define(Win *win, int id, const char *style) { Ui *tui = &win->vis->ui; if (id >= UI_STYLE_MAX) diff --git a/ui.h b/ui.h @@ -133,5 +133,6 @@ bool ui_window_style_set_pos(Win *win, int x, int y, enum UiStyle id, bool keep_ void ui_window_options_set(Win *win, enum UiOption options); void ui_window_status(Win *win, const char *status); +void ui_showcursor(bool show); #endif diff --git a/vis-lua.c b/vis-lua.c @@ -1681,9 +1681,17 @@ static int ui_newindex(lua_State *L) { return newindex_common(L); } +static int ui_lua_showcursor(lua_State *L) { + obj_ref_check(L, 1, VIS_LUA_TYPE_UI); + bool show = lua_toboolean(L, 2); + ui_showcursor(show); + return 0; +} + static const struct luaL_Reg ui_funcs[] = { { "__index", ui_index }, { "__newindex", ui_newindex }, + { "showcursor", ui_lua_showcursor }, { NULL, NULL }, };