aboutsummaryrefslogtreecommitdiffhomepage
path: root/core/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'core/init.lua')
-rw-r--r--core/init.lua57
1 files changed, 23 insertions, 34 deletions
diff --git a/core/init.lua b/core/init.lua
index 712d07a7..361edf3e 100644
--- a/core/init.lua
+++ b/core/init.lua
@@ -6,9 +6,7 @@ _COPYRIGHT = 'Copyright © 2007-2021 Mitchell. See LICENSE.\n' ..
package.path = string.format('%s/core/?.lua;%s', _HOME, package.path)
---for _, arg in ipairs(arg) do
--- if arg == '-t' or arg == '--test' then pcall(require, 'luacov') end
---end
+-- for _, arg in ipairs(arg) do if arg == '-t' or arg == '--test' then pcall(require, 'luacov') end end
require('assert')
_SCINTILLA = require('iface')
@@ -40,13 +38,11 @@ if CURSES and WIN32 then
end
end
--- Replacement for original `buffer:text_range()`, which has a C struct for an
--- argument.
+-- Replacement for original `buffer:text_range()`, which has a C struct for an argument.
-- Documentation is in core/.buffer.luadoc.
local function text_range(buffer, start_pos, end_pos)
local target_start, target_end = buffer.target_start, buffer.target_end
- buffer:set_target_range(
- math.max(1, assert_type(start_pos, 'number', 2)),
+ buffer:set_target_range(math.max(1, assert_type(start_pos, 'number', 2)),
math.min(assert_type(end_pos, 'number', 3), buffer.length + 1))
local text = buffer.target_text
buffer:set_target_range(target_start, target_end) -- restore
@@ -56,13 +52,11 @@ end
local GETNAMEDSTYLE = _SCINTILLA.properties.named_styles[1]
-- Documentation is in core/.buffer.luadoc.
local function style_of_name(buffer, style_name)
- return buffer:private_lexer_call(
- GETNAMEDSTYLE, assert_type(style_name, 'string', 2))
+ return buffer:private_lexer_call(GETNAMEDSTYLE, assert_type(style_name, 'string', 2))
end
-events.connect(events.BUFFER_NEW, function()
- buffer.text_range, buffer.style_of_name = text_range, style_of_name
-end)
+events.connect(events.BUFFER_NEW,
+ function() buffer.text_range, buffer.style_of_name = text_range, style_of_name end)
--[[ This comment is for LuaDoc.
---
@@ -72,13 +66,12 @@ end)
-- @field _RELEASE (string)
-- The Textadept release version string.
-- @field _USERHOME (string)
--- The path to the user's *~/.textadept/* directory, where all preferences and
--- user-data is stored.
--- On Windows machines *~/* is the value of the "USERHOME" environment
--- variable (typically *C:\Users\username\\* or
--- *C:\Documents and Settings\username\\*). On Linux, BSD, and macOS
--- machines *~/* is the value of "$HOME" (typically */home/username/* and
--- */Users/username/* respectively).
+-- The path to the user's *~/.textadept/* directory, where all preferences and user-data
+-- is stored.
+-- On Windows machines *~/* is the value of the "USERHOME" environment variable (typically
+-- *C:\Users\username\\* or *C:\Documents and Settings\username\\*). On Linux, BSD, and macOS
+-- machines *~/* is the value of "$HOME" (typically */home/username/* and */Users/username/*
+-- respectively).
-- @field _CHARSET (string)
-- The filesystem's character encoding.
-- This is used when [working with files](#io).
@@ -108,8 +101,7 @@ local arg
---
-- Table of all open buffers in Textadept.
--- Numeric keys have buffer values and buffer keys have their associated numeric
--- keys.
+-- Numeric keys have buffer values and buffer keys have their associated numeric keys.
-- @class table
-- @usage _BUFFERS[n] --> buffer at index n
-- @usage _BUFFERS[buffer] --> index of buffer in _BUFFERS
@@ -119,8 +111,7 @@ local _BUFFERS
---
-- Table of all views in Textadept.
--- Numeric keys have view values and view keys have their associated numeric
--- keys.
+-- Numeric keys have view values and view keys have their associated numeric keys.
-- @class table
-- @usage _VIEWS[n] --> view at index n
-- @usage _VIEWS[view] --> index of view in _VIEWS
@@ -143,8 +134,7 @@ local view
-- The functions below are Lua C functions.
---
--- Emits a `QUIT` event, and unless any handler returns `false`, quits
--- Textadept.
+-- Emits a `QUIT` event, and unless any handler returns `false`, quits Textadept.
-- @see events.QUIT
-- @class function
-- @name quit
@@ -152,21 +142,20 @@ local quit
---
-- Resets the Lua State by reloading all initialization scripts.
--- Language modules for opened files are NOT reloaded. Re-opening the files that
--- use them will reload those modules instead.
--- This function is useful for modifying user scripts (such as
--- *~/.textadept/init.lua* and *~/.textadept/modules/textadept/keys.lua*) on
--- the fly without having to restart Textadept. `arg` is set to `nil` when
--- reinitializing the Lua State. Any scripts that need to differentiate between
--- startup and reset can test `arg`.
+-- Language modules for opened files are NOT reloaded. Re-opening the files that use them will
+-- reload those modules instead.
+-- This function is useful for modifying user scripts (such as *~/.textadept/init.lua* and
+-- *~/.textadept/modules/textadept/keys.lua*) on the fly without having to restart Textadept. `arg`
+-- is set to `nil` when reinitializing the Lua State. Any scripts that need to differentiate
+-- between startup and reset can test `arg`.
-- @class function
-- @name reset
local reset
---
-- Calls function *f* with the given arguments after *interval* seconds.
--- If *f* returns `true`, calls *f* repeatedly every *interval* seconds as long
--- as *f* returns `true`. A `nil` or `false` return value stops repetition.
+-- If *f* returns `true`, calls *f* repeatedly every *interval* seconds as long as *f* returns
+-- `true`. A `nil` or `false` return value stops repetition.
-- @param interval The interval in seconds to call *f* after.
-- @param f The function to call.
-- @param ... Additional arguments to pass to *f*.