mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 15:48:00 +01:00
added intelligent :buffer selection
This commit is contained in:
1
NEWS
1
NEWS
@@ -2,6 +2,7 @@
|
|||||||
2007-xx-xx:
|
2007-xx-xx:
|
||||||
* version 0.6
|
* version 0.6
|
||||||
* THIS VERSION ONLY WORKS WITH FIREFOX 3.0
|
* THIS VERSION ONLY WORKS WITH FIREFOX 3.0
|
||||||
|
* :buffer partial_string works now as in vim, and with ! even better
|
||||||
* new :time command for profiling
|
* new :time command for profiling
|
||||||
* added new :sidebar and :sbclose commands
|
* added new :sidebar and :sbclose commands
|
||||||
* added 'more' and standard more-prompt key mappings to control
|
* added 'more' and standard more-prompt key mappings to control
|
||||||
|
|||||||
@@ -318,22 +318,40 @@ function Commands() //{{{
|
|||||||
));
|
));
|
||||||
addDefaultCommand(new Command(["b[uffer]"],
|
addDefaultCommand(new Command(["b[uffer]"],
|
||||||
// TODO: move to v.tabs/buffers
|
// TODO: move to v.tabs/buffers
|
||||||
function(args)
|
function(args, special)
|
||||||
{
|
{
|
||||||
var match;
|
var match;
|
||||||
if (match = args.match(/^(\d+):?/))
|
if (match = args.match(/^(\d+):?/))
|
||||||
return vimperator.tabs.select(parseInt(match[1]) - 1, false); // make it zero-based
|
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++)
|
for (var i = 0; i < getBrowser().browsers.length; i++)
|
||||||
{
|
{
|
||||||
var url = getBrowser().getBrowserAtIndex(i).contentDocument.location.href;
|
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)
|
if (url == args)
|
||||||
return vimperator.tabs.select(i, false);
|
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);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
usage: ["b[uffer] {url|index}"],
|
usage: ["b[uffer][!] {url|index}"],
|
||||||
short_help: "Go to buffer from buffer list",
|
short_help: "Go to buffer from buffer list",
|
||||||
help: "Argument can be either the buffer index or the full URL.<br/>" +
|
help: "Argument can be either the buffer index or the full URL.<br/>" +
|
||||||
|
"If argument is neither a full URL nor an index but uniquely identifies a buffer, " +
|
||||||
|
"it is selected. With <code class=\"argument\">[!]</code> the next buffer matching the argument " +
|
||||||
|
"is selected, even if it cannot be identified uniquely.<br/>" +
|
||||||
"Use <code class=\"mapping\">b</code> as a shortcut to open this prompt.",
|
"Use <code class=\"mapping\">b</code> as a shortcut to open this prompt.",
|
||||||
completer: function(filter) { return vimperator.completion.get_buffer_completions(filter); }
|
completer: function(filter) { return vimperator.completion.get_buffer_completions(filter); }
|
||||||
}
|
}
|
||||||
@@ -1324,25 +1342,25 @@ function Commands() //{{{
|
|||||||
var after_time = Date.now();
|
var after_time = Date.now();
|
||||||
|
|
||||||
if ((after_time - before_time) / count >= 100)
|
if ((after_time - before_time) / count >= 100)
|
||||||
var each = " Each time: <span style=\"color: green\">" +
|
var each = " Each time: <span style=\"color: green\">" +
|
||||||
((after_time - before_time) / 1000.0 / count) +
|
((after_time - before_time) / 1000.0 / count) +
|
||||||
"</span> sec<br/>";
|
"</span> sec<br/>";
|
||||||
else
|
else
|
||||||
var each = " Each time: <span style=\"color: green\">" +
|
var each = " Each time: <span style=\"color: green\">" +
|
||||||
((after_time - before_time) / count) +
|
((after_time - before_time) / count) +
|
||||||
"</span> msec<br/>";
|
"</span> msec<br/>";
|
||||||
|
|
||||||
if (after_time - before_time >= 100)
|
if (after_time - before_time >= 100)
|
||||||
var total = " Total time: <span style=\"color: red\">" +
|
var total = " Total time: <span style=\"color: red\">" +
|
||||||
((after_time - before_time) / 1000.0) +
|
((after_time - before_time) / 1000.0) +
|
||||||
"</span> sec</pre>";
|
"</span> sec";
|
||||||
else
|
else
|
||||||
var total = " Total time: <span style=\"color: red\">" +
|
var total = " Total time: <span style=\"color: red\">" +
|
||||||
(after_time - before_time) + "</span> msec</pre>";
|
(after_time - before_time) + "</span> msec";
|
||||||
|
|
||||||
|
|
||||||
vimperator.echo("<pre><span style=\"color: magenta; font-weight: bold\">Code execution summary</span>:<br/>" +
|
vimperator.echo("<span style=\"color: magenta; font-weight: bold\">Code execution summary</span>:<br/>" +
|
||||||
" Executed: <span style=\"color: green\">" + count + "</span> times<br/>" + each + total);
|
" Executed: <span style=\"color: green\">" + count + "</span> times<br/>" + each + total);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -566,8 +566,11 @@ function Events() //{{{
|
|||||||
|
|
||||||
// XXX: ugly hack for now pass certain keys to firefox as they are without beeping
|
// XXX: ugly hack for now pass certain keys to firefox as they are without beeping
|
||||||
// also fixes key navigation in combo boxes, etc.
|
// also fixes key navigation in combo boxes, etc.
|
||||||
if (key == "<Tab>" || key == "<S-Tab>")// || key == "<Return>" || key == "<Space>" || key == "<Up>" || key == "<Down>")
|
if (vimperator.mode == vimperator.modes.NORMAL)
|
||||||
|
{
|
||||||
|
if (key == "<Tab>" || key == "<S-Tab>" || key == "<Return>" || key == "<Space>" || key == "<Up>" || key == "<Down>")
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// // FIXME: handle middle click in content area {{{
|
// // FIXME: handle middle click in content area {{{
|
||||||
|
|||||||
Reference in New Issue
Block a user