aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/events.lua4
-rw-r--r--core/ext/find.lua24
-rw-r--r--core/ext/keys.lua29
-rw-r--r--core/ext/mime_types.lua8
-rw-r--r--core/file_io.lua16
-rw-r--r--modules/textadept/editing.lua43
-rw-r--r--modules/textadept/lsnippets.lua30
7 files changed, 44 insertions, 110 deletions
diff --git a/core/events.lua b/core/events.lua
index e990a5c6..61ebd3ea 100644
--- a/core/events.lua
+++ b/core/events.lua
@@ -295,9 +295,7 @@ add_handler('buffer_new',
if not ret then io.stderr:write(errmsg) end
end)
----
--- [Local function] Sets the title of the Textadept window to the buffer's
--- filename.
+-- Sets the title of the Textadept window to the buffer's filename.
-- @param buffer The currently focused buffer.
local function set_title(buffer)
local buffer = buffer
diff --git a/core/ext/find.lua b/core/ext/find.lua
index c68b97e3..de59c576 100644
--- a/core/ext/find.lua
+++ b/core/ext/find.lua
@@ -10,17 +10,13 @@ local MARK_FIND = 0
local MARK_FIND_COLOR = 0x4D9999
local previous_view
----
--- [Local table] Text escape sequences with their associated characters.
--- @class table
--- @name escapes
+-- Text escape sequences with their associated characters.
local escapes = {
['\\a'] = '\a', ['\\b'] = '\b', ['\\f'] = '\f', ['\\n'] = '\n',
['\\r'] = '\r', ['\\t'] = '\t', ['\\v'] = '\v', ['\\\\'] = '\\'
}
----
--- [Local function] Finds and selects text in the current buffer.
+-- Finds and selects text in the current buffer.
-- @param text The text to find.
-- @param next Flag indicating whether or not the search direction is forward.
-- @param flags Search flags. This is a number mask of 4 flags: match case (2),
@@ -156,9 +152,8 @@ local function find_(text, next, flags, nowrap, wrapped)
end
textadept.events.add_handler('find', find_)
----
--- [Local function] Finds and selects text incrementally in the current buffer
--- from a start point.
+-- Finds and selects text incrementally in the current buffer from a start
+-- point.
-- Flags other than SCFIND_MATCHCASE are ignored.
-- @param text The text to find.
local function find_incremental(text)
@@ -205,8 +200,7 @@ textadept.events.add_handler('command_entry_command',
end
end, 1) -- place before command_entry.lua's handler (if necessary)
----
--- [Local function] Replaces found text.
+-- Replaces found text.
-- 'find_' is called first, to select any found text. The selected text is then
-- replaced by the specified replacement text.
-- This function ignores 'Find in Files'.
@@ -251,8 +245,7 @@ local function replace(rtext)
end
textadept.events.add_handler('replace', replace)
----
--- [Local function] Replaces all found text.
+-- Replaces all found text.
-- If any text is selected, all found text in that selection is replaced.
-- This function ignores 'Find in Files'.
-- @param ftext The text to find.
@@ -300,9 +293,8 @@ local function replace_all(ftext, rtext, flags)
end
textadept.events.add_handler('replace_all', replace_all)
----
--- [Local function] When the user double-clicks a found file, go to the line in
--- the file the text was found at.
+-- When the user double-clicks a found file, go to the line in the file the text
+-- was found at.
-- @param pos The position of the caret.
-- @param line_num The line double-clicked.
local function goto_file(pos, line_num)
diff --git a/core/ext/keys.lua b/core/ext/keys.lua
index b6d4c6d0..5a27f36a 100644
--- a/core/ext/keys.lua
+++ b/core/ext/keys.lua
@@ -81,7 +81,7 @@ local ALT = 'a'..ADD
---
-- Global container that holds all key commands.
-- @class table
--- @name keys
+-- @name _G.keys
_G.keys = {}
-- optimize for speed
@@ -96,12 +96,9 @@ local type = _G.type
local unpack = _G.unpack
local MAC = _G.MAC
----
--- [Local table] Lookup table for key values higher than 255.
+-- 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.
--- @class table
--- @name KEYSYMS
local KEYSYMS = { -- from <gdk/gdkkeysyms.h>
[65056] = '\t', -- backtab; will be 'shift'ed
[65288] = '\b',
@@ -123,9 +120,7 @@ local KEYSYMS = { -- from <gdk/gdkkeysyms.h>
[65478] = 'f9', [65479] = 'f10', [65480] = 'f11', [65481] = 'f12',
}
---- [Local table] The current key sequence.
--- @class table
--- @name keychain
+-- The current key sequence.
local keychain = {}
-- local functions
@@ -138,8 +133,7 @@ function clear_key_sequence()
textadept.statusbar_text = ''
end
----
--- [Local function] Handles Textadept keypresses.
+-- Handles Textadept keypresses.
-- It is called every time a key is pressed, and based on lexer and scope,
-- executes a command. The command is looked up in the global 'keys' key
-- command table.
@@ -219,28 +213,23 @@ local function keypress(code, shift, control, alt)
end
textadept.events.add_handler('keypress', keypress, 1)
----
--- [Local function] Tries to get a key command based on the lexer and current
--- scope.
+-- Tries to get a key command based on the lexer and current scope.
try_get_cmd1 = function(keys, lexer, scope)
return try_get_cmd(keys[lexer][scope])
end
----
--- [Local function] Tries to get a key command based on the lexer.
+-- Tries to get a key command based on the lexer.
try_get_cmd2 = function(keys, lexer)
return try_get_cmd(keys[lexer])
end
----
--- [Local function] Tries to get a global key command.
+-- Tries to get a global key command.
try_get_cmd3 = function(keys)
return try_get_cmd(keys)
end
----
--- [Local function] Helper function that gets commands associated with the
--- current keychain from 'keys'.
+-- Helper function that gets commands associated with the current keychain from
+-- 'keys'.
-- If the current item in the keychain is part of a chain, throw an error value
-- 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.
diff --git a/core/ext/mime_types.lua b/core/ext/mime_types.lua
index f411ab89..e6412884 100644
--- a/core/ext/mime_types.lua
+++ b/core/ext/mime_types.lua
@@ -44,7 +44,7 @@ if f then
end
---
--- [Local function] Replacement for buffer:set_lexer_language().
+-- Replacement for buffer:set_lexer_language().
-- Sets a buffer._lexer field so it can be restored without querying the
-- mime-types tables. Also if the user manually sets the lexer, it should be
-- restored.
@@ -58,8 +58,7 @@ end
textadept.events.add_handler('buffer_new',
function() buffer.set_lexer = set_lexer end)
----
--- [Local function] Performs actions suitable for a new buffer.
+-- Performs actions suitable for a new buffer.
-- Sets the buffer's lexer language and loads the language module.
local function handle_new()
local lexer
@@ -97,8 +96,7 @@ local function handle_new()
end
end
----
--- [Local function] Sets the buffer's lexer based on filename, shebang words, or
+-- Sets the buffer's lexer based on filename, shebang words, or
-- first line pattern.
local function restore_lexer()
buffer:set_lexer_language(buffer._lexer or 'container')
diff --git a/core/file_io.lua b/core/file_io.lua
index 56f3777c..aedecbd3 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -32,8 +32,7 @@ boms = {
['UTF-32LE'] = string.char(255, 254, 0, 0)
}
----
--- [Local function] Attempt to detect the encoding of the given text.
+-- Attempt to detect the encoding of the given text.
-- @param text Text to determine encoding from.
-- @return encoding string for textadept.iconv() (unless 'binary', indicating a
-- binary file), byte-order mark (BOM) string or nil. If encoding string is
@@ -57,10 +56,7 @@ local function detect_encoding(text)
return nil
end
----
--- [Local table] List of encodings to try to decode files as after UTF-8.
--- @class table
--- @name try_encodings
+-- List of encodings to try to decode files as after UTF-8.
local try_encodings = {
'UTF-8',
'ASCII',
@@ -68,8 +64,7 @@ local try_encodings = {
'MacRoman'
}
----
--- [Local function] Opens a file or goes to its already open buffer.
+-- Opens a file or goes to its already open buffer.
-- @param utf8_filename The absolute path to the file to open. Must be UTF-8
-- encoded.
local function open_helper(utf8_filename)
@@ -338,9 +333,8 @@ function read_api_file(filename, word_chars)
return api
end
----
--- [Local function] Prompts the user to reload the current file if it has been
--- modified outside of Textadept.
+-- Prompts the user to reload the current file if it has been modified outside
+-- of Textadept.
local function update_modified_file()
if not buffer.filename then return end
local utf8_filename = buffer.filename
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index 5556e110..d1d2c4a2 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -7,45 +7,30 @@ local locale = _G.locale
-- Editing commands for the textadept module.
module('_m.textadept.editing', package.seeall)
----
--- [Local table] The kill-ring.
--- @class table
--- @name kill_ring
+-- The kill-ring.
-- @field maxn The maximum size of the kill-ring.
local kill_ring = { pos = 1, maxn = 10 }
----
--- [Local table] Character matching.
+-- Character matching.
-- Used for auto-matching parentheses, brackets, braces, and quotes.
--- @class table
--- @name char_matches
local char_matches = {
[40] = ')', [91] = ']', [123] = '}',
[39] = "'", [34] = '"'
}
----
--- [Local table] Brace characters.
+-- Brace characters.
-- Used for going to matching brace positions.
--- @class table
--- @name braces
local braces = { -- () [] {} <>
[40] = 1, [91] = 1, [123] = 1, [60] = 1,
[41] = 1, [93] = 1, [125] = 1, [62] = 1,
}
----
--- [Local table] The current call tip.
+-- The current call tip.
-- Used for displaying call tips.
--- @class table
--- @name current_call_tip
local current_call_tip = {}
----
--- [Local table] Enclosures for enclosing or selecting ranges of text.
+-- Enclosures for enclosing or selecting ranges of text.
-- Note chars and tag enclosures are generated at runtime.
--- @class table
--- @name enclosure
local enclosure = {
dbl_quotes = { left = '"', right = '"' },
sng_quotes = { left = "'", right = "'" },
@@ -58,11 +43,8 @@ local enclosure = {
single_tag = { left = '<', right = ' />' }
}
----
--- [Local table] Comment strings for various lexer languages.
+-- Comment strings for various lexer languages.
-- Used for the block_comment function.
--- @class table
--- @name comment_strings
-- @see block_comment
local comment_strings = {
cpp = '//~',
@@ -587,8 +569,7 @@ function convert_indentation()
buffer:end_undo_action()
end
----
--- [Local function] Inserts text into kill_ring.
+-- Inserts text into kill_ring.
-- If it grows larger than maxn, the oldest inserted text is replaced.
-- @see smart_cutcopy
insert_into_kill_ring = function(txt)
@@ -596,8 +577,7 @@ insert_into_kill_ring = function(txt)
if #kill_ring > kill_ring.maxn then kill_ring[kill_ring.maxn + 1] = nil end
end
----
--- [Local function] Scrolls kill_ring in the specified direction.
+-- Scrolls kill_ring in the specified direction.
-- @param direction The direction to scroll: 'forward' (default) or 'reverse'.
-- @see smart_paste
scroll_kill_ring = function(direction)
@@ -610,8 +590,7 @@ scroll_kill_ring = function(direction)
end
end
----
--- [Local function] Returns the number to the left of the caret.
+-- Returns the number to the left of the caret.
-- This is used for the enclose function.
-- @see enclose
get_preceding_number = function()
@@ -627,9 +606,7 @@ get_preceding_number = function()
return tonumber(txt) or 1, #txt
end
----
--- [Local function] Returns the current selection or the contents of the
--- current line.
+-- Returns the current selection or the contents of the current line.
get_sel_or_line = function()
local buffer = buffer
if buffer:get_sel_text() == '' then select_line() end
diff --git a/modules/textadept/lsnippets.lua b/modules/textadept/lsnippets.lua
index e773be0f..3d4c73fa 100644
--- a/modules/textadept/lsnippets.lua
+++ b/modules/textadept/lsnippets.lua
@@ -86,16 +86,10 @@ _G.snippets.path = "%((buffer.filename or ''):match('^.+/'))"
_G.snippets.tab = "%%%1(1)(%2(default))"
_G.snippets.key = "['%1'] = { %2(func)%3(, %4(arg)) }"
----
--- [Local table] The current snippet.
--- @class table
--- @name snippet
+-- The current snippet.
local snippet = {}
----
--- [Local table] The stack of currently running snippets.
--- @class table
--- @name snippet_stack
+-- The stack of currently running snippets.
local snippet_stack = {}
-- Local functions.
@@ -371,9 +365,8 @@ function show_style()
buffer:call_tip_show(buffer.current_pos, text)
end
----
--- [Local function] Gets the start position, end position, and text of the
--- currently running snippet.
+-- Gets the start position, end position, and text of the currently running
+-- snippet.
-- @return start pos, end pos, and snippet text.
snippet_info = function()
local buffer = buffer
@@ -384,8 +377,7 @@ snippet_info = function()
if e >= s then return s, e, buffer:text_range(s, e) end
end
----
--- [Local function] Runs the given Lua code.
+-- Runs the given Lua code.
run_lua_code = function(code)
code = unhandle_escapes(code)
local env =
@@ -394,9 +386,7 @@ run_lua_code = function(code)
return val or ''
end
----
--- [Local function] Replaces escaped characters with their octal equivalents in
--- a given string.
+-- Replaces escaped characters with their octal equivalents in a given string.
-- '%%' is the escape character used.
handle_escapes = function(s)
return s:gsub('%%([%%`%)|#])',
@@ -405,9 +395,7 @@ handle_escapes = function(s)
end)
end
----
--- [Local function] Replaces octal characters with their escaped equivalents in
--- a given string.
+-- Replaces octal characters with their escaped equivalents in a given string.
unhandle_escapes = function(s)
return s:gsub('\\(%d%d%d)',
function(value)
@@ -415,8 +403,6 @@ unhandle_escapes = function(s)
end)
end
----
--- [Local function] Replaces escaped characters with the actual characters in a
--- given string.
+-- Replaces escaped characters with the actual characters in a given string.
-- This is used when escape sequences are no longer needed.
unescape = function(s) return s:gsub('%%([%%`%)|#])', '%1') end