1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 04:07:58 +01:00

moved v.buffer.switchTo to v.tabs.switchTo

This commit is contained in:
Martin Stubenschrott
2008-02-12 18:28:07 +00:00
parent fec955dcb2
commit d1560b0cfb
3 changed files with 89 additions and 92 deletions

View File

@@ -32,9 +32,6 @@ vimperator.Buffer = function () //{{{
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
// used for the "B" mapping to remember the last :buffer[!] command
var lastBufferSwitchArgs = "";
var lastBufferSwitchSpecial = true;
var zoomLevels = [ 1, 10, 25, 50, 75, 90, 100,
120, 150, 200, 300, 500, 1000, 2000 ];
@@ -638,76 +635,6 @@ vimperator.Buffer = function () //{{{
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
},
// TODO: move to v.tabs.?
// "buffer" is a string which matches the URL or title of a buffer, if it
// is null, the last used string is used again
switchTo: function (buffer, allowNonUnique, count, reverse)
{
if (buffer == "")
{
return;
}
else if (buffer != null)
{
// store this command, so it can be repeated with "B"
lastBufferSwitchArgs = buffer;
lastBufferSwitchSpecial = allowNonUnique;
}
else
{
buffer = lastBufferSwitchArgs;
if (typeof allowNonUnique == "undefined" || allowNonUnique == null)
allowNonUnique = lastBufferSwitchSpecial;
}
if (!count || count < 1)
count = 1;
if (typeof reverse != "boolean")
reverse = false;
var match;
if (match = buffer.match(/^(\d+):?/))
{
vimperator.tabs.select(parseInt(match[1], 10) - 1, false); // make it zero-based
return;
}
var matches = [];
var lowerBuffer = buffer.toLowerCase();
var first = vimperator.tabs.index() + (reverse ? 0 : 1);
for (var i = 0; i < getBrowser().browsers.length; i++)
{
var index = (i + first) % getBrowser().browsers.length;
var url = getBrowser().getBrowserAtIndex(index).contentDocument.location.href;
var title = getBrowser().getBrowserAtIndex(index).contentDocument.title.toLowerCase();
if (url == buffer)
{
vimperator.tabs.select(index, false);
return;
}
if (url.indexOf(buffer) >= 0 || title.indexOf(lowerBuffer) >= 0)
matches.push(index);
}
if (matches.length == 0)
vimperator.echoerr("E94: No matching buffer for " + buffer);
else if (matches.length > 1 && !allowNonUnique)
vimperator.echoerr("E93: More than one match for " + buffer);
else
{
if (reverse)
{
index = matches.length - count;
while (index < 0)
index += matches.length;
}
else
index = (count - 1) % matches.length;
vimperator.tabs.select(matches[index], false);
}
},
zoomIn: function (steps, fullZoom)
{
bumpZoomLevel(steps, fullZoom);