From 505fc2aac6144291e4a43873282456979db4bb62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 17 Feb 2016 13:16:45 +0100 Subject: vis-lua: expose win.syntax --- vis-lua.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'vis-lua.c') diff --git a/vis-lua.c b/vis-lua.c index 7f45932..b6b4668 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -421,6 +421,15 @@ static int window_index(lua_State *L) { obj_ref_new(L, win->view, "vis.window.cursor"); return 1; } + + if (strcmp(key, "syntax") == 0) { + const char *syntax = view_syntax_get(win->view); + if (syntax) + lua_pushstring(L, syntax); + else + lua_pushnil(L); + return 1; + } } return index_common(L); @@ -430,6 +439,14 @@ static int window_newindex(lua_State *L) { Win *win = obj_ref_check(L, 1, "vis.window"); if (!win) return 0; + if (lua_isstring(L, 2)) { + const char *key = lua_tostring(L, 2); + if (strcmp(key, "syntax") == 0) { + const char *syntax = luaL_checkstring(L, 3); + view_syntax_set(win->view, syntax); + return 0; + } + } return newindex_common(L); } -- cgit v1.2.3