Re: [code] [textadept] Reorder tabs

From: Qwerky <mr.qwerky.att.gmail.com>
Date: Fri, 28 Jun 2019 16:26:59 -0600

On 2019-06-28 13:59, Robert Gieseke wrote:
> Am 28.06.19 um 21:37 schrieb Qwerky:
>>> So, that's what you probably would need to automate, have a shortcut,
>>> that moves a tab/buffer left or right by manipulating a session object
>>> or list of buffers and re-opening ...
>> Is that doable with textadept?  I'm not very familiar with Lua, nor yet
>> very experienced with textadept, but would be willing make an attempt,
>> with a little help.  :-)
> So, here is a quick proof of concept of moving the last buffer/tab to
> the first position by closing and re-opening all buffers, should work
> from your `init.lua`:
>
>
> -- Ctrl-5
> keys.c5 = function()
> local original_tabs = {}
> for i = 1, #_BUFFERS do
> local buffer = _BUFFERS[i]
> local filename = buffer.filename or buffer._type
> original_tabs[#original_tabs + 1] = filename
> view:goto_buffer(buffer)
> end
> io.close_all_buffers()
> io.open_file(original_tabs[#original_tabs])
> for i = 1, #original_tabs - 1 do
> io.open_file(original_tabs[i])
> end
> end
>
> This doesn't do a lot of things, keep cursor positions or properly
> recover message buffers etc. Could likely be done based on the code in
> Textadept's `session.lua`. Basically merging the save and load session
> function from it with a order manipulation step in between.
>
> Cheers,
> Robert

Your code seems clear enough.  But following your comment, I had a look
at "session.lua",  comparing it to the actual session file--and I see
that there is a lot going on there!  To properly keep everything intact
would, I think, require a lot more than I am presently capable of with Lua.

Though I'm sure Mitchell would have no problem with it, if he thought
that this was a proper approach to reordering the buffers.

Perhaps another approach might be to have the actual GUI tabs simply be
a list of pointers to the correct buffers, so that reordering the tabs
list itself would have no effect on the buffers, as each tab would 
continue to point to its original buffer?  Thus the buffers could be 1,
2, 3, 4; while the tabs could be 2, 1, 4, 3, with each pointing to its
own buffer?

qwerky

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Fri 28 Jun 2019 - 18:26:59 EDT

This archive was generated by hypermail 2.2.0 : Sat 29 Jun 2019 - 06:42:15 EDT