aboutsummaryrefslogtreecommitdiff
path: root/core/events.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-06-11 18:51:16 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2010-06-11 18:51:16 -0400
commit8e66381a040f695f4203b28bc3f1d6818d0da7a2 (patch)
treee30e8115d27b423b579e60178f36a151dc795f50 /core/events.lua
parent7a4800f05f26067a1cef77e5431256aab4c3d675 (diff)
downloadtextadept-8e66381a040f695f4203b28bc3f1d6818d0da7a2.tar.gz
textadept-8e66381a040f695f4203b28bc3f1d6818d0da7a2.zip
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.
Diffstat (limited to 'core/events.lua')
-rw-r--r--core/events.lua51
1 files changed, 24 insertions, 27 deletions
diff --git a/core/events.lua b/core/events.lua
index 900ccbb3..d80857f6 100644
--- a/core/events.lua
+++ b/core/events.lua
@@ -1,6 +1,5 @@
-- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE.
-local textadept = _G.textadept
local locale = _G.locale
---
@@ -93,11 +92,9 @@ module('events', package.seeall)
-- * **view\_after\_switch** ()<br />
-- Called right after [view][view] was switched to.
-- * **reset\_before()**<br />
--- Called before resetting the Lua state during a call to
--- [`textadept.reset()`][textadept_reset].
+-- Called before resetting the Lua state during a call to [`reset()`][reset].
-- * **reset\_after()**<br />
--- Called after resetting the Lua state during a call to
--- [`textadept.reset()`][textadept_reset].
+-- Called after resetting the Lua state during a call to [`reset()`][reset].
-- * **quit** ()<br />
-- Called when quitting Textadept.<br />
-- Note: Any quit handlers added must be inserted at index 1 because the
@@ -114,7 +111,7 @@ module('events', package.seeall)
-- * **menu\_clicked** (menu\_id)<br />
-- Called when a menu item is selected.
-- - menu\_id: the numeric ID of the menu item set in
--- [`textadept.gtkmenu()`][textadept_gtkmenu].
+-- [`gui.gtkmenu()`][gui_gtkmenu].
-- * **find** (text, next)<br />
-- Called when attempting to finding text via the Find dialog box.
-- - text: the text to search for.
@@ -132,15 +129,15 @@ module('events', package.seeall)
--
-- [buffer]: ../modules/buffer.html
-- [view]: ../modules/view.html
--- [textadept_reset]: ../modules/textadept.html#reset
--- [textadept_gtkmenu]: ../modules/textadept.html#gtkmenu
+-- [reset]: ../modules/_G.html#reset
+-- [gui_gtkmenu]: ../modules/gui.html#gtkmenu
--
-- ## Example
--
-- The following Lua code generates and handles a custom `my_event` event:
--
-- function my_event_handler(message)
--- textadept.print(message)
+-- gui.print(message)
-- end
--
-- events.connect('my_event', my_event_handler)
@@ -187,7 +184,7 @@ local connect = connect
local emit = emit
--- Map of Scintilla notifications to their handlers.
-local c = textadept.constants
+local c = _SCINTILLA.constants
local scnnotifications = {
[c.SCN_CHARADDED] = { 'char_added', 'ch' },
[c.SCN_SAVEPOINTREACHED] = { 'save_point_reached' },
@@ -219,7 +216,7 @@ end
connect('view_new',
function() -- sets default properties for a Scintilla window
local buffer = buffer
- local c = textadept.constants
+ local c = _SCINTILLA.constants
-- lexer
buffer.style_bits = 8
@@ -260,7 +257,7 @@ connect('buffer_new',
buffer:set_lexer_language('container')
-- buffer
- buffer.code_page = textadept.constants.SC_CP_UTF8
+ buffer.code_page = _SCINTILLA.constants.SC_CP_UTF8
if _THEME and #_THEME > 0 then
local ret, errmsg = pcall(dofile, _THEME..'/buffer.lua')
@@ -282,7 +279,7 @@ local function set_title(buffer)
local buffer = buffer
local filename = buffer.filename or buffer._type or locale.UNTITLED
local dirty = buffer.dirty and '*' or '-'
- textadept.title =
+ gui.title =
string.format('%s %s Textadept (%s)', filename:match('[^/\\]+$'), dirty,
filename)
end
@@ -308,7 +305,7 @@ connect('uri_dropped',
utf8_uri = utf8_uri:gsub('%%(%x%x)',
function(hex) return string.char(tonumber(hex, 16)) end)
if WIN32 then utf8_uri = utf8_uri:sub(2, -1) end -- ignore leading '/'
- local uri = textadept.iconv(utf8_uri, _CHARSET, 'UTF-8')
+ local uri = utf8_uri:iconv(_CHARSET, 'UTF-8')
if lfs.attributes(uri).mode ~= 'directory' then
io.open_file(utf8_uri)
end
@@ -332,7 +329,7 @@ connect('update_ui',
local tabs = (buffer.use_tabs and locale.STATUS_TABS or
locale.STATUS_SPACES)..buffer.indent
local enc = buffer.encoding or ''
- textadept.docstatusbar_text =
+ gui.docstatusbar_text =
locale.DOCSTATUSBAR_TEXT:format(line, max, col, lexer, eol, tabs, enc)
end)
@@ -355,7 +352,7 @@ connect('buffer_before_switch',
buffer._folds = {}
local folds = buffer._folds
local level, expanded = buffer.fold_level, buffer.fold_expanded
- local header_flag = textadept.constants.SC_FOLDLEVELHEADERFLAG
+ local header_flag = _SCINTILLA.constants.SC_FOLDLEVELHEADERFLAG
local test = 2 * header_flag
for i = 0, buffer.line_count do
if level[i] % test >= header_flag and not expanded[i] then
@@ -393,21 +390,21 @@ connect('quit',
function() -- prompts for confirmation if any buffers are dirty
local any = false
local list = {}
- for _, buffer in ipairs(textadept.buffers) do
+ for _, buffer in ipairs(_BUFFERS) do
if buffer.dirty then
list[#list + 1] = buffer.filename or buffer._type or locale.UNTITLED
any = true
end
end
if any and
- textadept.dialog('msgbox',
- '--title', locale.EVENTS_QUIT_TITLE,
- '--text', locale.EVENTS_QUIT_TEXT,
- '--informative-text',
- string.format('%s', table.concat(list, '\n')),
- '--button1', 'gtk-cancel',
- '--button2', locale.EVENTS_QUIT_BUTTON2,
- '--no-newline') ~= '2' then
+ gui.dialog('msgbox',
+ '--title', locale.EVENTS_QUIT_TITLE,
+ '--text', locale.EVENTS_QUIT_TEXT,
+ '--informative-text',
+ string.format('%s', table.concat(list, '\n')),
+ '--button1', 'gtk-cancel',
+ '--button2', locale.EVENTS_QUIT_BUTTON2,
+ '--no-newline') ~= '2' then
return false
end
return true
@@ -420,10 +417,10 @@ if MAC then
connect('buffer_new',
function()
buffer.paste = function()
- local clipboard_text = textadept.clipboard_text
+ local clipboard_text = gui.clipboard_text
if #clipboard_text > 0 then buffer:replace_sel(clipboard_text) end
end
end)
end
-connect('error', function(...) textadept._print(locale.ERROR_BUFFER, ...) end)
+connect('error', function(...) gui._print(locale.ERROR_BUFFER, ...) end)