mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 03:27:59 +01:00
add new Ctrl-^ mapping for selecting the alternate tab
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<pre>
|
<pre>
|
||||||
2007-07-02:
|
2007-07-02:
|
||||||
* version ???
|
* version ???
|
||||||
|
* Ctrl-^ mapping for selecting the alternate tab/buffer
|
||||||
* QuickMarks support (new commands :qmarks/:qmarkadd/:qmarkdel and
|
* QuickMarks support (new commands :qmarks/:qmarkadd/:qmarkdel and
|
||||||
mappings go{a-z}, gn{a-z} and M{a-z}
|
mappings go{a-z}, gn{a-z} and M{a-z}
|
||||||
* Multiline echo support
|
* Multiline echo support
|
||||||
|
|||||||
@@ -298,6 +298,32 @@ function Mappings() //{{{
|
|||||||
flags: Mappings.flags.COUNT
|
flags: Mappings.flags.COUNT
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ['<C-^>', '<C-6>'],
|
||||||
|
function (args) {
|
||||||
|
if (vimperator.tabs.getTab() == vimperator.tabs.alternate)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E23: No alternate page");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: this currently relies on v.tabs.index() returning the
|
||||||
|
// currently selected tab index when passed null
|
||||||
|
var index = vimperator.tabs.index(vimperator.tabs.alternate);
|
||||||
|
|
||||||
|
// TODO: since a tab close is more like a bdelete for us we
|
||||||
|
// should probably reopen the closed tab when a 'deleted'
|
||||||
|
// alternate is selected
|
||||||
|
if (index == -1)
|
||||||
|
vimperator.echoerr("E86: Buffer does not exist") // TODO: This should read "Buffer N does not exist"
|
||||||
|
else
|
||||||
|
vimperator.tabs.select(index);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
short_help: "Select the alternate tab",
|
||||||
|
usage: ['<C-^>'],
|
||||||
|
help: "The alternate tab is the last selected tab. This provides a quick method of toggling between two tabs."
|
||||||
|
}
|
||||||
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["m"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["m"],
|
||||||
function(mark) { vimperator.marks.add(mark) },
|
function(mark) { vimperator.marks.add(mark) },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -368,6 +368,7 @@ function Events() //{{{
|
|||||||
vimperator.statusline.updateTabCount();
|
vimperator.statusline.updateTabCount();
|
||||||
updateBufferList();
|
updateBufferList();
|
||||||
vimperator.setMode(); // trick to reshow the mode in the command line
|
vimperator.setMode(); // trick to reshow the mode in the command line
|
||||||
|
vimperator.tabs.updateSelectionHistory();
|
||||||
}, false);
|
}, false);
|
||||||
tabcontainer.addEventListener("TabClose", function(event) {
|
tabcontainer.addEventListener("TabClose", function(event) {
|
||||||
vimperator.statusline.updateTabCount()
|
vimperator.statusline.updateTabCount()
|
||||||
@@ -378,6 +379,7 @@ function Events() //{{{
|
|||||||
vimperator.statusline.updateTabCount();
|
vimperator.statusline.updateTabCount();
|
||||||
updateBufferList();
|
updateBufferList();
|
||||||
vimperator.setMode(); // trick to reshow the mode in the command line
|
vimperator.setMode(); // trick to reshow the mode in the command line
|
||||||
|
vimperator.tabs.updateSelectionHistory();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
// this adds an event which is is called on each page load, even if the
|
// this adds an event which is is called on each page load, even if the
|
||||||
@@ -910,6 +912,8 @@ function Tabs() //{{{
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var alternates = [null, null];
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
@@ -929,6 +933,7 @@ function Tabs() //{{{
|
|||||||
|
|
||||||
return getBrowser().tabContainer.selectedIndex;
|
return getBrowser().tabContainer.selectedIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.count = function()
|
this.count = function()
|
||||||
{
|
{
|
||||||
return getBrowser().mTabs.length;
|
return getBrowser().mTabs.length;
|
||||||
@@ -1003,6 +1008,19 @@ function Tabs() //{{{
|
|||||||
}
|
}
|
||||||
getBrowser().mTabContainer.selectedIndex = index;
|
getBrowser().mTabContainer.selectedIndex = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: when restarting a session FF selects the first tab and then the
|
||||||
|
// tab that was selected when the session was created. As a result the
|
||||||
|
// alternate after a restart is often incorrectly tab 1 when there
|
||||||
|
// shouldn't be one yet.
|
||||||
|
this.updateSelectionHistory = function()
|
||||||
|
{
|
||||||
|
alternates = [this.getTab(), alternates[0]];
|
||||||
|
this.alternate = alternates[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.alternate = this.getTab();
|
||||||
|
|
||||||
//}}}
|
//}}}
|
||||||
} //}}}
|
} //}}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user