aboutsummaryrefslogtreecommitdiff
path: root/core/ext
diff options
context:
space:
mode:
Diffstat (limited to 'core/ext')
-rw-r--r--core/ext/command_entry.lua6
-rw-r--r--core/ext/find.lua15
-rw-r--r--core/ext/key_commands.lua13
-rw-r--r--core/ext/menu.lua11
4 files changed, 24 insertions, 21 deletions
diff --git a/core/ext/command_entry.lua b/core/ext/command_entry.lua
index 34dfbe13..c29a2180 100644
--- a/core/ext/command_entry.lua
+++ b/core/ext/command_entry.lua
@@ -3,7 +3,7 @@
local textadept = _G.textadept
local locale = _G.locale
-textadept.events.add_handler('command_entry_command',
+events.connect('command_entry_command',
function(command) -- execute a Lua command
local f, err = loadstring(command)
if err then error(err) end
@@ -11,10 +11,10 @@ textadept.events.add_handler('command_entry_command',
f()
end)
-textadept.events.add_handler('command_entry_keypress',
+events.connect('command_entry_keypress',
function(code)
local ce = textadept.command_entry
- local KEYSYMS = textadept.keys.KEYSYMS
+ local KEYSYMS = keys.KEYSYMS
if KEYSYMS[code] == 'esc' then
ce.focus() -- toggle focus to hide
return true
diff --git a/core/ext/find.lua b/core/ext/find.lua
index f8cf27c8..9aebaaee 100644
--- a/core/ext/find.lua
+++ b/core/ext/find.lua
@@ -2,6 +2,7 @@
local textadept = _G.textadept
local locale = _G.locale
+local events = _G.events
local find = textadept.find
local lfs = require 'lfs'
@@ -150,7 +151,7 @@ local function find_(text, next, flags, nowrap, wrapped)
return result
end
-textadept.events.add_handler('find', find_)
+events.connect('find', find_)
-- Finds and selects text incrementally in the current buffer from a start
-- point.
@@ -172,7 +173,7 @@ function find.find_incremental()
textadept.command_entry.focus()
end
-textadept.events.add_handler('command_entry_keypress',
+events.connect('command_entry_keypress',
function(code)
if find.incremental then
if code == 0xff1b then -- escape
@@ -188,7 +189,7 @@ textadept.events.add_handler('command_entry_keypress',
end
end, 1) -- place before command_entry.lua's handler (if necessary)
-textadept.events.add_handler('command_entry_command',
+events.connect('command_entry_command',
function(text) -- 'find next' for incremental search
if find.incremental then
find.incremental_start = buffer.current_pos + 1
@@ -240,7 +241,7 @@ local function replace(rtext)
buffer:goto_pos(buffer.current_pos)
end
end
-textadept.events.add_handler('replace', replace)
+events.connect('replace', replace)
-- Replaces all found text.
-- If any text is selected, all found text in that selection is replaced.
@@ -288,7 +289,7 @@ local function replace_all(ftext, rtext, flags)
string.format(locale.FIND_REPLACEMENTS_MADE, tostring(count))
buffer:end_undo_action()
end
-textadept.events.add_handler('replace_all', replace_all)
+events.connect('replace_all', replace_all)
-- When the user double-clicks a found file, go to the line in the file the text
-- was found at.
@@ -326,7 +327,7 @@ local function goto_file(pos, line_num)
end
end
end
-textadept.events.add_handler('double_click', goto_file)
+events.connect('double_click', goto_file)
-- LuaDoc is in core/.find.lua.
function find.goto_file_in_list(next)
@@ -359,5 +360,5 @@ function find.goto_file_in_list(next)
end
if buffer then buffer:marker_set_back(MARK_FIND, MARK_FIND_COLOR) end
-textadept.events.add_handler('view_new',
+events.connect('view_new',
function() buffer:marker_set_back(MARK_FIND, MARK_FIND_COLOR) end)
diff --git a/core/ext/key_commands.lua b/core/ext/key_commands.lua
index 297cb3a8..93f02713 100644
--- a/core/ext/key_commands.lua
+++ b/core/ext/key_commands.lua
@@ -2,6 +2,7 @@
local textadept = _G.textadept
local locale = _G.locale
+local events = _G.events
---
-- Manages and defines key commands in Textadept.
@@ -246,7 +247,7 @@ if not MAC then
elseif type(state) == 'number' then
buffer[setting] = buffer[setting] == 0 and 1 or 0
end
- t.events.handle('update_ui') -- for updating statusbar
+ events.emit('update_ui') -- for updating statusbar
end
keys.ct.v = {
e = { toggle_setting, 'view_eol' },
@@ -274,7 +275,7 @@ if not MAC then
-- Miscellaneous not in standard menu.
-- Recent files.
local RECENT_FILES = 1
- t.events.add_handler('user_list_selection',
+ events.connect('user_list_selection',
function(type, text)
if type == RECENT_FILES then io.open_file(text) end
end)
@@ -408,7 +409,7 @@ else
elseif type(state) == 'number' then
buffer[setting] = buffer[setting] == 0 and 1 or 0
end
- t.events.handle('update_ui') -- for updating statusbar
+ events.emit('update_ui') -- for updating statusbar
end
keys.at.v = {
e = { toggle_setting, 'view_eol' },
@@ -436,7 +437,7 @@ else
-- Miscellaneous not in standard menu.
-- Recent files.
local RECENT_FILES = 1
- t.events.add_handler('user_list_selection',
+ events.connect('user_list_selection',
function(type, text)
if type == RECENT_FILES then io.open_file(text) end
end)
@@ -589,7 +590,7 @@ local function keypress(code, shift, control, alt)
if ch:find('[%p%d]') and #keychain == 0 then
if buffer.anchor ~= buffer.current_pos then buffer:delete_back() end
buffer:add_text(ch)
- textadept.events.handle('char_added', code)
+ events.emit('char_added', code)
return true
end
end
@@ -649,4 +650,4 @@ local function keypress(code, shift, control, alt)
end
end
end
-textadept.events.add_handler('keypress', keypress, 1)
+events.connect('keypress', keypress, 1)
diff --git a/core/ext/menu.lua b/core/ext/menu.lua
index 7fede4da..ee60bc60 100644
--- a/core/ext/menu.lua
+++ b/core/ext/menu.lua
@@ -2,6 +2,7 @@
local textadept = _G.textadept
local locale = _G.locale
+local events = _G.events
---
-- Provides dynamic menus for Textadept.
@@ -291,7 +292,7 @@ local m_run = _m.textadept.run
local function set_encoding(encoding)
buffer:set_encoding(encoding)
- t.events.handle('update_ui') -- for updating statusbar
+ events.emit('update_ui') -- for updating statusbar
end
local function toggle_setting(setting)
local state = buffer[setting]
@@ -300,17 +301,17 @@ local function toggle_setting(setting)
elseif type(state) == 'number' then
buffer[setting] = buffer[setting] == 0 and 1 or 0
end
- t.events.handle('update_ui') -- for updating statusbar
+ events.emit('update_ui') -- for updating statusbar
end
local function set_eol_mode(mode)
buffer.eol_mode = mode
buffer:convert_eo_ls(mode)
- t.events.handle('update_ui') -- for updating statusbar
+ events.emit('update_ui') -- for updating statusbar
end
local function set_lexer(lexer)
buffer:set_lexer(lexer)
buffer:colourise(0, -1)
- t.events.handle('update_ui') -- for updating statusbar
+ events.emit('update_ui') -- for updating statusbar
end
local function open_webpage(url)
local cmd
@@ -475,7 +476,7 @@ local actions = {
}
-- Most of this handling code comes from keys.lua.
-t.events.add_handler('menu_clicked',
+events.connect('menu_clicked',
function(menu_id)
local active_table = actions[menu_id]
if menu_id >= ID.LEXER_START and menu_id < ID.LEXER_START + 99 then