aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/bookmarks.lua
diff options
context:
space:
mode:
Diffstat (limited to 'modules/textadept/bookmarks.lua')
-rw-r--r--modules/textadept/bookmarks.lua31
1 files changed, 14 insertions, 17 deletions
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