From 8e66381a040f695f4203b28bc3f1d6818d0da7a2 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Fri, 11 Jun 2010 18:51:16 -0400 Subject: Removed _G.textadept. Created new _SCINTILLA core module. Renamed textadept.constants to _SCINTILLA.constants Renamed textadept.buffer_functions to _SCINTILLA.functions Renamed textadept.buffer_properties to _SCINTILLA.properties Created new gui core module. Renamed textadept._print() to gui._print(). Renamed textadept.check_focused_buffer() to gui.check_focused_buffer(). Renamed textadept.clipboard_text to gui.clipboard_text. Renamed textadept.context_menu to gui.context_menu Renamed textadept.command_entry to gui.command_entry. Renamed textadept.dialog to gui.dialog. Renamed textadept.docstatusbar_text to gui.docstatusbar_text. Renamed textadept.find to gui.find. Renamed textadept.focused_doc_pointer to gui.focused_doc_pointer. Renamed textadept.get_split_table() to gui.get_split_table(). Renamed textadept.gtkmenu() to gui.gtkmenu(). Renamed textadept.goto_view() to gui.goto_view(). Renamed textadept.menubar to gui.menubar. Renamed textadept.print() to gui.print(). Renamed textadept.size to gui.size. Renamed textadept.statusbar_text to gui.statusbar_text. Renamed textadept.switch_buffer() to gui.switch_buffer(). Renamed textadept.title to gui.title. Renamed textadept.buffers to _G._BUFFERS. Renamed textadept.new_buffer() to _G.new_buffer(). Renamed textadept.quit() to _G.quit(). Renamed textadept.reset() to _G.reset(). Renamed textadept.views to _G._VIEWS. Renamed textadept.user_dofile() to _G.user_dofile(). Renamed textadept.iconv to string.iconv. Renamed textadept.session_file to _SESSIONFILE. Renamed appropriate C functions. --- core/init.lua | 78 +++-------------------------------------------------------- 1 file changed, 4 insertions(+), 74 deletions(-) (limited to 'core/init.lua') diff --git a/core/init.lua b/core/init.lua index fcf8e354..39497614 100644 --- a/core/init.lua +++ b/core/init.lua @@ -2,8 +2,6 @@ _RELEASE = "Textadept 2.2" -local textadept = _G.textadept - package.path = _HOME..'/core/?.lua;'..package.path _USERHOME = os.getenv(not WIN32 and 'HOME' or 'USERPROFILE')..'/.textadept' @@ -29,83 +27,15 @@ require 'iface' require 'locale' require 'events' require 'file_io' +require 'gui' rawset = nil -- do not allow modifications which could compromise stability --- LuaDoc is in core/.textadept.lua. -function textadept.check_focused_buffer(buffer) - if type(buffer) ~= 'table' or not buffer.doc_pointer then - error(locale.ERR_BUFFER_EXPECTED, 2) - elseif textadept.focused_doc_pointer ~= buffer.doc_pointer then - error(locale.ERR_BUFFER_NOT_FOCUSED, 2) - end -end - --- LuaDoc is in core/.textadept.lua. -function textadept._print(buffer_type, ...) - local function safe_print(...) - local message = table.concat({...}, '\t') - local message_buffer, message_buffer_index - local message_view, message_view_index - for index, buffer in ipairs(textadept.buffers) do - if buffer._type == buffer_type then - message_buffer, message_buffer_index = buffer, index - for jndex, view in ipairs(textadept.views) do - if view.doc_pointer == message_buffer.doc_pointer then - message_view, message_view_index = view, jndex - break - end - end - break - end - end - if not message_view then - local _, message_view = view:split(false) -- horizontal split - if not message_buffer then - message_buffer = textadept.new_buffer() - message_buffer._type = buffer_type - events.emit('file_opened') - else - message_view:goto_buffer(message_buffer_index, true) - end - else - textadept.goto_view(message_view_index, true) - end - message_buffer:append_text(message..'\n') - message_buffer:set_save_point() - end - pcall(safe_print, ...) -- prevent endless loops if this errors -end - --- LuaDoc is in core/.textadept.lua. -function textadept.print(...) textadept._print(locale.MESSAGE_BUFFER, ...) end - --- LuaDoc is in core/.textadept.lua. -function textadept.switch_buffer() - local items = {} - for _, buffer in ipairs(textadept.buffers) do - local filename = buffer.filename or buffer._type or locale.UNTITLED - local dirty = buffer.dirty and '*' or '' - items[#items + 1] = dirty..filename:match('[^/\\]+$') - items[#items + 1] = filename - end - local out = - textadept.dialog('filteredlist', - '--title', locale.SWITCH_BUFFERS, - '--button1', 'gtk-ok', - '--button2', 'gtk-cancel', - '--no-newline', - '--columns', 'Name', 'File', - '--items', unpack(items)) - local i = tonumber(out:match('%-?%d+$')) - if i and i >= 0 then view:goto_buffer(i + 1, true) end -end - --- LuaDoc is in core/.textadept.lua. -function textadept.user_dofile(filename) +-- LuaDoc is in core/._G.lua. +function _G.user_dofile(filename) if lfs.attributes(_USERHOME..'/'..filename) then local ret, errmsg = pcall(dofile, _USERHOME..'/'..filename) - if not ret then textadept.print(errmsg) end + if not ret then gui.print(errmsg) end return ret end return false -- cgit v1.2.3