From 2247eeb38c71da492cb96711e133b353e7c3129d Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Wed, 19 Jan 2011 23:11:40 -0500 Subject: Can navigate between bookmarks with a filteredlist. --- modules/textadept/bookmarks.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'modules/textadept/bookmarks.lua') diff --git a/modules/textadept/bookmarks.lua b/modules/textadept/bookmarks.lua index d7efb467..072cca67 100644 --- a/modules/textadept/bookmarks.lua +++ b/modules/textadept/bookmarks.lua @@ -73,6 +73,21 @@ function goto_prev() if line >= 0 then _m.textadept.editing.goto_line(line + 1) end end +--- +-- Goes to selected bookmark from a filtered list. +function goto() + local buffer = buffer + local markers, line = {}, buffer:marker_next(0, 2^MARK_BOOKMARK) + if line == -1 then return end + repeat + local text = buffer:get_line(line):sub(1, -2) -- chop \n + markers[#markers + 1] = table.concat({ line + 1, text }, ': ') + line = buffer:marker_next(line + 1, 2^MARK_BOOKMARK) + until line < 0 + local line = gui.filteredlist(L('Select Bookmark'), 'Bookmark', markers) + if line then _m.textadept.editing.goto_line(tonumber(line:match('^%d+'))) end +end + if buffer then buffer:marker_set_back(MARK_BOOKMARK, MARK_BOOKMARK_COLOR) end events.connect('view_new', function() buffer:marker_set_back(MARK_BOOKMARK, MARK_BOOKMARK_COLOR) end) -- cgit v1.2.3