diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-11-07 16:07:35 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-11-08 13:37:24 +0100 |
| commit | c407d30856f3a4af800cc2dd2f319be903381705 (patch) | |
| tree | 2df05eca422299018eb30e016d43f3c76d4c563f /view.c | |
| parent | 96e0a52358247aa99242b786cd88bd310d1c5311 (diff) | |
| download | vis-c407d30856f3a4af800cc2dd2f319be903381705.tar.gz vis-c407d30856f3a4af800cc2dd2f319be903381705.tar.xz | |
vis: introduce vis namespace for lua objects
For now the vis table has only one member "lexers".
Diffstat (limited to 'view.c')
| -rw-r--r-- | view.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -456,7 +456,8 @@ void view_update(View *view) { lua_State *L = view->lua; if (L && view->lexer_name) { - lua_getglobal(L, "lexers"); + lua_getglobal(L, "vis"); + lua_getfield(L, -1, "lexers"); lua_getfield(L, -1, "load"); lua_pushstring(L, view->lexer_name); lua_pcall(L, 1, 1, 0); @@ -898,11 +899,12 @@ bool view_syntax_set(View *view, const char *name) { /* Try to load the specified lexer and parse its token styles. * Roughly equivalent to the following lua code: * - * lang = lexers.load(name) + * lang = vis.lexers.load(name) * for token_name, id in pairs(lang._TOKENSTYLES) do - * ui->syntax_style(id, lexers:get_style(lang, token_name); + * ui->syntax_style(id, vis.lexers:get_style(lang, token_name); */ - lua_getglobal(L, "lexers"); + lua_getglobal(L, "vis"); + lua_getfield(L, -1, "lexers"); lua_getfield(L, -1, "STYLE_DEFAULT"); view->ui->syntax_style(view->ui, UI_STYLE_DEFAULT, lua_tostring(L, -1)); @@ -923,7 +925,6 @@ bool view_syntax_set(View *view, const char *name) { view->ui->syntax_style(view->ui, UI_STYLE_COLOR_COLUMN, lua_tostring(L, -1)); lua_pop(L, 1); - lua_getfield(L, -1, "load"); lua_pushstring(L, name); @@ -956,10 +957,7 @@ bool view_syntax_set(View *view, const char *name) { lua_pop(L, 1); /* style */ } - lua_pop(L, 1); /* _TOKENSTYLES */ - lua_pop(L, 1); /* grammar */ - - lua_pop(L, 1); /* lexers */ + lua_pop(L, 4); /* _TOKENSTYLES, grammar, lexers, vis */ return true; } |
