aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/14_Appendix.md50
-rw-r--r--modules/textadept/bookmarks.lua31
-rw-r--r--modules/textadept/editing.lua24
-rw-r--r--modules/textadept/run.lua24
4 files changed, 64 insertions, 65 deletions
diff --git a/doc/14_Appendix.md b/doc/14_Appendix.md
index be7a0235..8696ae58 100644
--- a/doc/14_Appendix.md
+++ b/doc/14_Appendix.md
@@ -153,33 +153,36 @@ completely new theme implementation.
Old API |Change |New API
----------------------------------|:------:|-------
**_G** | |
-RESETTING |Removed |N/A<sup>\*</sup>
+RESETTING |Removed |N/A<sup>a</sup>
buffer\_new() |Renamed |\_G.[buffer.new()][]
**_M.textadept** |Renamed |[textadept][]
filter\_through |Removed |N/A
filter\_through.filter\_through() |Renamed |editing.[filter\_through()][]
-mime\_types |Renamed |[file\_types][]<sup>+</sup>
+mime\_types |Renamed |[file\_types][]<sup>b</sup>
**_M.textadept.bookmark** | |
N/A |New |[goto\_mark()][]
-MARK\_BOOKMARK\_COLOR |Renamed |[BOOKMARK\_COLOR][]
+N/A |New |[MARK\_BOOKMARK][]
+MARK\_BOOKMARK\_COLOR |Removed |N/A<sup>c</sup>
goto\_bookmark |Replaced|goto\_mark()
goto\_next |Replaced|goto\_mark(true)
goto\_prev |Replaced|goto\_mark(false)
**_M.textadept.editing** | |
-INDIC\_HIGHLIGHT\_BACK |Renamed |[HIGHLIGHT\_COLOR][]
+N/A |New |[INDIC\_HIGHLIGHT][]
+INDIC\_HIGHLIGHT\_BACK |Removed |N/A<sup>d</sup>
autocomplete\_word(chars, default)|Changed |[autocomplete\_word][](default)
grow\_selection() |Replaced|[select\_enclosed()][]
**_M.textadept.menu** | |
menubar |Removed |N/A
contextmenu |Removed |N/A
**_M.textadept.run** | |
-MARK\_ERROR\_BACK |Renamed |[ERROR\_COLOR][]
+N/A |New |[MARK\_ERROR][]
+MARK\_ERROR\_BACK |Removed |N/A<sup>c</sup>
**_M.textadept.snapopen** |Removed |N/A
-open |Changed |\_G.[io.snapopen()][]<sup>†</sup>
+open |Changed |\_G.[io.snapopen()][]<sup>e</sup>
**buffer** | |
get\_style\_name(buffer, n) |Renamed |[style\_name][]\[n\]
**events** | |
-N/A |New |[INITIALIZED][]<sup>‡</sup>
+N/A |New |[INITIALIZED][]<sup>f</sup>
handlers |Removed |N/A
**gui** |Renamed |[ui][]
docstatusbar\_text |Renamed |[bufstatusbar\_text][]
@@ -189,13 +192,17 @@ select\_theme |Removed |N/A
**io** | |
try\_encodings |Renamed |[encodings][]
-<sup>\*</sup>`arg` is `nil` when resetting.
+<sup>a</sup>`arg` is `nil` when resetting.
-<sup>+</sup>Removed *mime_types.conf* files. Interact with Lua tables directly.
+<sup>b</sup>Removed *mime_types.conf* files. Interact with Lua tables directly.
-<sup>†</sup>Changed arguments too.
+<sup>c</sup>Set [`buffer.marker_back`][] in [`events.VIEW_NEW`][].
-<sup>‡</sup>Custom menus and key bindings should take advantage of this since
+<sup>d</sup>Set [`buffer.indic_fore`][] in [`events.VIEW_NEW`][].
+
+<sup>e</sup>Changed arguments too.
+
+<sup>f</sup>Custom menus and key bindings should take advantage of this since
not all buffer functions are available at the `require()` stage. See
*modules/textadept/init.lua* for an example.
@@ -204,11 +211,11 @@ not all buffer functions are available at the `require()` stage. See
[filter\_through()]: api/textadept.editing.html#filter_through
[file\_types]: api/textadept.file_types.html
[goto\_mark()]: api/textadept.bookmarks.html#goto_mark
-[BOOKMARK\_COLOR]: api/textadept.bookmarks.html#BOOKMARK_COLOR
-[HIGHLIGHT\_COLOR]: api/textadept.editing.html#HIGHLIGHT_COLOR
+[MARK\_BOOKMARK]: api/textadept.bookmarks.html#MARK_BOOKMARK
+[INDIC\_HIGHLIGHT]: api/textadept.editing.html#INDIC_HIGHLIGHT
[autocomplete\_word]: api/textadept.editing.html#autocomplete_word
[select\_enclosed()]: api/textadept.editing.html#select_enclosed
-[ERROR\_COLOR]: api/textadept.run.html#ERROR_COLOR
+[MARK\_ERROR]: api/textadept.run.html#MARK_ERROR
[io.snapopen()]: api/io.html#snapopen
[style\_name]: api/buffer.html#style_name
[INITIALIZED]: api/events.html#INITIALIZED
@@ -217,6 +224,9 @@ not all buffer functions are available at the `require()` stage. See
[maximized]: api/ui.html#maximized
[goto\_file\_found()]: api/ui.find.html#goto_file_found
[encodings]: api/io.html#encodings
+[`buffer.marker_back`]: api/buffer.html#marker_back
+[`events.VIEW_NEW`]: api/events.html#VIEW_NEW
+[`buffer.indic_fore`]: api/buffer.html#indic_fore
#### Module Mentality
@@ -398,26 +408,26 @@ Old API |Change |New API
getfenv(f) |Removed |N/A. Use:<br/>debug.getupvalue(f, 1)
loadstring() |Replaced|load()
module() |Removed |N/A
-setfenv(f, env)|Removed |N/A. Use:<br/>debug.setupvalue(f, 1, env)<sup>\*</sup>
+setfenv(f, env)|Removed |N/A. Use:<br/>debug.setupvalue(f, 1, env)<sup>a</sup>
unpack() |Renamed |table.unpack()
xpcall(f, msgh)|Changed |xpcall(f, msgh, ...)
-**\_m** |Renamed |**[\_M][]**<sup>†</sup>
+**\_m** |Renamed |**[\_M][]**<sup>b</sup>
**_m.textadept.editing**| |
-current\_word(action) |Renamed|[select\_word()][]<sup>‡</sup>
+current\_word(action) |Renamed|[select\_word()][]<sup>c</sup>
**locale** |Removed|N/A
localize(message) |Renamed|\_G.[\_L][][message]
**os** | |
code = execute(cmd) |Changed|ok, status, code = execute(cmd)
-<sup>\*</sup>In some cases, use `load()` with an environment instead:
+<sup>a</sup>In some cases, use `load()` with an environment instead:
setfenv(loadstring(str), env)() --> load(str, nil, 'bt', env)()
-<sup>†</sup>In Textadept, search for "\_m" and replace with "\_M" with the
+<sup>b</sup>In Textadept, search for "\_m" and replace with "\_M" with the
"Match Case" and "Whole Words" options checked -- this is what I did when
upgrading Textadept's internals.
-<sup>‡</sup>To delete, call `_M.textadept.keys.utils.delete_word()` or define
+<sup>c</sup>To delete, call `_M.textadept.keys.utils.delete_word()` or define
your own:
local function delete_word()
diff --git a/modules/textadept/bookmarks.lua b/modules/textadept/bookmarks.lua
index 525befa9..b6fc39d5 100644
--- a/modules/textadept/bookmarks.lua
+++ b/modules/textadept/bookmarks.lua
@@ -5,13 +5,11 @@ local M = {}
--[[ This comment is for LuaDoc.
---
-- Bookmarks for Textadept.
--- @field BOOKMARK_COLOR (string)
--- The name of the color in the current theme to mark a bookmarked line with.
+-- @field MARK_BOOKMARK (number)
+-- The bookmark mark number.
module('textadept.bookmarks')]]
-M.BOOKMARK_COLOR = not CURSES and 'color.dark_blue' or 'color.blue'
-
-local MARK_BOOKMARK = _SCINTILLA.next_marker_number()
+M.MARK_BOOKMARK = _SCINTILLA.next_marker_number()
---
-- Toggles the bookmark on the current line unless *on* is given.
@@ -23,17 +21,17 @@ function M.toggle(on)
local line = buffer:line_from_position(buffer.current_pos)
local f = on and buffer.marker_add or buffer.marker_delete
if on == nil then -- toggle
- local bit, marker_mask = 2^MARK_BOOKMARK, buffer:marker_get(line)
+ local bit, marker_mask = 2^M.MARK_BOOKMARK, buffer:marker_get(line)
if bit32.band(marker_mask, bit) == 0 then f = buffer.marker_add end
end
- f(buffer, line, MARK_BOOKMARK)
+ f(buffer, line, M.MARK_BOOKMARK)
end
---
-- Clears all bookmarks in the current buffer.
-- @name clear
function M.clear()
- buffer:marker_delete_all(MARK_BOOKMARK)
+ buffer:marker_delete_all(M.MARK_BOOKMARK)
end
---
@@ -48,21 +46,21 @@ end
function M.goto_mark(next)
if next == nil then
local buffer = buffer
- local marks, line = {}, buffer:marker_next(0, 2^MARK_BOOKMARK)
+ local marks, line = {}, buffer:marker_next(0, 2^M.MARK_BOOKMARK)
if line == -1 then return end
repeat
local text = buffer:get_line(line):sub(1, -2) -- chop \n
marks[#marks + 1] = tostring(line + 1)..': '..text
- line = buffer:marker_next(line + 1, 2^MARK_BOOKMARK)
+ line = buffer:marker_next(line + 1, 2^M.MARK_BOOKMARK)
until line < 0
local line = ui.filteredlist(_L['Select Bookmark'], _L['Bookmark'], marks)
if line then textadept.editing.goto_line(line:match('^%d+')) end
else
local f = next and buffer.marker_next or buffer.marker_previous
local current_line = buffer:line_from_position(buffer.current_pos)
- local line = f(buffer, current_line + (next and 1 or -1), 2^MARK_BOOKMARK)
+ local line = f(buffer, current_line + (next and 1 or -1), 2^M.MARK_BOOKMARK)
if line == -1 then
- line = f(buffer, (next and 0 or buffer.line_count), 2^MARK_BOOKMARK)
+ line = f(buffer, (next and 0 or buffer.line_count), 2^M.MARK_BOOKMARK)
end
if line >= 0 then textadept.editing.goto_line(line + 1) end
end
@@ -70,10 +68,9 @@ end
local CURSES_MARK = buffer.SC_MARK_CHARACTER + string.byte(' ')
-- Sets view properties for bookmark markers.
-local function set_bookmark_properties()
- if CURSES then buffer:marker_define(MARK_BOOKMARK, CURSES_MARK) end
- buffer.marker_back[MARK_BOOKMARK] = buffer.property_int[M.BOOKMARK_COLOR]
-end
-events.connect(events.VIEW_NEW, set_bookmark_properties)
+events.connect(events.VIEW_NEW, function()
+ if CURSES then buffer:marker_define(M.MARK_BOOKMARK, CURSES_MARK) end
+ buffer.marker_back[M.MARK_BOOKMARK] = not CURSES and 0xB3661A or 0x800000
+end)
return M
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index acd4a5e1..97935f13 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -27,9 +27,8 @@ local M = {}
-- @field STRIP_TRAILING_SPACES (bool)
-- Strip trailing whitespace on file save.
-- The default value is `true`.
--- @field HIGHLIGHT_COLOR (string)
--- The name of the color in the current theme to
--- [highlight words](#highlight_word) with.
+-- @field INDIC_HIGHLIGHT (number)
+-- The word highlight indicator number.
module('textadept.editing')]]
M.AUTOPAIR = true
@@ -37,7 +36,7 @@ M.HIGHLIGHT_BRACES = true
M.TYPEOVER_CHARS = true
M.AUTOINDENT = true
M.STRIP_TRAILING_SPACES = true
-M.HIGHLIGHT_COLOR = not CURSES and 'color.orange' or 'color.yellow'
+M.INDIC_HIGHLIGHT = _SCINTILLA.next_indic_number()
---
-- Map of lexer names to line comment strings for programming languages, used by
@@ -470,11 +469,9 @@ function M.convert_indentation()
buffer:end_undo_action()
end
-local INDIC_HIGHLIGHT = _SCINTILLA.next_indic_number()
-
-- Clears highlighted word indicators and markers.
local function clear_highlighted_words()
- buffer.indicator_current = INDIC_HIGHLIGHT
+ buffer.indicator_current = M.INDIC_HIGHLIGHT
buffer:indicator_clear_range(0, buffer.length)
end
events.connect(events.KEYPRESS, function(code)
@@ -505,13 +502,12 @@ function M.highlight_word()
end
-- Sets view properties for highlighted word indicators and markers.
-local function set_highlight_properties()
- buffer.indic_fore[INDIC_HIGHLIGHT] = buffer.property_int[M.HIGHLIGHT_COLOR]
- buffer.indic_style[INDIC_HIGHLIGHT] = buffer.INDIC_ROUNDBOX
- buffer.indic_alpha[INDIC_HIGHLIGHT] = 255
- if not CURSES then buffer.indic_under[INDIC_HIGHLIGHT] = true end
-end
-events.connect(events.VIEW_NEW, set_highlight_properties)
+events.connect(events.VIEW_NEW, function()
+ buffer.indic_fore[M.INDIC_HIGHLIGHT] = not CURSES and 0x4D99E6 or 0x008080
+ buffer.indic_style[M.INDIC_HIGHLIGHT] = buffer.INDIC_ROUNDBOX
+ buffer.indic_alpha[M.INDIC_HIGHLIGHT] = 255
+ if not CURSES then buffer.indic_under[M.INDIC_HIGHLIGHT] = true end
+end)
---
-- Passes selected or all buffer text to string shell command *command* as
diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua
index e253a6c9..917cb7a5 100644
--- a/modules/textadept/run.lua
+++ b/modules/textadept/run.lua
@@ -10,9 +10,8 @@ local M = {}
-- extension.
--
-- [language modules]: _M.html#Compile.and.Run
--- @field ERROR_COLOR (string)
--- The name of the color in the current theme to mark a line containing a
--- recognized run or compile error.
+-- @field MARK_ERROR (number)
+-- The run or compile error marker number.
-- @field cwd (string, Read-only)
-- The working directory for the most recently executed compile or run
-- command.
@@ -35,7 +34,7 @@ local M = {}
-- * `output`: The string output from the command.
module('textadept.run')]]
-M.ERROR_COLOR = not CURSES and 'color.light_red' or 'color.red'
+M.MARK_ERROR = _SCINTILLA.next_marker_number()
-- Events.
events.COMPILE_OUTPUT, events.RUN_OUTPUT = 'compile_output', 'run_output'
@@ -99,8 +98,6 @@ local function get_error_details(message)
return nil
end
-local MARK_ERROR = _SCINTILLA.next_marker_number()
-
-- Prints the output from a run or compile command.
-- If the output is a recognized error message, mark it.
-- @param lexer The current lexer.
@@ -109,7 +106,7 @@ local function print_output(lexer, output)
ui.print(output)
if get_error_details(output) then
-- Current position is one line below the error due to ui.print()'s '\n'.
- buffer:marker_add(buffer.line_count - 2, MARK_ERROR)
+ buffer:marker_add(buffer.line_count - 2, M.MARK_ERROR)
end
end
@@ -220,9 +217,9 @@ function M.goto_error(line, next)
if not line and next ~= nil then
local f = buffer['marker_'..(next and 'next' or 'previous')]
line = f(buffer, buffer:line_from_position(buffer.current_pos) +
- (next and 1 or -1), 2^MARK_ERROR)
+ (next and 1 or -1), 2^M.MARK_ERROR)
if line == -1 then
- line = f(buffer, next and 0 or buffer.line_count, 2^MARK_ERROR)
+ line = f(buffer, next and 0 or buffer.line_count, 2^M.MARK_ERROR)
if line == -1 then if CURSES then view:goto_buffer(cur_buf) end return end
end
end
@@ -246,10 +243,9 @@ end)
local CURSES_MARK = buffer.SC_MARK_CHARACTER + string.byte(' ')
-- Sets view properties for error markers.
-local function set_error_properties()
- if CURSES then buffer:marker_define(MARK_ERROR, CURSES_MARK) end
- buffer.marker_back[MARK_ERROR] = buffer.property_int[M.ERROR_COLOR]
-end
-events.connect(events.VIEW_NEW, set_error_properties)
+events.connect(events.VIEW_NEW, function()
+ if CURSES then buffer:marker_define(M.MARK_ERROR, CURSES_MARK) end
+ buffer.marker_back[M.MARK_ERROR] = not CURSES and 0x8080CC or 0x000080
+end)
return M