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/lua/api | 3 ++- modules/lua/tags | 3 ++- modules/textadept/bookmarks.lua | 15 +++++++++++++++ modules/textadept/menu.lua | 1 + 4 files changed, 20 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/lua/api b/modules/lua/api index 330106e9..f7f3b765 100644 --- a/modules/lua/api +++ b/modules/lua/api @@ -54,6 +54,7 @@ new _m.textadept.adeptsense.new(lang)\nCreates a new adeptsense for the given le show_apidoc _m.textadept.adeptsense.show_apidoc(sense)\nShows a calltip with API documentation for the symbol behind the caret.\n@param The adeptsense returned by adeptsense.new().\n@return true on success or false.\n@see get_symbol\n@see get_apidoc\n add _m.textadept.bookmarks.add()\nAdds a bookmark to the current line.\n clear _m.textadept.bookmarks.clear()\nClears all bookmarks in the current buffer.\n +goto _m.textadept.bookmarks.goto()\nGoes to selected bookmark from a filtered list.\n goto_next _m.textadept.bookmarks.goto_next()\nGoes to the next bookmark in the current buffer.\n goto_prev _m.textadept.bookmarks.goto_prev()\nGoes to the previous bookmark in the current buffer.\n remove _m.textadept.bookmarks.remove()\nClears the bookmark at the current line.\n @@ -532,4 +533,4 @@ concat table.concat(table [, sep [, i [, j]]])\nGiven an array where all element insert table.insert(table, [pos, ] value)\nInserts element `value` at position `pos` in `table`, shifting up other\nelements to open space, if necessary. The default value for `pos` is\n`n+1`, where `n` is the length of the table (see ยง2.5.5), so that a call\n`table.insert(t,x)` inserts `x` at the end of table `t`.\n maxn table.maxn(table)\nReturns the largest positive numerical index of the given table, or zero if\nthe table has no positive numerical indices. (To do its job this function\ndoes a linear traversal of the whole table.)\n remove table.remove(table [, pos])\nRemoves from `table` the element at position `pos`, shifting down other\nelements to close the space, if necessary. Returns the value of the removed\nelement. The default value for `pos` is `n`, where `n` is the length of the\ntable, so that a call `table.remove(t)` removes the last element of table `t`.\n -sort table.sort(table [, comp])\nSorts table elements in a given order, *in-place*, from `table[1]` to\n`table[n]`, where `n` is the length of the table. If `comp` is given, then it\nmust be a function that receives two table elements, and returns true when\nthe first is less than the second (so that `not comp(a[i+1],a[i])` will be\ntrue after the sort). If `comp` is not given, then the standard Lua operator\n``io.lines`, this function does not close the file when the loop ends.)\n +sort table.sort(table [, comp])\nSorts table elements in a given order, *in-place*, from `table[1]` to\n`table[n]`, where `n` is the length of the table. If `comp` is given, then it\nmust be a function that receives two table elements, and returns true when\nthe first is less than the second (so that `not comp(a[i+1],a[i])` will be\ntrue after the sort). If `comp` is not given, then the standard Lua operator\n``io.lines`, this function does not close the file when the loop ends.)\n \ No newline at end of file diff --git a/modules/lua/tags b/modules/lua/tags index db3a67c8..140fb0be 100644 --- a/modules/lua/tags +++ b/modules/lua/tags @@ -164,6 +164,7 @@ _m.textadept.bookmarks _ 0;" m bookmarks _ 0;" t class:_m.textadept add _ 0;" f class:_m.textadept.bookmarks clear _ 0;" f class:_m.textadept.bookmarks +goto _ 0;" f class:_m.textadept.bookmarks goto_next _ 0;" f class:_m.textadept.bookmarks goto_prev _ 0;" f class:_m.textadept.bookmarks remove _ 0;" f class:_m.textadept.bookmarks @@ -1026,4 +1027,4 @@ concat _ 0;" f class:table insert _ 0;" f class:table maxn _ 0;" f class:table remove _ 0;" f class:table -sort _ 0;" f class:table +sort _ 0;" f class:table \ No newline at end of file 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) diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua index a183996c..e3ef2576 100644 --- a/modules/textadept/menu.lua +++ b/modules/textadept/menu.lua @@ -210,6 +210,7 @@ menubar = { { L('_Clear All'), { m_bookmarks.clear } }, { L('_Next'), { m_bookmarks.goto_next } }, { L('_Previous'), { m_bookmarks.goto_prev } }, + { L('_Goto Bookmark...'), { m_bookmarks.goto } }, }, { title = L('Snap_open'), { L('_User Home'), { m_snapopen.open, _USERHOME } }, -- cgit v1.2.3