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