diff options
author | 2014-01-01 12:28:33 -0500 | |
---|---|---|
committer | 2014-01-01 12:28:33 -0500 | |
commit | ee8e402829b65901351bbbf7417c291da7c3b541 (patch) | |
tree | a87d3008adae84a0e2a0a8ee07b1464aa4a29557 | |
parent | 66bfdfeda14c40f631fe808c0b2d50ee2f14a254 (diff) |
Merge the separate Textadept and lexer Lua states into a single unified one.
This is an experimental change and requires the latest Scintillua changes.
-rw-r--r-- | core/ui.lua | 4 | ||||
-rw-r--r-- | modules/textadept/file_types.lua | 1 | ||||
-rw-r--r-- | src/textadept.c | 10 |
3 files changed, 10 insertions, 5 deletions
diff --git a/core/ui.lua b/core/ui.lua index a4ceeac2..09d273c0 100644 --- a/core/ui.lua +++ b/core/ui.lua @@ -249,6 +249,7 @@ events_connect(events.VIEW_NEW, function() events.emit(events.UPDATE_UI) end) local SETDIRECTFUNCTION = _SCINTILLA.properties.direct_function[1] local SETDIRECTPOINTER = _SCINTILLA.properties.doc_pointer[2] +local SETLUASTATE = _SCINTILLA.functions.change_lexer_state[1] local SETLEXERLANGUAGE = _SCINTILLA.properties.lexer_language[2] -- Sets default properties for a Scintilla document. events_connect(events.BUFFER_NEW, function() @@ -257,6 +258,7 @@ events_connect(events.BUFFER_NEW, function() buffer.lexer_language = 'lpeg' buffer:private_lexer_call(SETDIRECTFUNCTION, buffer.direct_function) buffer:private_lexer_call(SETDIRECTPOINTER, buffer.direct_pointer) + buffer:private_lexer_call(SETLUASTATE, _LUA) buffer.property['lexer.lpeg.home'] = _USERHOME..'/lexers/?.lua;'.. _HOME..'/lexers' load_theme_and_settings() @@ -441,7 +443,7 @@ local goto_view -- Low-level function for creating a menu from table *menu_table* and returning -- the userdata. -- You probably want to use the higher-level `textadept.menu.set_menubar()` --- or `textadept.menu.set_contextmenus()` functions. Emits a `MENU_CLICKED` +-- or `textadept.menu.set_contextmenus()` functions. Emits a `MENU_CLICKED` -- event when a menu item is selected. -- @param menu_table A table defining the menu. It is an ordered list of tables -- with a string menu item, integer menu ID, and optional GDK keycode and diff --git a/modules/textadept/file_types.lua b/modules/textadept/file_types.lua index aa17246e..dfb4ed63 100644 --- a/modules/textadept/file_types.lua +++ b/modules/textadept/file_types.lua @@ -114,6 +114,7 @@ events.connect(events.FILE_SAVED_AS, function() buffer:set_lexer() end) -- Restores the buffer's lexer. local function restore_lexer() buffer:set_lexer(buffer._lexer) end events.connect(events.BUFFER_AFTER_SWITCH, restore_lexer) +events.connect(events.VIEW_AFTER_SWITCH, restore_lexer) events.connect(events.VIEW_NEW, restore_lexer) events.connect(events.RESET_AFTER, restore_lexer) diff --git a/src/textadept.c b/src/textadept.c index 8733b947..0a4157cb 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -793,7 +793,7 @@ static void sync_tabbar() { l_pushdoc(lua, SS(focused_view, SCI_GETDOCPOINTER, 0, 0)); lua_gettable(lua, -2); int i = lua_tointeger(lua, -1) - 1; - lua_pop(lua, 2); // buffers and index + lua_pop(lua, 2); // index and buffers GtkNotebook *tabs = GTK_NOTEBOOK(tabbar); tab_sync = TRUE, gtk_notebook_set_current_page(tabs, i), tab_sync = FALSE; //#elif CURSES @@ -1243,7 +1243,8 @@ static int l_callscintilla(lua_State *L, Scintilla *view, int msg, int wtype, if (msg == SCI_PRIVATELEXERCALL) { ltype = SSTRINGRET; int c = luaL_checklong(L, arg); - if (c == SCI_GETDIRECTFUNCTION || c == SCI_SETDOCPOINTER) + if (c == SCI_GETDIRECTFUNCTION || c == SCI_SETDOCPOINTER || + c == SCI_CHANGELEXERSTATE) ltype = SINT; else if (c == SCI_SETLEXERLANGUAGE) ltype = SSTRING; @@ -1419,7 +1420,7 @@ static void new_buffer(sptr_t doc) { gtk_widget_show(tab), gtk_widget_set_visible(tabbar, show_tabs && i > 0); gtk_notebook_set_current_page(GTK_NOTEBOOK(tabbar), i); tab_sync = FALSE; - lua_pop(lua, 2); // buffer and tab_pointer + lua_pop(lua, 2); // tab_pointer and buffer //#elif CURSES // TODO: tabs #endif @@ -1579,7 +1580,7 @@ static int lL_init(lua_State *L, int argc, char **argv, int reinit) { } else { // clear package.loaded and _G lua_getglobal(L, "package"), lua_getfield(L, -1, "loaded"); lL_cleartable(L, -1); - lua_pop(L, 2); // package and package.loaded + lua_pop(L, 2); // package.loaded and package #if !LUAJIT lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); lL_cleartable(L, -1); @@ -1588,6 +1589,7 @@ static int lL_init(lua_State *L, int argc, char **argv, int reinit) { lL_cleartable(L, LUA_GLOBALSINDEX); #endif } + lua_pushinteger(L, (sptr_t)L), lua_setglobal(L, "_LUA"); luaL_openlibs(L); lL_openlib(L, "lpeg", luaopen_lpeg); lL_openlib(L, "lfs", luaopen_lfs); |