1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-07 00:34:12 +01:00

Make :ba and :fo generally more consistent and less annoying.

This commit is contained in:
Kris Maglione
2009-07-15 14:31:29 -04:00
parent 379c6a2d71
commit 773814c985
2 changed files with 54 additions and 40 deletions

View File

@@ -294,10 +294,8 @@ function Bookmarks() //{{{
"Show jumplist", "Show jumplist",
function () function ()
{ {
let sh = window.getWebNavigation().sessionHistory; let sh = history.session;
let list = template.jumps(sh.index, sh);
let entries = [sh.getEntryAtIndex(i, false) for (i in util.range(0, sh.count))];
let list = template.jumps(sh.index, entries);
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE); commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
}, },
{ argCount: "0" }); { argCount: "0" });
@@ -843,15 +841,13 @@ function History() //{{{
{ {
if (url) if (url)
{ {
let sh = window.getWebNavigation().sessionHistory; let sh = history.session;
for (let i in util.range(sh.index, 0, -1)) if (/^\d+(:|$)/.test(url) && sh.index - parseInt(url) in sh)
{ return void window.getWebNavigation().gotoIndex(sh.index - parseInt(url));
if (sh.getEntryAtIndex(i, false).URI.spec == url)
{ for (let [i, ent] in Iterator(sh.slice(0, sh.index).reverse()))
window.getWebNavigation().gotoIndex(i); if (ent.URI.spec == url)
return; return void window.getWebNavigation().gotoIndex(i);
}
}
liberator.echoerr("Exxx: URL not found in history"); liberator.echoerr("Exxx: URL not found in history");
} }
else else
@@ -863,12 +859,13 @@ function History() //{{{
bang: true, bang: true,
completer: function completer(context) completer: function completer(context)
{ {
let sh = window.getWebNavigation().sessionHistory; let sh = history.session;
context.anchored = false; context.anchored = false;
context.completions = [sh.getEntryAtIndex(i, false) for (i in util.range(sh.index, 0, -1))]; context.completions = sh.slice(0, sh.index).reverse();
context.keys = { text: function (item) item.URI.spec, description: "title" }; context.keys = { text: function (item) (sh.index - item.index) + ": " + item.URI.spec, description: "title" };
context.compare = CompletionContext.Sort.unsorted; context.compare = CompletionContext.Sort.unsorted;
context.filters = [CompletionContext.Filter.textDescription];
}, },
count: true, count: true,
literal: 0 literal: 0
@@ -886,15 +883,13 @@ function History() //{{{
{ {
if (url) if (url)
{ {
let sh = window.getWebNavigation().sessionHistory; let sh = history.session;
for (let i in util.range(sh.index + 1, sh.count)) if (/^\d+(:|$)/.test(url) && sh.index + parseInt(url) in sh)
{ return void window.getWebNavigation().gotoIndex(sh.index + parseInt(url));
if (sh.getEntryAtIndex(i, false).URI.spec == url)
{ for (let [i, ent] in Iterator(sh.slice(sh.index + 1)))
window.getWebNavigation().gotoIndex(i); if (ent.URI.spec == url)
return; return void window.getWebNavigation().gotoIndex(i);
}
}
liberator.echoerr("Exxx: URL not found in history"); liberator.echoerr("Exxx: URL not found in history");
} }
else else
@@ -906,12 +901,13 @@ function History() //{{{
bang: true, bang: true,
completer: function completer(context) completer: function completer(context)
{ {
let sh = window.getWebNavigation().sessionHistory; let sh = history.session;
context.anchored = false; context.anchored = false;
context.completions = [sh.getEntryAtIndex(i, false) for (i in util.range(sh.index + 1, sh.count))]; context.completions = sh.slice(sh.index + 1);
context.keys = { text: function (item) item.URI.spec, description: "title" }; context.keys = { text: function (item) (item.index - sh.index) + ": " + item.URI.spec, description: "title" };
context.compare = CompletionContext.Sort.unsorted; context.compare = CompletionContext.Sort.unsorted;
context.filters = [CompletionContext.Filter.textDescription];
}, },
count: true, count: true,
literal: 0 literal: 0
@@ -985,6 +981,17 @@ function History() //{{{
return items; return items;
}, },
get session()
{
let sh = window.getWebNavigation().sessionHistory;
let obj = [];
obj.index = sh.index;
obj.__iterator__ = function() util.Array.iteritems(this)
for (let i in util.range(0, sh.count))
obj[i] = { index: i, __proto__: sh.getEntryAtIndex(i, false) };
return obj;
},
// TODO: better names // TODO: better names
stepTo: function stepTo(steps) stepTo: function stepTo(steps)
{ {

View File

@@ -133,18 +133,7 @@ function CompletionContext(editor, name, offset) //{{{
* @property {Array} An array of predicates on which to filter the * @property {Array} An array of predicates on which to filter the
* results. * results.
*/ */
this.filters = [function (item) { this.filters = [CompletionContext.Filter.text];
let text = Array.concat(item.text);
for (let [i, str] in Iterator(text))
{
if (this.match(String(str)))
{
item.text = String(text[i]);
return true;
}
}
return false;
}];
/** /**
* @property {boolean} Specifies whether this context results must * @property {boolean} Specifies whether this context results must
* match the filter at the beginning of the string. * match the filter at the beginning of the string.
@@ -225,6 +214,24 @@ CompletionContext.Sort = {
unsorted: null unsorted: null
}; };
CompletionContext.Filter = {
text: function (item) {
let text = Array.concat(item.text);
for (let [i, str] in Iterator(text))
{
if (this.match(String(str)))
{
item.text = String(text[i]);
return true;
}
}
return false;
},
textDescription: function (item) {
return CompletionContext.Filter.text.call(this, item) || this.match(item.description);
}
};
CompletionContext.prototype = { CompletionContext.prototype = {
// Temporary // Temporary
/** /**