/extman/scite_lua/switch_buffers.lua

http://github.com/davidm/lua-inspect · Lua · 31 lines · 23 code · 5 blank · 3 comment · 5 complexity · 5b11bcb8adb3dc2fec776ca90de609fd MD5 · raw file

  1. --switch_buffers.lua
  2. --drops down a list of buffers, in recently-used order
  3. scite_Command 'Switch Buffer|do_buffer_list|Alt+F12'
  4. scite_Command 'Last Buffer|last_buffer|Ctrl+F12'
  5. local buffers = {}
  6. scite_OnOpenSwitch(function(f)
  7. --- swop the new current buffer with the last one!
  8. local idx
  9. for i,file in ipairs(buffers) do
  10. if file == f then idx = i; break end
  11. end
  12. if idx then
  13. table.remove(buffers,idx)
  14. table.insert(buffers,1,f)
  15. else
  16. table.insert(buffers,1,f)
  17. end
  18. end)
  19. function last_buffer()
  20. if table.getn(buffers) > 1 then
  21. scite.Open(buffers[2])
  22. end
  23. end
  24. function do_buffer_list()
  25. scite_UserListShow(buffers,2,scite.Open)
  26. end