diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-02-17 13:16:45 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-02-18 16:50:39 +0100 |
| commit | 505fc2aac6144291e4a43873282456979db4bb62 (patch) | |
| tree | 7494a53fa88e4bf10174dfddfe21f556186f668f /vis-lua.c | |
| parent | f74ecd62c2c7c0dc2755272c23a3e2c50cecfcab (diff) | |
| download | vis-505fc2aac6144291e4a43873282456979db4bb62.tar.gz vis-505fc2aac6144291e4a43873282456979db4bb62.tar.xz | |
vis-lua: expose win.syntax
Diffstat (limited to 'vis-lua.c')
| -rw-r--r-- | vis-lua.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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); } |
