aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/.textadept.lua4
-rw-r--r--core/events.lua15
-rw-r--r--core/ext/command_entry.lua1
-rw-r--r--core/ext/find.lua7
-rw-r--r--core/ext/key_commands.lua1
-rw-r--r--core/ext/key_commands_mac.lua1
-rw-r--r--core/ext/key_commands_std.lua1
-rw-r--r--core/ext/keys.lua8
-rw-r--r--core/ext/menu.lua3
-rw-r--r--core/ext/mime_types.lua1
-rw-r--r--core/ext/pm/buffer_browser.lua7
-rw-r--r--core/ext/pm/ctags_browser.lua4
-rw-r--r--core/ext/pm/file_browser.lua3
-rw-r--r--core/ext/pm/macro_browser.lua2
-rw-r--r--core/ext/pm/modules_browser.lua3
-rw-r--r--core/ext/pm/project_browser.lua3
-rw-r--r--core/file_io.lua5
-rw-r--r--core/init.lua9
-rw-r--r--core/locale.lua2
19 files changed, 38 insertions, 42 deletions
diff --git a/core/.textadept.lua b/core/.textadept.lua
index d16d61ef..a37a892c 100644
--- a/core/.textadept.lua
+++ b/core/.textadept.lua
@@ -108,8 +108,8 @@ function check_focused_buffer(buffer) end
-- buffer, and prints to it.
-- @param buffer_type String type of message buffer.
-- @param ... Message strings.
--- @usage textadept._print(textadept.locale.ERROR_BUFFER, error_message)
--- @usage textadept._print(textadept.locale.MESSAGE_BUFFER, message)
+-- @usage textadept._print(locale.ERROR_BUFFER, error_message)
+-- @usage textadept._print(locale.MESSAGE_BUFFER, message)
function _print(buffer_type, ...)
---
diff --git a/core/events.lua b/core/events.lua
index 52093fc3..23ce1ae3 100644
--- a/core/events.lua
+++ b/core/events.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- Module that handles Scintilla and Textadept notifications/events.
@@ -359,7 +360,7 @@ local title_text = '%s %s Textadept (%s)'
-- @param buffer The currently focused buffer.
local function set_title(buffer)
local buffer = buffer
- local filename = buffer.filename or buffer._type or textadept.locale.UNTITLED
+ local filename = buffer.filename or buffer._type or locale.UNTITLED
local d = buffer.dirty and '*' or '-'
textadept.title =
string.format(title_text, filename:match('[^/\\]+$'), d, filename)
@@ -393,14 +394,13 @@ add_handler('uri_dropped',
end)
local EOLs = {
- textadept.locale.STATUS_CRLF,
- textadept.locale.STATUS_CR,
- textadept.locale.STATUS_LF
+ locale.STATUS_CRLF,
+ locale.STATUS_CR,
+ locale.STATUS_LF
}
add_handler('update_ui',
function() -- sets docstatusbar text
local buffer = buffer
- local locale = textadept.locale
local pos = buffer.current_pos
local line, max = buffer:line_from_position(pos) + 1, buffer.line_count
local col = buffer.column[pos] + 1
@@ -444,12 +444,11 @@ add_handler('view_switch',
add_handler('quit',
function() -- prompts for confirmation if any buffers are dirty; saves session
- local locale = textadept.locale
local any = false
local list = {}
for _, buffer in ipairs(textadept.buffers) do
if buffer.dirty then
- list[#list + 1] = buffer.filename or locale.UNTITLED
+ list[#list + 1] = buffer.filename or buffer._type or locale.UNTITLED
any = true
end
end
@@ -475,4 +474,4 @@ end
-- Default error handler.
-- Prints the errors to an error buffer.
-- @param ... Error strings.
-function error(...) textadept._print(textadept.locale.ERROR_BUFFER, ...) end
+function error(...) textadept._print(locale.ERROR_BUFFER, ...) end
diff --git a/core/ext/command_entry.lua b/core/ext/command_entry.lua
index c583dc06..890c99e9 100644
--- a/core/ext/command_entry.lua
+++ b/core/ext/command_entry.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
local ce = textadept.command_entry
---
diff --git a/core/ext/find.lua b/core/ext/find.lua
index 566ff0d9..611a73ab 100644
--- a/core/ext/find.lua
+++ b/core/ext/find.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
local find = textadept.find
local MARK_REPLACEALL_END = 0
@@ -33,7 +34,6 @@ local escapes = {
function find.find(text, next, flags, nowrap, wrapped)
if #text == 0 then return end
local buffer = buffer
- local locale = textadept.locale
local first_visible_line = buffer.first_visible_line -- for 'no results found'
local increment
@@ -177,7 +177,6 @@ function find.replace(rtext)
end
local ret, rtext = pcall(rtext.gsub, rtext, '%%(%b())',
function(code)
- local locale = textadept.locale
local ret, val = pcall(loadstring('return '..code))
if not ret then
cocoa_dialog('msgbox', {
@@ -246,7 +245,7 @@ function find.replace_all(ftext, rtext, flags)
buffer:marker_delete_handle(end_marker)
end
textadept.statusbar_text =
- string.format(textadept.locale.FIND_REPLACEMENTS_MADE, tostring(count))
+ string.format(locale.FIND_REPLACEMENTS_MADE, tostring(count))
buffer:end_undo_action()
end
@@ -256,7 +255,7 @@ end
-- @param pos The position of the caret.
-- @param line_num The line double-clicked.
function goto_file(pos, line_num)
- if buffer._type == textadept.locale.FIND_FILES_FOUND_BUFFER then
+ if buffer._type == locale.FIND_FILES_FOUND_BUFFER then
line = buffer:get_line(line_num)
local file, line_num = line:match('^(.+):(%d+):.+$')
if file and line_num then
diff --git a/core/ext/key_commands.lua b/core/ext/key_commands.lua
index 89d7903e..1a378fb6 100644
--- a/core/ext/key_commands.lua
+++ b/core/ext/key_commands.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- Defines the key commands used by the Textadept key command manager.
diff --git a/core/ext/key_commands_mac.lua b/core/ext/key_commands_mac.lua
index 258c91a9..d7357726 100644
--- a/core/ext/key_commands_mac.lua
+++ b/core/ext/key_commands_mac.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- Defines the key commands used by the Textadept key command manager.
diff --git a/core/ext/key_commands_std.lua b/core/ext/key_commands_std.lua
index b6db26b6..04903a57 100644
--- a/core/ext/key_commands_std.lua
+++ b/core/ext/key_commands_std.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- Defines the key commands used by the Textadept key command manager.
diff --git a/core/ext/keys.lua b/core/ext/keys.lua
index 1a276861..08d5c606 100644
--- a/core/ext/keys.lua
+++ b/core/ext/keys.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- Manages key commands in Textadept.
@@ -205,7 +206,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 = textadept.locale.KEYS_INVALID
+ textadept.statusbar_text = locale.KEYS_INVALID
return true
end
else
@@ -243,8 +244,7 @@ end
try_get_cmd = function(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 =
- textadept.locale.KEYCHAIN..table.concat(keychain, ' ')
+ textadept.statusbar_text = locale.KEYCHAIN..table.concat(keychain, ' ')
error(-1, 0)
else
local func = active_table[1]
@@ -258,7 +258,7 @@ try_get_cmd = function(active_table)
return view[func], { view, unpack(active_table, 3) }
end
else
- error(textadept.locale.KEYS_UNKNOWN_COMMAND..tostring(func))
+ error(locale.KEYS_UNKNOWN_COMMAND..tostring(func))
end
end
end
diff --git a/core/ext/menu.lua b/core/ext/menu.lua
index 9032c4b6..1a2b06ed 100644
--- a/core/ext/menu.lua
+++ b/core/ext/menu.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- Provides dynamic menus for Textadept.
@@ -8,7 +9,7 @@ local textadept = _G.textadept
module('textadept.menu', package.seeall)
local t = textadept
-local l = textadept.locale
+local l = locale
local gtkmenu = textadept.gtkmenu
local SEPARATOR = 'separator'
diff --git a/core/ext/mime_types.lua b/core/ext/mime_types.lua
index b35ee151..e4960e41 100644
--- a/core/ext/mime_types.lua
+++ b/core/ext/mime_types.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
--- Handles file-specific settings (based on file extension).
module('textadept.mime_types', package.seeall)
diff --git a/core/ext/pm/buffer_browser.lua b/core/ext/pm/buffer_browser.lua
index 0bac4818..e33c15aa 100644
--- a/core/ext/pm/buffer_browser.lua
+++ b/core/ext/pm/buffer_browser.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- Buffer browser for the Textadept project manager.
@@ -16,12 +17,11 @@ end
function get_contents_for()
local contents = {}
for index, buffer in ipairs(textadept.buffers) do
- local filename =
- buffer.filename or buffer._type or textadept.locale.UNTITLED
index = string.format("%02i", index)
contents[index] = {
pixbuf = buffer.dirty and 'gtk-edit' or 'gtk-file',
- text = filename:match('[^/\\]+$')
+ text =
+ (buffer.filename or buffer._type or locale.UNTITLED):match('[^/\\]+$')
}
end
return contents
@@ -39,7 +39,6 @@ end
local ID = { NEW = 1, OPEN = 2, SAVE = 3, SAVEAS = 4, CLOSE = 5 }
function get_context_menu(selected_item)
- local locale = textadept.locale
return {
{ locale.PM_BROWSER_BUFFER_NEW, ID.NEW },
{ locale.PM_BROWSER_BUFFER_OPEN, ID.OPEN },
diff --git a/core/ext/pm/ctags_browser.lua b/core/ext/pm/ctags_browser.lua
index 3a4ce826..7039d1c4 100644
--- a/core/ext/pm/ctags_browser.lua
+++ b/core/ext/pm/ctags_browser.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- CTags Browser for the Textadept project manager.
@@ -110,7 +111,6 @@ end
-- of the parent being expanded.
function get_contents_for(full_path, expanding)
local ctags_file = full_path[1]:sub(7) -- ignore 'ctags:'
- local locale = textadept.locale
local f
if #ctags_file == 0 then
tags = {}
@@ -221,7 +221,7 @@ function perform_action(selected_item)
buffer:goto_line(line)
else
error(
- string.format(textadept.locale.PM_BROWSER_CTAGS_NOT_FOUND, item.text))
+ string.format(locale.PM_BROWSER_CTAGS_NOT_FOUND, item.text))
end
elseif item.line_num then
textadept.io.open(item.filepath)
diff --git a/core/ext/pm/file_browser.lua b/core/ext/pm/file_browser.lua
index 8aa6cf96..45c1db4c 100644
--- a/core/ext/pm/file_browser.lua
+++ b/core/ext/pm/file_browser.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- File browser for the Textadept project manager.
@@ -48,7 +49,6 @@ end
local ID = { CHANGE_DIR = 1, FILE_INFO = 2 }
function get_context_menu(selected_item)
- local locale = textadept.locale
return {
{ 'separator', 0 }, -- make it harder to click 'Change Directory' by mistake
{ locale.PM_BROWSER_FILE_CD, ID.CHANGE_DIR },
@@ -57,7 +57,6 @@ function get_context_menu(selected_item)
end
function perform_menu_action(menu_id, selected_item)
- local locale = textadept.locale
local filepath = table.concat(selected_item, '/')
if menu_id == ID.CHANGE_DIR then
textadept.pm.entry_text = filepath
diff --git a/core/ext/pm/macro_browser.lua b/core/ext/pm/macro_browser.lua
index 75e9e91f..32bd86ff 100644
--- a/core/ext/pm/macro_browser.lua
+++ b/core/ext/pm/macro_browser.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- Macro browser for the Textadept project manager.
@@ -28,7 +29,6 @@ end
local ID = { DELETE = 1 }
function get_context_menu(selected_item)
- local locale = textadept.locale
return { { locale.PM_BROWSER_MACRO_DELETE, ID.DELETE } }
end
diff --git a/core/ext/pm/modules_browser.lua b/core/ext/pm/modules_browser.lua
index 174394a6..921dc455 100644
--- a/core/ext/pm/modules_browser.lua
+++ b/core/ext/pm/modules_browser.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- Modules browser for the Textadept project manager.
@@ -113,7 +114,6 @@ local ID = {
}
function get_context_menu(selected_item)
- local locale = textadept.locale
return {
{ locale.PM_BROWSER_MODULE_NEW, ID.NEW },
{ locale.PM_BROWSER_MODULE_DELETE, ID.DELETE },
@@ -125,7 +125,6 @@ function get_context_menu(selected_item)
end
function perform_menu_action(menu_id, selected_item)
- local locale = textadept.locale
if menu_id == ID.NEW then
local status, module_name =
cocoa_dialog('standard-inputbox', {
diff --git a/core/ext/pm/project_browser.lua b/core/ext/pm/project_browser.lua
index b1609ad1..30616ef9 100644
--- a/core/ext/pm/project_browser.lua
+++ b/core/ext/pm/project_browser.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- Browser template for the Textadept project manager.
@@ -84,7 +85,6 @@ local ID = {
--- Displays the project manager context menu.
function get_context_menu(selected_item)
- local locale = textadept.locale
return {
{ 'separator', 0 }, -- make it harder to click 'New Project' by mistake
{ locale.PM_BROWSER_PROJECT_NEW, ID.NEW },
@@ -101,7 +101,6 @@ function get_context_menu(selected_item)
end
function perform_menu_action(menu_id, selected_item)
- local locale = textadept.locale
if menu_id == ID.NEW then
-- Close all open files and prompt the user to save a project file.
if textadept.io.close_all() then
diff --git a/core/file_io.lua b/core/file_io.lua
index 4dce2721..8e487930 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -1,6 +1,7 @@
-- Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE.
local textadept = _G.textadept
+local locale = _G.locale
---
-- Provides file input/output routines for Textadept.
@@ -48,7 +49,6 @@ end
-- specified, the user is prompted to open files from a dialog.
-- @usage textadept.io.open(filename)
function open(filenames)
- local locale = textadept.locale
filenames =
filenames or cocoa_dialog('fileselect', {
title = locale.IO_OPEN_TITLE,
@@ -113,7 +113,7 @@ function save_as(buffer, filename)
if not filename then
filename =
cocoa_dialog('filesave', {
- title = textadept.locale.IO_SAVE_TITLE,
+ title = locale.IO_SAVE_TITLE,
['with-directory'] = (buffer.filename or ''):match('.+[/\\]'),
['with-file'] = (buffer.filename or ''):match('[^/\\]+$'),
['no-newline'] = true
@@ -148,7 +148,6 @@ end
-- buffer.
-- @usage buffer:close()
function close(buffer)
- local locale = textadept.locale
textadept.check_focused_buffer(buffer)
if buffer.dirty and cocoa_dialog('yesno-msgbox', {
title = locale.IO_CLOSE_TITLE,
diff --git a/core/init.lua b/core/init.lua
index e792a515..bf272496 100644
--- a/core/init.lua
+++ b/core/init.lua
@@ -37,7 +37,6 @@ rawset = nil -- do not allow modifications which could compromise stability
-- if the check fails.
-- @param buffer The buffer in question.
function textadept.check_focused_buffer(buffer)
- local locale = textadept.locale
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
@@ -53,8 +52,8 @@ end
-- buffer, and prints to it.
-- @param buffer_type String type of message buffer.
-- @param ... Message strings.
--- @usage textadept._print(textadept.locale.ERROR_BUFFER, error_message)
--- @usage textadept._print(textadept.locale.MESSAGE_BUFFER, message)
+-- @usage textadept._print(locale.ERROR_BUFFER, error_message)
+-- @usage textadept._print(locale.MESSAGE_BUFFER, message)
function textadept._print(buffer_type, ...)
local function safe_print(...)
local message = table.concat({...}, '\t')
@@ -93,9 +92,7 @@ end
-- Prints messages to the Textadept message buffer.
-- Opens a new buffer (if one hasn't already been opened) for printing messages.
-- @param ... Message strings.
-function textadept.print(...)
- textadept._print(textadept.locale.MESSAGE_BUFFER, ...)
-end
+function textadept.print(...) textadept._print(locale.MESSAGE_BUFFER, ...) end
---
-- Displays a CocoaDialog of a specified type with given arguments returning
diff --git a/core/locale.lua b/core/locale.lua
index 26a7f1fe..696eacb1 100644
--- a/core/locale.lua
+++ b/core/locale.lua
@@ -7,7 +7,7 @@
-- languages.
-- However, you must convert any UTF-16, UTF-32, etc. to UTF-8 manually as the
-- \U+xxxx format cannot be represented in Lua.
-module('textadept.locale', package.seeall)
+module('locale', package.seeall)
-- init.lua