diff options
Diffstat (limited to 'core/ext')
-rw-r--r-- | core/ext/command_entry.lua | 2 | ||||
-rw-r--r-- | core/ext/find.lua | 4 | ||||
-rw-r--r-- | core/ext/key_commands.lua | 9 | ||||
-rw-r--r-- | core/ext/key_commands_mac.lua | 9 | ||||
-rw-r--r-- | core/ext/key_commands_std.lua | 9 | ||||
-rw-r--r-- | core/ext/keys.lua | 35 | ||||
-rw-r--r-- | core/ext/menu.lua | 6 | ||||
-rw-r--r-- | core/ext/mime_types.lua | 11 | ||||
-rw-r--r-- | core/ext/pm/buffer_browser.lua | 13 | ||||
-rw-r--r-- | core/ext/pm/ctags_browser.lua | 11 | ||||
-rw-r--r-- | core/ext/pm/file_browser.lua | 2 | ||||
-rw-r--r-- | core/ext/pm/find_browser.lua | 2 | ||||
-rw-r--r-- | core/ext/pm/macro_browser.lua | 9 | ||||
-rw-r--r-- | core/ext/pm/modules_browser.lua | 3 | ||||
-rw-r--r-- | core/ext/pm/project_browser.lua | 2 |
15 files changed, 74 insertions, 53 deletions
diff --git a/core/ext/command_entry.lua b/core/ext/command_entry.lua index f1bd1820..29e38bb6 100644 --- a/core/ext/command_entry.lua +++ b/core/ext/command_entry.lua @@ -1,5 +1,6 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept local ce = textadept.command_entry --- @@ -8,7 +9,6 @@ local ce = textadept.command_entry -- @param command The command to complete. -- @return sorted table of completions function ce.get_completions_for(command) - local textadept = textadept local substring = command:match('[%w_.:]+$') or '' local path, o, prefix = substring:match('^([%w_.:]-)([.:]?)([%w_]*)$') local ret, tbl = pcall(loadstring('return ('..path..')')) diff --git a/core/ext/find.lua b/core/ext/find.lua index 5def64e8..e036934f 100644 --- a/core/ext/find.lua +++ b/core/ext/find.lua @@ -1,5 +1,6 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept local find = textadept.find --- @@ -25,7 +26,7 @@ local escapes = { -- for displaying useful statusbar information. This flag is used and set -- internally, and should not be set otherwise. function find.find(text, next, flags, nowrap, wrapped) - local buffer, textadept = buffer, textadept + local buffer = buffer local increment, result text = text:gsub('\\[abfnrtv\\]', escapes) find.captures = nil @@ -135,7 +136,6 @@ end -- @param flags The number mask identical to the one in 'find'. -- @see find.find function find.replace_all(ftext, rtext, flags) - local textadept = textadept buffer:goto_pos(0) local count = 0 while(find.find(ftext, true, flags, true)) do diff --git a/core/ext/key_commands.lua b/core/ext/key_commands.lua index 6e3f0145..25c7c239 100644 --- a/core/ext/key_commands.lua +++ b/core/ext/key_commands.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Defines the key commands used by the Textadept key command manager. -- For non-ascii keys, see textadept.keys for string aliases. @@ -14,12 +16,7 @@ module('textadept.key_commands', package.seeall) CSA: C D G H J K L O Q R S T U W X Z ]]-- ---- --- Global container that holds all key commands. --- @class table --- @name keys -_G.keys = {} -local keys = keys +local keys = _G.keys keys.clear_sequence = 'esc' diff --git a/core/ext/key_commands_mac.lua b/core/ext/key_commands_mac.lua index 11378804..2e8e82b2 100644 --- a/core/ext/key_commands_mac.lua +++ b/core/ext/key_commands_mac.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Defines the key commands used by the Textadept key command manager. -- For non-ascii keys, see textadept.keys for string aliases. @@ -15,12 +17,7 @@ module('textadept.key_commands_mac', package.seeall) CSA: A C D E G H J K L M N O P Q R S T U V W X Y Z ]]-- ---- --- Global container that holds all key commands. --- @class table --- @name keys -_G.keys = {} -local keys = keys +local keys = _G.keys keys.clear_sequence = 'aesc' diff --git a/core/ext/key_commands_std.lua b/core/ext/key_commands_std.lua index 499305f6..2d7688d8 100644 --- a/core/ext/key_commands_std.lua +++ b/core/ext/key_commands_std.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Defines the key commands used by the Textadept key command manager. -- For non-ascii keys, see textadept.keys for string aliases. @@ -15,12 +17,7 @@ module('textadept.key_commands_std', package.seeall) CSA: A B C D E F G H J K L M N O P Q R S T U V W X Y Z ]]-- ---- --- Global container that holds all key commands. --- @class table --- @name keys -_G.keys = {} -local keys = keys +local keys = _G.keys keys.clear_sequence = 'esc' diff --git a/core/ext/keys.lua b/core/ext/keys.lua index 818479a9..466a74c2 100644 --- a/core/ext/keys.lua +++ b/core/ext/keys.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Manages key commands in Textadept. -- Default key commands should be defined in a separate file and loaded after @@ -76,6 +78,23 @@ local ALT = 'a'..ADD -- end options --- +-- Global container that holds all key commands. +-- @class table +-- @name keys +_G.keys = {} + +-- optimize for speed +local keys = _G.keys +local string = _G.string +local string_char = string.char +local string_format = string.format +local pcall = _G.pcall +local ipairs = _G.ipairs +local next = _G.next +local type = _G.type +local unpack = _G.unpack + +--- -- [Local table] Lookup table for key values higher than 255. -- If a key value given to 'keypress' is higher than 255, this table is used to -- return a string representation of the key if it exists. @@ -124,15 +143,13 @@ end -- @return whatever the executed command returns, true by default. A true -- return value will tell Textadept not to handle the key afterwords. local function keypress(code, shift, control, alt) - local buffer, textadept = buffer, textadept - local string, pcall = string, pcall - local keys = _G.keys + local buffer = buffer local key --print(code, string.char(code)) if code < 256 then - key = string.char(code):lower() + key = string_char(code):lower() if MAC and not shift and not control and not alt then - local ch = string.char(code) + local ch = string_char(code) -- work around native GTK-OSX's handling of Alt key if ch:match('[^A-Za-z ]') and #keychain == 0 then buffer:add_text(ch) @@ -147,7 +164,7 @@ local function keypress(code, shift, control, alt) control = control and CTRL or '' shift = shift and SHIFT or '' alt = alt and ALT or '' - local key_seq = string.format('%s%s%s%s', control, shift, alt, key) + local key_seq = string_format('%s%s%s%s', control, shift, alt, key) if #keychain > 0 and key_seq == keys.clear_sequence then clear_key_sequence() @@ -224,10 +241,10 @@ end -- of -1. This way, pcall will return false and -1, where the -1 can easily and -- efficiently be checked rather than using a string error message. try_get_cmd = function(active_table) - local locale = textadept.locale for _, key_seq in ipairs(keychain) do active_table = active_table[key_seq] end if #active_table == 0 and next(active_table) then - textadept.statusbar_text = locale.KEYCHAIN..table.concat(keychain, ' ') + textadept.statusbar_text = + textadept.locale.KEYCHAIN..table.concat(keychain, ' ') error(-1, 0) else local func = active_table[1] @@ -241,7 +258,7 @@ try_get_cmd = function(active_table) return view[func], { view, unpack(active_table, 3) } end else - error(locale.KEYS_UNKNOWN_COMMAND..tostring(func)) + error(textadept.locale.KEYS_UNKNOWN_COMMAND..tostring(func)) end end end diff --git a/core/ext/menu.lua b/core/ext/menu.lua index e7f57d5a..3398f47e 100644 --- a/core/ext/menu.lua +++ b/core/ext/menu.lua @@ -1,11 +1,15 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Provides dynamic menus for Textadept. -- This module, like ext/key_commands, should be 'require'ed last. module('textadept.menu', package.seeall) -local t, gtkmenu, l = textadept, textadept.gtkmenu, textadept.locale +local t = textadept +local l = textadept.locale +local gtkmenu = textadept.gtkmenu local SEPARATOR = 'separator' local ID = { diff --git a/core/ext/mime_types.lua b/core/ext/mime_types.lua index 6d4ec37a..8ee41c7c 100644 --- a/core/ext/mime_types.lua +++ b/core/ext/mime_types.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- Handles file-specific settings (based on file extension). module('textadept.mime_types', package.seeall) @@ -334,8 +336,7 @@ local function handle_switch() end end -local events = textadept.events -events.add_handler('file_opened', handle_new) -events.add_handler('file_saved_as', handle_new) -events.add_handler('buffer_switch', handle_switch) -events.add_handler('view_new', handle_switch) +textadept.events.add_handler('file_opened', handle_new) +textadept.events.add_handler('file_saved_as', handle_new) +textadept.events.add_handler('buffer_switch', handle_switch) +textadept.events.add_handler('view_new', handle_switch) diff --git a/core/ext/pm/buffer_browser.lua b/core/ext/pm/buffer_browser.lua index 73b09d55..83bb26f9 100644 --- a/core/ext/pm/buffer_browser.lua +++ b/core/ext/pm/buffer_browser.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Buffer browser for the Textadept project manager. -- It is enabled with the prefix 'buffers' in the project manager entry field. @@ -62,12 +64,11 @@ function perform_menu_action(menu_item, menu_id, selected_item) textadept.pm.activate() end -local add_handler = textadept.events.add_handler local function update_view() if matches(textadept.pm.entry_text) then textadept.pm.activate() end end -add_handler('file_opened', update_view) -add_handler('buffer_new', update_view) -add_handler('buffer_deleted', update_view) -add_handler('save_point_reached', update_view) -add_handler('save_point_left', update_view) +textadept.events.add_handler('file_opened', update_view) +textadept.events.add_handler('buffer_new', update_view) +textadept.events.add_handler('buffer_deleted', update_view) +textadept.events.add_handler('save_point_reached', update_view) +textadept.events.add_handler('save_point_left', update_view) diff --git a/core/ext/pm/ctags_browser.lua b/core/ext/pm/ctags_browser.lua index e1b4586d..8f112470 100644 --- a/core/ext/pm/ctags_browser.lua +++ b/core/ext/pm/ctags_browser.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- CTags Browser for the Textadept project manager. -- It is enabled with the prefix 'ctags' in the project manager entry field @@ -234,7 +236,6 @@ function perform_menu_action(menu_item, menu_id, selected_item) end -local add_handler = textadept.events.add_handler local function update_view() if matches(textadept.pm.entry_text) then if buffer.filename then @@ -244,7 +245,7 @@ local function update_view() end end end -add_handler('file_opened', update_view) -add_handler('buffer_deleted', update_view) -add_handler('buffer_switch', update_view) -add_handler('save_point_reached', update_view) +textadept.events.add_handler('file_opened', update_view) +textadept.events.add_handler('buffer_deleted', update_view) +textadept.events.add_handler('buffer_switch', update_view) +textadept.events.add_handler('save_point_reached', update_view) diff --git a/core/ext/pm/file_browser.lua b/core/ext/pm/file_browser.lua index c658b6c0..87d4b8e6 100644 --- a/core/ext/pm/file_browser.lua +++ b/core/ext/pm/file_browser.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- File browser for the Textadept project manager. -- It is enabled by providing the absolute path to a directory in the project diff --git a/core/ext/pm/find_browser.lua b/core/ext/pm/find_browser.lua index a8722e78..c79ab167 100644 --- a/core/ext/pm/find_browser.lua +++ b/core/ext/pm/find_browser.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Find in files browser for the Textadept project manager. -- It is enabled with the prefix 'find' in the project manager entry field. diff --git a/core/ext/pm/macro_browser.lua b/core/ext/pm/macro_browser.lua index c2892fa7..051487cf 100644 --- a/core/ext/pm/macro_browser.lua +++ b/core/ext/pm/macro_browser.lua @@ -1,12 +1,12 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Macro browser for the Textadept project manager. -- It is enabled with the prefix 'macros' in the project manager entry field. module('textadept.pm.browsers.macro', package.seeall) -local textadept = textadept - function matches(entry_text) return entry_text:sub(1, 7) == 'macros' end @@ -38,9 +38,8 @@ function perform_menu_action(menu_item, menu_id, selected_item) textadept.pm.activate() end -local add_handler = textadept.events.add_handler local function update_view() if matches(textadept.pm.entry_text) then textadept.pm.activate() end end -add_handler('macro_saved', update_view) -add_handler('macro_deleted', update_view) +textadept.events.add_handler('macro_saved', update_view) +textadept.events.add_handler('macro_deleted', update_view) diff --git a/core/ext/pm/modules_browser.lua b/core/ext/pm/modules_browser.lua index 4fc97206..757e7d93 100644 --- a/core/ext/pm/modules_browser.lua +++ b/core/ext/pm/modules_browser.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Modules browser for the Textadept project manager. -- It is enabled with the prefix 'modules' in the project manager entry field. @@ -182,7 +184,6 @@ function perform_menu_action(menu_item, menu_id, selected_item) elseif menu_id == ID.CONF_MIME_TYPES then textadept.io.open(_HOME..'/core/ext/mime_types.lua') elseif menu_id == ID.CONF_KEY_COMMANDS then - local textadept = textadept if textadept.key_commands then textadept.io.open(_HOME..'/core/ext/key_commands.lua') elseif textadept.key_commands_std then diff --git a/core/ext/pm/project_browser.lua b/core/ext/pm/project_browser.lua index 30c6a847..0219839e 100644 --- a/core/ext/pm/project_browser.lua +++ b/core/ext/pm/project_browser.lua @@ -1,5 +1,7 @@ -- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. +local textadept = _G.textadept + --- -- Browser template for the Textadept project manager. -- It is enabled with the prefix 'project' in the project manager entry field. |