diff options
| -rw-r--r-- | lexers/themes/solarized.lua | 2 | ||||
| -rw-r--r-- | view.c | 16 | ||||
| -rw-r--r-- | vis.c | 8 |
3 files changed, 15 insertions, 11 deletions
diff --git a/lexers/themes/solarized.lua b/lexers/themes/solarized.lua index dee1750..4264f15 100644 --- a/lexers/themes/solarized.lua +++ b/lexers/themes/solarized.lua @@ -1,4 +1,6 @@ -- Solarized color codes Copyright (c) 2011 Ethan Schoonover +local lexers = vis.lexers + local colors = { ['base03'] = '#000000', -- '#002b36', ['base02'] = '#073642', @@ -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; } @@ -132,7 +132,8 @@ void vis_window_name(Win *win, const char *filename) { } if (filename && L) { - lua_getglobal(L, "lexers"); + lua_getglobal(L, "vis"); + lua_getfield(L, -1, "lexers"); lua_getfield(L, -1, "lexer_name"); lua_pushstring(L, filename); lua_pcall(L, 1, 1, 0); @@ -360,7 +361,10 @@ Vis *vis_new(Ui *ui) { lua_close(L); vis->lua = L = NULL; } else { - lua_setglobal(L, "lexers"); + lua_newtable(L); /* vis */ + lua_pushvalue(L, -2); /* require return value */ + lua_setfield(L, -2, "lexers"); + lua_setglobal(L, "vis"); vis_theme_load(vis, "default"); } |
