aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2008-06-24 18:43:59 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2008-06-24 18:43:59 -0400
commit08db1fe758f320cc1575ae980cb30ceff1c60dad (patch)
treeccc43d59ab8d07fc2e2f73d5f8d92f12089d1764 /modules/textadept
parent45a1f776e3c8432003e7b54432c0cbf45ec84259 (diff)
downloadtextadept-08db1fe758f320cc1575ae980cb30ceff1c60dad.tar.gz
textadept-08db1fe758f320cc1575ae980cb30ceff1c60dad.zip
Added _m.textadept.bookmarks module; modules/textadept/bookmarks.lua
Diffstat (limited to 'modules/textadept')
-rw-r--r--modules/textadept/bookmarks.lua62
1 files changed, 62 insertions, 0 deletions
diff --git a/modules/textadept/bookmarks.lua b/modules/textadept/bookmarks.lua
new file mode 100644
index 00000000..334ed626
--- /dev/null
+++ b/modules/textadept/bookmarks.lua
@@ -0,0 +1,62 @@
+-- Copyright 2007-2008 Mitchell mitchell<att>caladbolg.net. See LICENSE.
+
+---
+-- Bookmarks for the textadept module.
+-- There are several option variables used:
+-- MARK_BOOKMARK: The integer mark used to identify a bookmarked line.
+-- MARK_BOOKMARK_COLOR: The Scintilla color used for a bookmarked line.
+module('_m.textadept.bookmarks', package.seeall)
+
+-- options
+local MARK_BOOKMARK = 0
+local MARK_BOOKMARK_COLOR = 0xC08040
+-- end options
+
+---
+-- Adds a bookmark to the current line.
+function add()
+ local buffer = buffer
+ buffer:marker_set_back(MARK_BOOKMARK, MARK_BOOKMARK_COLOR)
+ local line = buffer:line_from_position(buffer.current_pos)
+ buffer:marker_add(line, MARK_BOOKMARK)
+end
+
+---
+-- Clears the bookmark at the current line.
+function remove()
+ local buffer = buffer
+ local line = buffer:line_from_position(buffer.current_pos)
+ buffer:marker_delete(line, MARK_BOOKMARK)
+end
+
+---
+-- Toggles a bookmark on the current line.
+function toggle()
+ local buffer = buffer
+ local line = buffer:line_from_position(buffer.current_pos)
+ local markers = buffer:marker_get(line) -- bit mask
+ if markers % 2 == 0 then add() else remove() end -- first bit is set?
+end
+
+---
+-- Clears all bookmarks in the current buffer.
+function clear()
+ local buffer = buffer
+ buffer:marker_delete_all(MARK_BOOKMARK)
+end
+
+---
+-- Goes to the next bookmark in the current buffer.
+function goto_next()
+ local current_line = buffer:line_from_position(buffer.current_pos)
+ local line = buffer:marker_next(current_line, 1)
+ if line >= 0 then _m.textadept.editing.goto_line(line + 1) end
+end
+
+---
+-- Goes to the previous bookmark in the current buffer.
+function goto_prev()
+ local current_line = buffer:line_from_position(buffer.current_pos)
+ local line = buffer:marker_previous(current_line, 1)
+ if line >= 0 then _m.textadept.editing.goto_line(line + 1) end
+end