vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 4b89fa7a7b9644e40ef923a55be04d0eaf40f007 parent ac93226239954cd5332e266abd354b471f33d432 Author: Marc André Tanner <mat@brain-dump.org> Date: Sun, 22 May 2016 11:52:59 +0200 vis-lua: fall back to C status bar handling if the Lua implementation is not available Diffstat:
| M | vis-lua.c | | | 37 | ++++++++++++++++++++----------------- |
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/vis-lua.c b/vis-lua.c @@ -16,23 +16,7 @@ #define VIS_PATH "/usr/local/share/vis" #endif -#if !CONFIG_LUA - -bool vis_lua_path_add(Vis *vis, const char *path) { return true; } -const char *vis_lua_paths_get(Vis *vis) { return NULL; } -void vis_lua_init(Vis *vis) { } -void vis_lua_start(Vis *vis) { } -void vis_lua_quit(Vis *vis) { } -void vis_lua_file_open(Vis *vis, File *file) { } -void vis_lua_file_save(Vis *vis, File *file) { } -void vis_lua_file_close(Vis *vis, File *file) { } -void vis_lua_win_open(Vis *vis, Win *win) { } -void vis_lua_win_close(Vis *vis, Win *win) { } -void vis_lua_win_highlight(Vis *vis, Win *win, size_t horizon) { } -bool vis_lua_win_syntax(Vis *vis, Win *win, const char *syntax) { return true; } -bool vis_theme_load(Vis *vis, const char *name) { return true; } - -void vis_lua_win_status(Vis *vis, Win *win) { +static void window_status_update(Vis *vis, Win *win) { char status[1024], left[256], right[256], cursors[32] = "", pos[32] = ""; int width = vis_window_width_get(win); int delim_len = 1, delim_count = 0; @@ -74,6 +58,23 @@ void vis_lua_win_status(Vis *vis, Win *win) { vis_window_status(win, status); } +#if !CONFIG_LUA + +bool vis_lua_path_add(Vis *vis, const char *path) { return true; } +const char *vis_lua_paths_get(Vis *vis) { return NULL; } +void vis_lua_init(Vis *vis) { } +void vis_lua_start(Vis *vis) { } +void vis_lua_quit(Vis *vis) { } +void vis_lua_file_open(Vis *vis, File *file) { } +void vis_lua_file_save(Vis *vis, File *file) { } +void vis_lua_file_close(Vis *vis, File *file) { } +void vis_lua_win_open(Vis *vis, Win *win) { } +void vis_lua_win_close(Vis *vis, Win *win) { } +void vis_lua_win_highlight(Vis *vis, Win *win, size_t horizon) { } +bool vis_lua_win_syntax(Vis *vis, Win *win, const char *syntax) { return true; } +bool vis_theme_load(Vis *vis, const char *name) { return true; } +void vis_lua_win_status(Vis *vis, Win *win) { window_status_update(vis, win); } + #else #if 0 @@ -1384,6 +1385,8 @@ void vis_lua_win_status(Vis *vis, Win *win) { if (lua_isfunction(L, -1)) { obj_ref_new(L, win, "vis.window"); pcall(vis, L, 1, 0); + } else { + window_status_update(vis, win); } lua_pop(L, 1); }