aboutsummaryrefslogtreecommitdiffhomepage
path: root/core/ext
diff options
context:
space:
mode:
Diffstat (limited to 'core/ext')
-rw-r--r--core/ext/command_entry.lua9
-rw-r--r--core/ext/find.lua59
-rw-r--r--core/ext/key_commands.lua85
-rw-r--r--core/ext/menu.lua81
4 files changed, 114 insertions, 120 deletions
diff --git a/core/ext/command_entry.lua b/core/ext/command_entry.lua
index c29a2180..296244f4 100644
--- a/core/ext/command_entry.lua
+++ b/core/ext/command_entry.lua
@@ -1,19 +1,18 @@
-- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE.
-local textadept = _G.textadept
local locale = _G.locale
events.connect('command_entry_command',
function(command) -- execute a Lua command
local f, err = loadstring(command)
if err then error(err) end
- textadept.command_entry.focus() -- toggle focus to hide
+ gui.command_entry.focus() -- toggle focus to hide
f()
end)
events.connect('command_entry_keypress',
function(code)
- local ce = textadept.command_entry
+ local ce = gui.command_entry
local KEYSYMS = keys.KEYSYMS
if KEYSYMS[code] == 'esc' then
ce.focus() -- toggle focus to hide
@@ -32,11 +31,11 @@ events.connect('command_entry_keypress',
end
if path == 'buffer' then
if o == ':' then
- for f in pairs(textadept.buffer_functions) do
+ for f in pairs(_SCINTILLA.functions) do
if f:find('^'..prefix) then cmpls[#cmpls + 1] = f end
end
else
- for p in pairs(textadept.buffer_properties) do
+ for p in pairs(_SCINTILLA.properties) do
if p:find('^'..prefix) then cmpls[#cmpls + 1] = p end
end
end
diff --git a/core/ext/find.lua b/core/ext/find.lua
index 9aebaaee..eafef5ed 100644
--- a/core/ext/find.lua
+++ b/core/ext/find.lua
@@ -1,9 +1,8 @@
-- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE.
-local textadept = _G.textadept
local locale = _G.locale
local events = _G.events
-local find = textadept.find
+local find = gui.find
local lfs = require 'lfs'
@@ -41,7 +40,7 @@ local function find_(text, next, flags, nowrap, wrapped)
end
if not flags then
- local find, c = find, textadept.constants
+ local find, c = find, _SCINTILLA.constants
flags = 0
if find.match_case then flags = flags + c.SCFIND_MATCHCASE end
if find.whole_word then flags = flags + c.SCFIND_WHOLEWORD end
@@ -76,19 +75,18 @@ local function find_(text, next, flags, nowrap, wrapped)
else -- find in files
local utf8_dir =
- textadept.dialog('fileselect',
- '--title', locale.FIND_IN_FILES_TITLE,
- '--select-only-directories',
- '--with-directory',
- (buffer.filename or ''):match('^.+[/\\]') or '',
- '--no-newline')
+ gui.dialog('fileselect',
+ '--title', locale.FIND_IN_FILES_TITLE,
+ '--select-only-directories',
+ '--with-directory',
+ (buffer.filename or ''):match('^.+[/\\]') or '',
+ '--no-newline')
if #utf8_dir > 0 then
if not find.lua then text = text:gsub('([().*+?^$%%[%]-])', '%%%1') end
if not find.match_case then text = text:lower() end
if find.whole_word then text = '[^%W_]'..text..'[^%W_]' end
local match_case = find.match_case
local whole_word = find.whole_word
- local iconv = textadept.iconv
local format = string.format
local matches = { 'Find: '..text }
function search_file(file)
@@ -98,7 +96,7 @@ local function find_(text, next, flags, nowrap, wrapped)
if not match_case then optimized_line = line:lower() end
if whole_word then optimized_line = ' '..line..' ' end
if string.find(optimized_line, text) then
- file = iconv(file, 'UTF-8', _CHARSET)
+ file = file:iconv('UTF-8', _CHARSET)
matches[#matches + 1] = format('%s:%s:%s', file, line_num, line)
end
line_num = line_num + 1
@@ -117,15 +115,14 @@ local function find_(text, next, flags, nowrap, wrapped)
end
end
end
- local dir = iconv(utf8_dir, _CHARSET, 'UTF-8')
+ local dir = utf8_dir:iconv(_CHARSET, 'UTF-8')
search_dir(dir)
if #matches == 1 then matches[2] = locale.FIND_NO_RESULTS end
matches[#matches + 1] = ''
if buffer._type ~= locale.FIND_FILES_FOUND_BUFFER then
previous_view = view
end
- textadept._print(locale.FIND_FILES_FOUND_BUFFER,
- table.concat(matches, '\n'))
+ gui._print(locale.FIND_FILES_FOUND_BUFFER, table.concat(matches, '\n'))
end
return
end
@@ -137,16 +134,16 @@ local function find_(text, next, flags, nowrap, wrapped)
else
buffer:goto_pos(buffer.length)
end
- textadept.statusbar_text = locale.FIND_SEARCH_WRAPPED
+ gui.statusbar_text = locale.FIND_SEARCH_WRAPPED
result = find_(text, next, flags, true, true)
if result == -1 then
- textadept.statusbar_text = locale.FIND_NO_RESULTS
+ gui.statusbar_text = locale.FIND_NO_RESULTS
buffer:line_scroll(0, first_visible_line)
buffer:goto_pos(anchor)
end
return result
elseif result ~= -1 and not wrapped then
- textadept.statusbar_text = ''
+ gui.statusbar_text = ''
end
return result
@@ -158,7 +155,7 @@ events.connect('find', find_)
-- Flags other than SCFIND_MATCHCASE are ignored.
-- @param text The text to find.
local function find_incremental(text)
- local c = textadept.constants
+ local c = _SCINTILLA.constants
local flags = find.match_case and c.SCFIND_MATCHCASE or 0
--if find.lua then flags = flags + 8 end
buffer:goto_pos(find.incremental_start or 0)
@@ -169,8 +166,8 @@ end
function find.find_incremental()
find.incremental = true
find.incremental_start = buffer.current_pos
- textadept.command_entry.entry_text = ''
- textadept.command_entry.focus()
+ gui.command_entry.entry_text = ''
+ gui.command_entry.focus()
end
events.connect('command_entry_keypress',
@@ -179,7 +176,7 @@ events.connect('command_entry_keypress',
if code == 0xff1b then -- escape
find.incremental = nil
elseif code < 256 or code == 0xff08 then -- character or backspace
- local text = textadept.command_entry.entry_text
+ local text = gui.command_entry.entry_text
if code == 0xff08 then
find_incremental(text:sub(1, -2))
else
@@ -222,11 +219,11 @@ local function replace(rtext)
function(code)
local ret, val = pcall(loadstring('return '..code))
if not ret then
- textadept.dialog('ok-msgbox',
- '--title', locale.FIND_ERROR_DIALOG_TITLE,
- '--text', locale.FIND_ERROR_DIALOG_TEXT,
- '--informative-text', val:gsub('"', '\\"'),
- '--no-cancel')
+ gui.dialog('ok-msgbox',
+ '--title', locale.FIND_ERROR_DIALOG_TITLE,
+ '--text', locale.FIND_ERROR_DIALOG_TEXT,
+ '--informative-text', val:gsub('"', '\\"'),
+ '--no-cancel')
error()
end
return val
@@ -285,7 +282,7 @@ local function replace_all(ftext, rtext, flags)
buffer:set_sel(anchor, current_pos)
buffer:marker_delete_handle(end_marker)
end
- textadept.statusbar_text =
+ gui.statusbar_text =
string.format(locale.FIND_REPLACEMENTS_MADE, tostring(count))
buffer:end_undo_action()
end
@@ -304,7 +301,7 @@ local function goto_file(pos, line_num)
buffer:marker_set_back(MARK_FIND, MARK_FIND_COLOR)
buffer:marker_add(line_num, MARK_FIND)
buffer:goto_pos(buffer.current_pos)
- if #textadept.views == 1 then
+ if #_VIEWS == 1 then
_, previous_view = view:split(false) -- horizontal
else
local clicked_view = view
@@ -312,7 +309,7 @@ local function goto_file(pos, line_num)
if buffer._type == locale.FIND_FILES_FOUND_BUFFER then
-- there are at least two find in files views; find one of those views
-- that the file was not selected from and focus it
- for _, v in ipairs(textadept.views) do
+ for _, v in ipairs(_VIEWS) do
if v ~= clicked_view then
previous_view = v
v:focus()
@@ -332,9 +329,9 @@ events.connect('double_click', goto_file)
-- LuaDoc is in core/.find.lua.
function find.goto_file_in_list(next)
local orig_view = view
- for _, buffer in ipairs(textadept.buffers) do
+ for _, buffer in ipairs(_BUFFERS) do
if buffer._type == locale.FIND_FILES_FOUND_BUFFER then
- for _, view in ipairs(textadept.views) do
+ for _, view in ipairs(_VIEWS) do
if view.doc_pointer == buffer.doc_pointer then
view:focus()
local orig_line = buffer:line_from_position(buffer.current_pos)
diff --git a/core/ext/key_commands.lua b/core/ext/key_commands.lua
index 93f02713..310db7aa 100644
--- a/core/ext/key_commands.lua
+++ b/core/ext/key_commands.lua
@@ -1,6 +1,5 @@
-- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE.
-local textadept = _G.textadept
local locale = _G.locale
local events = _G.events
@@ -34,11 +33,11 @@ module('keys', package.seeall)
-- -- pressing control, shift, alt and 'a' yields: 'Ctrl+Shift+Alt+A'
--
-- For key values less than 255, Lua's [`string.char()`][string_char] is used to
--- determine the key's string representation. Otherwise, the `KEYSYMS` lookup
--- table in [`textadept.keys`][textadept_keys] is used.
+-- determine the key's string representation. Otherwise, the
+-- [`KEYSYMS`][keysyms] lookup table is used.
--
-- [string_char]: http://www.lua.org/manual/5.1/manual.html#pdf-string.char
--- [textadept_keys]: ../modules/textadept.keys.html
+-- [keysyms]: ../modules/keys.html#KEYSYMS
--
-- An action table is a table consisting of either:
--
@@ -127,7 +126,7 @@ local ALT = 'a'..ADD
local keys = keys
local b, v = 'buffer', 'view'
-local t = textadept
+local gui = gui
-- CTRL = 'c'
-- SHIFT = 's'
@@ -154,16 +153,16 @@ if not MAC then
-- File
local m_session = _m.textadept.session
- keys.cn = { t.new_buffer }
- keys.co = { io.open_file }
+ keys.cn = { new_buffer }
+ keys.co = { io.open_file }
-- TODO: { 'reload', b }
- keys.cs = { 'save', b }
- keys.cS = { 'save_as', b }
- keys.cw = { 'close', b }
+ keys.cs = { 'save', b }
+ keys.cS = { 'save_as', b }
+ keys.cw = { 'close', b }
keys.cW = { io.close_all }
-- TODO: { m_session.load } after prompting with open dialog
-- TODO: { m_session.save } after prompting with save dialog
- keys.aq = { t.quit }
+ keys.aq = { quit }
-- Edit
local m_editing = _m.textadept.editing
@@ -211,19 +210,19 @@ if not MAC then
}
-- Search
- keys.cf = { t.find.focus } -- find/replace
- keys['f3'] = { t.find.find_next }
+ keys.cf = { gui.find.focus } -- find/replace
+ keys['f3'] = { gui.find.find_next }
-- Find Next is an when find pane is focused.
-- Find Prev is ap when find pane is focused.
-- Replace is ar when find pane is focused.
- keys.cF = { t.find.find_incremental }
+ keys.cF = { gui.find.find_incremental }
-- Find in Files is ai when find pane is focused.
- -- TODO: { t.find.goto_file_in_list, true }
- -- TODO: { t.find.goto_file_in_list, false }
+ -- TODO: { gui.find.goto_file_in_list, true }
+ -- TODO: { gui.find.goto_file_in_list, false }
keys.cg = { m_editing.goto_line }
-- Tools
- keys['f2'] = { t.command_entry.focus }
+ keys['f2'] = { gui.command_entry.focus }
-- Run
local m_run = _m.textadept.run
keys.cr = { m_run.run }
@@ -237,7 +236,7 @@ if not MAC then
keys.ai = { m_snippets.show_style }
-- Buffers
- keys.cb = { t.switch_buffer }
+ keys.cb = { gui.switch_buffer }
keys['c\t'] = { 'goto_buffer', v, 1, false }
keys['cs\t'] = { 'goto_buffer', v, -1, false }
local function toggle_setting(setting)
@@ -261,8 +260,8 @@ if not MAC then
-- Views
keys.cav = {
- n = { t.goto_view, 1, false },
- p = { t.goto_view, -1, false },
+ n = { gui.goto_view, 1, false },
+ p = { gui.goto_view, -1, false },
S = { 'split', v }, -- vertical
s = { 'split', v, false }, -- horizontal
w = { function() view:unsplit() return true end },
@@ -311,16 +310,16 @@ else
-- File
local m_session = _m.textadept.session
- keys.an = { t.new_buffer }
- keys.ao = { io.open_file }
+ keys.an = { new_buffer }
+ keys.ao = { io.open_file }
-- TODO: { 'reload', b }
- keys.as = { 'save', b }
- keys.aS = { 'save_as', b }
- keys.aw = { 'close', b }
+ keys.as = { 'save', b }
+ keys.aS = { 'save_as', b }
+ keys.aw = { 'close', b }
keys.aW = { io.close_all }
-- TODO: { m_session.load } after prompting with open dialog
-- TODO: { m_session.save } after prompting with save dialog
- keys.aq = { t.quit }
+ keys.aq = { quit }
-- Edit
local m_editing = _m.textadept.editing
@@ -369,23 +368,23 @@ else
}
-- Search
- keys.af = { t.find.focus } -- find/replace
- keys.ag = { t.find.find_next }
- keys.aG = { t.find.find_prev }
- keys.ar = { t.find.replace }
- keys.ai = { t.find.find_incremental }
+ keys.af = { gui.find.focus } -- find/replace
+ keys.ag = { gui.find.find_next }
+ keys.aG = { gui.find.find_prev }
+ keys.ar = { gui.find.replace }
+ keys.ai = { gui.find.find_incremental }
keys.aF = {
function()
- t.find.in_files = true
- t.find.focus()
+ gui.find.in_files = true
+ gui.find.focus()
end
}
- keys.cag = { t.find.goto_file_in_list, true }
- keys.caG = { t.find.goto_file_in_list, false }
+ keys.cag = { gui.find.goto_file_in_list, true }
+ keys.caG = { gui.find.goto_file_in_list, false }
keys.cg = { m_editing.goto_line }
-- Tools
- keys['f2'] = { t.command_entry.focus }
+ keys['f2'] = { gui.command_entry.focus }
-- Run
local m_run = _m.textadept.run
keys.cr = { m_run.run }
@@ -399,7 +398,7 @@ else
keys.ci = { m_snippets.show_style }
-- Buffers
- keys.ab = { t.switch_buffer }
+ keys.ab = { gui.switch_buffer }
keys['c\t'] = { 'goto_buffer', v, 1, false }
keys['cs\t'] = { 'goto_buffer', v, -1, false }
local function toggle_setting(setting)
@@ -423,8 +422,8 @@ else
-- Views
keys.cv = {
- n = { t.goto_view, 1, false },
- p = { t.goto_view, -1, false },
+ n = { gui.goto_view, 1, false },
+ p = { gui.goto_view, -1, false },
S = { 'split', v }, -- vertical
s = { 'split', v, false }, -- horizontal
w = { function() view:unsplit() return true end },
@@ -478,7 +477,7 @@ else
keys.cad = { 'del_word_right', b }
end
-textadept.user_dofile('key_commands.lua') -- load user key commands
+user_dofile('key_commands.lua') -- load user key commands
-- Do not edit below this line.
@@ -526,7 +525,7 @@ local keychain = {}
-- Clears the current key sequence.
local function clear_key_sequence()
keychain = {}
- textadept.statusbar_text = ''
+ gui.statusbar_text = ''
end
-- Helper function that gets commands associated with the current keychain from
@@ -537,7 +536,7 @@ end
local function try_get_cmd(active_table)
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, ' ')
+ gui.statusbar_text = locale.KEYCHAIN..table.concat(keychain, ' ')
error(-1, 0)
else
local func = active_table[1]
@@ -642,7 +641,7 @@ local function keypress(code, shift, control, alt)
local size = #keychain - 1
clear_key_sequence()
if size > 0 then -- previously in a chain
- textadept.statusbar_text = locale.KEYS_INVALID
+ gui.statusbar_text = locale.KEYS_INVALID
return true
end
else
diff --git a/core/ext/menu.lua b/core/ext/menu.lua
index ee60bc60..60e5679c 100644
--- a/core/ext/menu.lua
+++ b/core/ext/menu.lua
@@ -1,17 +1,16 @@
-- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE.
-local textadept = _G.textadept
local locale = _G.locale
local events = _G.events
---
-- Provides dynamic menus for Textadept.
-- This module, like ext/key_commands, should be 'require'ed last.
-module('textadept.menu', package.seeall)
+module('menu', package.seeall)
-local t = textadept
+local gui = gui
local l = locale
-local gtkmenu = textadept.gtkmenu
+local gtkmenu = gui.gtkmenu
local SEPARATOR = 'separator'
local ID = {
@@ -282,7 +281,7 @@ for _, lexer in ipairs(_m.textadept.mime_types.lexers) do
lexer_menu[#lexer_menu + 1] = { lexer, ID.LEXER_START + #lexer_menu }
end
table.insert(menubar, #menubar, gtkmenu(lexer_menu)) -- before 'Help'
-t.menubar = menubar
+gui.menubar = menubar
local b, v = 'buffer', 'view'
local m_snippets = _m.textadept.snippets
@@ -327,7 +326,7 @@ end
local actions = {
-- File
- [ID.NEW] = { t.new_buffer },
+ [ID.NEW] = { new_buffer },
[ID.OPEN] = { io.open_file },
[ID.RELOAD] = { 'reload', b },
[ID.SAVE] = { 'save', b },
@@ -337,34 +336,34 @@ local actions = {
[ID.LOAD_SESSION] = {
function()
local utf8_filename =
- t.dialog('fileselect',
- '--title', l.MENU_LOAD_SESSION_TITLE,
- '--with-directory',
- (textadept.session_file or ''):match('.+[/\\]') or '',
- '--with-file',
- (textadept.session_file or ''):match('[^/\\]+$') or '',
- '--no-newline')
+ gui.dialog('fileselect',
+ '--title', l.MENU_LOAD_SESSION_TITLE,
+ '--with-directory',
+ (_SESSIONFILE or ''):match('.+[/\\]') or '',
+ '--with-file',
+ (_SESSIONFILE or ''):match('[^/\\]+$') or '',
+ '--no-newline')
if #utf8_filename > 0 then
- _m.textadept.session.load(t.iconv(utf8_filename, _CHARSET, 'UTF-8'))
+ _m.textadept.session.load(utf8_filename:iconv(_CHARSET, 'UTF-8'))
end
end
},
[ID.SAVE_SESSION] = {
function()
local utf8_filename =
- t.dialog('filesave',
- '--title', l.MENU_SAVE_SESSION_TITLE,
- '--with-directory',
- (textadept.session_file or ''):match('.+[/\\]') or '',
- '--with-file',
- (textadept.session_file or ''):match('[^/\\]+$') or '',
- '--no-newline')
+ gui.dialog('filesave',
+ '--title', l.MENU_SAVE_SESSION_TITLE,
+ '--with-directory',
+ (_SESSIONFILE or ''):match('.+[/\\]') or '',
+ '--with-file',
+ (_SESSIONFILE or ''):match('[^/\\]+$') or '',
+ '--no-newline')
if #utf8_filename > 0 then
- _m.textadept.session.save(t.iconv(utf8_filename, _CHARSET, 'UTF-8'))
+ _m.textadept.session.save(utf8_filename:iconv(_CHARSET, 'UTF-8'))
end
end
},
- [ID.QUIT] = { t.quit },
+ [ID.QUIT] = { quit },
-- Edit
[ID.UNDO] = { 'undo', b },
[ID.REDO] = { 'redo', b },
@@ -405,23 +404,23 @@ local actions = {
[ID.SELECT_IN_INDENTED_BLOCK] = { m_editing.select_indented_block },
[ID.SELECT_IN_SCOPE] = { m_editing.select_scope },
-- Tools
- [ID.FIND] = { t.find.focus },
- [ID.FIND_NEXT] = { t.find.call_find_next },
- [ID.FIND_PREV] = { t.find.call_find_prev },
- [ID.FIND_AND_REPLACE] = { t.find.focus },
- [ID.REPLACE] = { t.find.call_replace },
- [ID.REPLACE_ALL] = { t.find.call_replace_all },
- [ID.FIND_INCREMENTAL] = { t.find.find_incremental },
+ [ID.FIND] = { gui.find.focus },
+ [ID.FIND_NEXT] = { gui.find.call_find_next },
+ [ID.FIND_PREV] = { gui.find.call_find_prev },
+ [ID.FIND_AND_REPLACE] = { gui.find.focus },
+ [ID.REPLACE] = { gui.find.call_replace },
+ [ID.REPLACE_ALL] = { gui.find.call_replace_all },
+ [ID.FIND_INCREMENTAL] = { gui.find.find_incremental },
[ID.FIND_IN_FILES] = {
function()
- t.find.in_files = true
- t.find.focus()
+ gui.find.in_files = true
+ gui.find.focus()
end
},
- [ID.GOTO_NEXT_FILE_FOUND] = { t.find.goto_file_in_list, true },
- [ID.GOTO_PREV_FILE_FOUND] = { t.find.goto_file_in_list, false },
+ [ID.GOTO_NEXT_FILE_FOUND] = { gui.find.goto_file_in_list, true },
+ [ID.GOTO_PREV_FILE_FOUND] = { gui.find.goto_file_in_list, false },
[ID.GOTO_LINE] = { m_editing.goto_line },
- [ID.FOCUS_COMMAND_ENTRY] = { t.command_entry.focus },
+ [ID.FOCUS_COMMAND_ENTRY] = { gui.command_entry.focus },
[ID.RUN] = { m_run.run },
[ID.COMPILE] = { m_run.compile },
-- Tools -> Snippets
@@ -452,10 +451,10 @@ local actions = {
[ID.ENCODING_MACROMAN] = { set_encoding, 'MacRoman' },
[ID.ENCODING_UTF16] = { set_encoding, 'UTF-16LE' },
[ID.REFRESH_SYNTAX_HIGHLIGHTING] = { 'colourise', b, 0, -1 },
- [ID.SWITCH_BUFFER] = { t.switch_buffer },
+ [ID.SWITCH_BUFFER] = { gui.switch_buffer },
-- View
- [ID.NEXT_VIEW] = { t.goto_view, 1, false },
- [ID.PREV_VIEW] = { t.goto_view, -1, false },
+ [ID.NEXT_VIEW] = { gui.goto_view, 1, false },
+ [ID.PREV_VIEW] = { gui.goto_view, -1, false },
[ID.SPLIT_VIEW_VERTICAL] = { 'split', v },
[ID.SPLIT_VIEW_HORIZONTAL] = { 'split', v, false },
[ID.UNSPLIT_VIEW] = { function() view:unsplit() end },
@@ -470,8 +469,8 @@ local actions = {
[ID.MANUAL] = { open_webpage, _HOME..'/doc/manual/1_Introduction.html' },
[ID.LUADOC] = { open_webpage, _HOME..'/doc/index.html' },
[ID.ABOUT] = {
- t.dialog, 'ok-msgbox', '--title', 'Textadept', '--informative-text',
- _RELEASE, '--no-cancel'
+ gui.dialog, 'ok-msgbox', '--title', 'Textadept', '--informative-text',
+ _RELEASE, '--no-cancel'
},
}
@@ -506,7 +505,7 @@ events.connect('menu_clicked',
end)
-- Right-click context menu.
-t.context_menu = gtkmenu {
+gui.context_menu = gtkmenu {
{ l.MENU_EDIT_UNDO, ID.UNDO },
{ l.MENU_EDIT_REDO, ID.REDO },
{ SEPARATOR, ID.SEPARATOR },