buffer list as tooltip

From: morchel <morc....at.hotmail.com>
Date: Sun, 14 Jun 2009 15:38:51 -0700 (PDT)

Alt-o is mapped to a tooltip-list of recent files. What I would need
more often is a tooltip-list of all buffers.
In textadept/core/ext/key_commands.lua I edited the -- Miscellaneous
not in standard menu.' part like so:

  -- Miscellaneous not in standard menu.
  -- Recent files, buffer files as select list --
  local RECENT_FILES = 1
  local BUFFER_FILES = 2
  t.events.add_handler('user_list_selection',
    function(type, text)
      if type == RECENT_FILES then t.io.open(text)
      elseif type == BUFFER_FILES then
        local index = text:match('(%d+): ')
        --print(index)
        local buffer = textadept.buffers[tonumber(index)]
        if buffer then
          view:goto_buffer(index)
          view:focus()
        end
      end
    end)
  keys.ao = {
    function()
      local buffer = buffer
      local files = {}
      for index, b in ipairs(textadept.buffers) do
        --text = (b.filename or b._type or locale.UNTITLED):match('[^/\
\]+$')
        text = (b.filename or b._type or locale.UNTITLED)
        table.insert(files, 1, index..': '..text)
       end
      local sep = buffer.auto_c_separator
      buffer.auto_c_separator = ('|'):byte()
      table.sort(files)
      buffer:user_list_show(BUFFER_FILES, table.concat(files, '|'))
      buffer.auto_c_separator = sep
    end
  }
  keys.sao = {
    function()
      local buffer = buffer
      local files = {}
      for _, filename in ipairs(t.io.recent_files) do
        table.insert(files, 1, filename)
      end
      local sep = buffer.auto_c_separator
      buffer.auto_c_separator = ('|'):byte()
      buffer:user_list_show(RECENT_FILES, table.concat(files, '|'))
      buffer.auto_c_separator = sep
    end
  }

Now I have a tooltip list of all buffers mapped to Alt-o and the
recent files list mapped to Shift-Alt-o.

The ta version I use is 1.6.

Just in case somebody finds that useful. No warranties, of course.
Received on Sun 14 Jun 2009 - 18:38:51 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:38:05 EST