Re: [textadept] Re: buffer list

From: mitchell <c....at.caladbolg.net>
Date: Sun, 12 Dec 2010 22:14:32 -0500 (EST)

Hi Scott,

> This is what I've got so far:
>
> keys.ck = { function ()
> local buffer = buffer
> local events = events
> local items = {}
> for _, buffer in ipairs(_BUFFERS) do
> local filename = buffer.filename or buffer._type or 'UNTITLED'
> local dirty = buffer.dirty and '* ' or ''
> table.insert(items, 1, dirty .. filename)
> -- items[#items + 1] = dirty .. filename
> buffer:user_list_show(1, table.concat(items, '|'))
> end
> file_select = events.connect('user_list_selection', function(type,
> text)
> events.disconnect('user_list_selection', file_select)
> end, 1)
> end }
>
> I hacked this together from code I saw in the core TA files, but was
> having trouble understanding some of it.
>
> Also, the user_list_show function takes a parameter, type, which I
> have no idea what it means.

type is just an integer that identifies the list type. Use a number not
used internally (greater than 10 is good I think) because when a user list
selection is made, all user_list_selection event handlers are called. 1 is
used for the recent file list. There is also no need to disconnect your
event handler.

local my_type = 10
events.connect('user_list_selection', function(type, text)
   if type == 10 then
     -- do stuff with text
   end
end)
buffer:user_list_show(my_type, ...)

> I hope I am not being too bothersome. TA is actually the first editor
> I've used that I really want to customize to my liking. I always felt
> that something like Vim or or Emacs were just too much for me, and
> Scite, which I did customize a bit, was too limited.

You're not bothersome at all. That is what this mailing list is for!

mitchell

>
> Scott
>
> On Dec 10, 3:59�pm, mitchell <c....at.caladbolg.net> wrote:
>> Scott,
>>
>>> Instead of using a dialog, what about some sort popup, like used for
>>> name completion? Is it possible to use something like that to instead
>>> popup a buffer selection list?
>>
>> Yes. Use buffer:user_list_show() and handle the selection with
>> events.connect('user_list_selection', ...)
>
> --
> You received this message because you are subscribed to the Google Groups "textadept" group.
> To post to this group, send email to textadept.at.googlegroups.com.
> To unsubscribe from this group, send email to textadept+unsubscribe.at.googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/textadept?hl=en.
>
>

mitchell
Received on Sun 12 Dec 2010 - 22:14:32 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:55:58 EST