Reorder tabs or buffers

View: New views
4 Messages — Rating Filter:   Alert me  

Reorder tabs or buffers

by Daniel Clemente-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


  Hi, I would like to move a tab (from new-tabs.js) one position to the left or to the right. Maybe it's easier to change the order of the buffers, not the tabs, so that C-x b (switch_to_buffer) shows also the new order.

  With my limited knowledge of Conkeror internals, I did this first proof of concept. The right solution is probably much easier. Feel free to change this code, to ignore it, to include a corrected version in Conkeror, or to  send me critiques about what I did wrong.

-- Daniel



// This tries to move the current tab 1 position to the left
// It is just a proof of concept but it's not usable: the tab is moved, but buffer_next() and buffer_previous() still use the old order. In addition it only works the first time. C-x b is not affected
// 16.m4.2009 Daniel Clemente
function test_move_tab_left(window) {

    // Get the tab bar
    var tabbar = window.tab_bar;
    tabbar.update_multiple_attribute(); //¿?

    var bcurrent=window.buffers.current;
    var index = window.buffers.selected_index;

    if (index==0) {return;}
    var bprevious=window.buffers.get_buffer(index-1);


    // remove it from its position
    tabbar.element.removeChild(bcurrent.tab);

    // and place it before the tab which was at our left
    tabbar.element.insertBefore(bcurrent.tab,bprevious.tab);

    // Renumber the tabs.
    for (var i = 0; i < tabbar.element.childNodes.length; i++) {
        tabbar.element.childNodes[i].childNodes[0].value = i + 1;
    }

    // TODO: make sure that the "next" buffer for each tab points to really the tab at the right, so that next_buffer/previous_buffer work


    // we changed the tabs, not the buffers
    // TODO: maybe change the internal buffer ordering too

    // this doesn't seem to work: C-x b doesn't show this
    var bs=window.buffers;
    var bl=bs.buffer_list;

    // I delete [bprevious,bcurrent] and I put [bcurrent,previous]
    bl.splice(index-1,2, bcurrent,bprevious);

    // still focus the original tab
    bs.current=bcurrent;



    // debug (to know that it ended)
    window.minibuffer.show(bl.length);
    return true;
 
}

interactive("test-move-tab-left", "Tries to move the current tab one position to the left. But FAILS", function(I) {test_move_tab_left(I.window); });
define_key(content_buffer_normal_keymap, "M-c", "test-move-tab-left");



_______________________________________________
Conkeror mailing list
Conkeror@...
https://www.mozdev.org/mailman/listinfo/conkeror

Re: Reorder tabs or buffers

by Jeremy Maitin-Shepard-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Daniel Clemente <dcl441-bugs@...> writes:

>   Hi, I would like to move a tab (from new-tabs.js) one position to the left or
> to the right. Maybe it's easier to change the order of the buffers, not the
> tabs, so that C-x b (switch_to_buffer) shows also the new order.

>   With my limited knowledge of Conkeror internals, I did this first proof of
> concept. The right solution is probably much easier. Feel free to change this
> code, to ignore it, to include a corrected version in Conkeror, or to send me
> critiques about what I did wrong.

This could be done entirely within the tab bar module as you do it now,
and you could simply have the tab bar redefine the key commands for
moving to the next or previous buffer to respect that order.  However,
that is probably not the best approach.

Note that the buffer_list variable is currently used to maintain the
order of most recent use of the buffers such that the most recently
accessed buffer can be provided as a default for certain commands like
switch-to-buffer.  That order is never displayed, and is modified only
by bury-buffer and by switching buffers.

Currently the "canonical" buffer ordering is the order in which the
buffers were created (and represented by the order of xul:browser nodes
in the chrome document).  If you want to be able to reorder buffers, I
believe the correct approach is to create a new array of buffers like
buffer_list, add appropriate code to keep that updated and functions for
rearranging buffers, add appropriate hooks to notify modules like the
tab bar about buffer rearrangement, add code to the tab bar to handle
buffer rearrangement, and add key commands or perhaps mouse commands to
the tab bar to perform buffer rearrangement.

Note that an additional buffer list as an array is needed because it is
not possible to rearrange xul:browser nodes in the chrome document once
they are added to it.  (Any attempt to do so will result in the "state"
of the corresponding buffer being lost, the state being the current page
loaded and all of the history.)

Nick was also interested in implementing this, so you may want to try to
coordinate with him.

--
Jeremy Maitin-Shepard
_______________________________________________
Conkeror mailing list
Conkeror@...
https://www.mozdev.org/mailman/listinfo/conkeror

Parent Message unknown Re: Reorder tabs or buffers

by Nicholas A. Zigarovich-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yeah I read that part of your email after I wrote this. gmail flaked
out and told me this message wasn't sent, so I discarded it, but I
guess it was sent. Sorry for the confusion.

On Thu, Apr 16, 2009 at 5:09 PM, Jeremy Maitin-Shepard
<jeremy@...> wrote:

> "Nicholas A. Zigarovich" <nicktastic@...> writes:
>
>> afaik, the buffer container is window.buffers.container. I would think
>> that the order of its children could be changed - pop out the child
>> element and reinsert it. Would that not work?
>
> We already discussed on IRC (and it is also mentioned in the e-mail) why
> this doesn't work.
>
> --
> Jeremy Maitin-Shepard
>
_______________________________________________
Conkeror mailing list
Conkeror@...
https://www.mozdev.org/mailman/listinfo/conkeror

Re: Reorder tabs or buffers

by Daniel Clemente-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

El dj, abr 16 2009, Jeremy Maitin-Shepard va escriure:
> If you want to be able to reorder buffers, I
> believe the correct approach is to create a new array of buffers like
> buffer_list, add appropriate code to keep that updated and functions for
> rearranging buffers, add appropriate hooks to notify modules like the
> tab bar about buffer rearrangement, add code to the tab bar to handle
> buffer rearrangement, and add key commands or perhaps mouse commands to
> the tab bar to perform buffer rearrangement.

  Since this seems not trivial, I have filed a bug about this wish:
http://bugs.conkeror.org/issue151


  I don't plan to work on this in the near future, but maybe later, when I have more practice with Conkeror.
  Thanks for explaining the direction to follow.

--Daniel

_______________________________________________
Conkeror mailing list
Conkeror@...
https://www.mozdev.org/mailman/listinfo/conkeror