diff options
author | 2010-03-10 12:54:18 -0500 | |
---|---|---|
committer | 2010-03-10 12:54:18 -0500 | |
commit | 87e5433dd9e4e054147c7b234b9d80a6c9e0db7d (patch) | |
tree | 82100784be5d0e6b3fda2143f936049b7eb2ede3 /core/init.lua | |
parent | 2d4c5b2cd9e7720d479b9d4ba1db805dad8b97bf (diff) | |
download | textadept-87e5433dd9e4e054147c7b234b9d80a6c9e0db7d.tar.gz textadept-87e5433dd9e4e054147c7b234b9d80a6c9e0db7d.zip |
Added textadept.buffer_switch() to replace side pane's buffer browser.
Diffstat (limited to 'core/init.lua')
-rw-r--r-- | core/init.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/init.lua b/core/init.lua index bb09a441..b55a3f04 100644 --- a/core/init.lua +++ b/core/init.lua @@ -78,3 +78,24 @@ end -- LuaDoc is in core/.textadept.lua. function textadept.print(...) textadept._print(locale.MESSAGE_BUFFER, ...) end + +-- LuaDoc is in core/.textadept.lua. +function textadept.switch_buffer() + local items = {} + for _, buffer in ipairs(textadept.buffers) do + local filename = buffer.filename or buffer._type or locale.UNTITLED + local dirty = buffer.dirty and '*' or '' + items[#items + 1] = dirty..filename:match('[^/\\]+$') + items[#items + 1] = filename + end + local out = + textadept.dialog('filteredlist', + '--title', locale.SWITCH_BUFFERS, + '--button1', 'gtk-ok', + '--button2', 'gtk-cancel', + '--no-newline', + '--columns', 'Name', 'File', + '--items', unpack(items)) + local i = tonumber(out:match('%-?%d+$')) + if i and i >= 0 then view:goto_buffer(i + 1, true) end +end |