mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 13:37:58 +01:00
new gb and gB commands
This commit is contained in:
1
NEWS
1
NEWS
@@ -2,6 +2,7 @@
|
||||
2007-xx-xx:
|
||||
* version 0.6
|
||||
* THIS VERSION ONLY WORKS WITH FIREFOX 3.0
|
||||
* new gb and gB mappings to repeat the last :buffer[!] command,
|
||||
* :ls, :history and :bmarks output is now hyperlinked
|
||||
* tags and keyword support for :bmark
|
||||
* added full zoom, and changed keybindings slightly for text zoom
|
||||
|
||||
@@ -31,6 +31,9 @@ function Buffer() //{{{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
// used for the "B" mapping to remember the last :buffer[!] command
|
||||
var lastBufferSwitchArgs = "";
|
||||
var lastBufferSwitchSpecial = true;
|
||||
|
||||
var zoom_levels = [ 1, 10, 25, 50, 75, 90, 100,
|
||||
120, 150, 200, 300, 500, 1000, 2000 ];
|
||||
@@ -124,6 +127,8 @@ function Buffer() //{{{
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
this.lastInputField = null; // used to keep track of the right field for "gi"
|
||||
|
||||
|
||||
this.__defineGetter__("URL", function()
|
||||
{
|
||||
@@ -160,8 +165,6 @@ function Buffer() //{{{
|
||||
return window.content.document.title;
|
||||
});
|
||||
|
||||
this.lastInputField = null; // used to keep track of the right field for "gi"
|
||||
|
||||
// returns an XPathResult object
|
||||
this.evaluateXPath = function(expression, doc, elem, ordered)
|
||||
{
|
||||
@@ -419,15 +422,75 @@ function Buffer() //{{{
|
||||
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
||||
}
|
||||
|
||||
// XXX: should this be in v.buffers. or 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
|
||||
this.switchTo = function(buffer, allowNonUnique, count, reverse)
|
||||
{
|
||||
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+):?/))
|
||||
return vimperator.tabs.select(parseInt(match[1]) - 1, false); // make it zero-based
|
||||
|
||||
var matches = [];
|
||||
var lower_buffer = 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)
|
||||
return vimperator.tabs.select(index, false);
|
||||
|
||||
if (url.indexOf(buffer) >= 0 || title.indexOf(lower_buffer) >= 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);
|
||||
}
|
||||
};
|
||||
|
||||
this.zoomIn = function(steps, full_zoom)
|
||||
{
|
||||
bumpZoomLevel(steps, full_zoom);
|
||||
}
|
||||
};
|
||||
|
||||
this.zoomOut = function(steps, full_zoom)
|
||||
{
|
||||
bumpZoomLevel(-steps, full_zoom);
|
||||
}
|
||||
};
|
||||
//}}}
|
||||
} //}}}
|
||||
|
||||
|
||||
@@ -587,34 +587,7 @@ function Commands() //{{{
|
||||
}
|
||||
));
|
||||
addDefaultCommand(new Command(["b[uffer]"],
|
||||
// TODO: move to v.tabs/buffers
|
||||
function(args, special)
|
||||
{
|
||||
var match;
|
||||
if (match = args.match(/^(\d+):?/))
|
||||
return vimperator.tabs.select(parseInt(match[1]) - 1, false); // make it zero-based
|
||||
|
||||
var matches = [];
|
||||
var lower_args = args.toLowerCase();
|
||||
var first = vimperator.tabs.index() + 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 == args)
|
||||
return vimperator.tabs.select(index, false);
|
||||
|
||||
if (url.indexOf(args) >= 0 || title.indexOf(lower_args) >= 0)
|
||||
matches.push(index);
|
||||
}
|
||||
if (matches.length == 0)
|
||||
vimperator.echoerr("E94: No matching buffer for " + args);
|
||||
else if (matches.length > 1 && !special)
|
||||
vimperator.echoerr("E93: More than one match for " + args);
|
||||
else
|
||||
vimperator.tabs.select(matches[0], false);
|
||||
},
|
||||
function(args, special) { vimperator.buffer.switchTo(args, special); },
|
||||
{
|
||||
usage: ["b[uffer][!] {url|index}"],
|
||||
short_help: "Go to buffer from buffer list",
|
||||
|
||||
@@ -419,6 +419,22 @@ function Mappings() //{{{
|
||||
"WARNING: This mapping may be removed/changed in future."
|
||||
}
|
||||
));
|
||||
addDefaultMap(new Map([vimperator.modes.NORMAL], ["gb"],
|
||||
function(count) { vimperator.buffer.switchTo(null, null, count, false); },
|
||||
{
|
||||
short_help: "Repeat last :buffer[!] command",
|
||||
help: "This is useful to quickly jump between buffers which have a similar URL or title.",
|
||||
flags: Mappings.flags.COUNT
|
||||
}
|
||||
));
|
||||
addDefaultMap(new Map([vimperator.modes.NORMAL], ["gB"],
|
||||
function(count) { vimperator.buffer.switchTo(null, null, count, true); },
|
||||
{
|
||||
short_help: "Repeat last :buffer[!] command in reverse direction",
|
||||
help: "Just like <code class=\"mapping\">gb</code> but in the other direction.",
|
||||
flags: Mappings.flags.COUNT
|
||||
}
|
||||
));
|
||||
addDefaultMap(new Map([vimperator.modes.NORMAL], ["d"],
|
||||
function(count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, false, 0); },
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user