1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 14:02:28 +01:00

Add -max option to :hist, default to 1000

This commit is contained in:
Kris Maglione
2008-11-28 17:19:08 +00:00
parent 7b94ccc354
commit e3feb4ce87
2 changed files with 13 additions and 12 deletions

View File

@@ -725,11 +725,11 @@ function History() //{{{
commands.add(["hist[ory]", "hs"], commands.add(["hist[ory]", "hs"],
"Show recently visited URLs", "Show recently visited URLs",
function (args) { history.list(args.string, args.bang); }, function (args) { history.list(args.join(" "), args.bang, args["-max"] || 1000); },
{ {
bang: true, bang: true,
literal: 0, completer: function (context) { context.quote = null, completion.history(context) },
completer: function (context) completion.history(context) options: [[["-max", "-m"], options.OPTION_INT]]
// completer: function (filter) completion.history(filter) // completer: function (filter) completion.history(filter)
}); });
@@ -803,12 +803,12 @@ function History() //{{{
}, },
// if openItems is true, open the matching history items in tabs rather than display // if openItems is true, open the matching history items in tabs rather than display
list: function list(filter, openItems) list: function list(filter, openItems, maxItems)
{ {
if (!openItems) if (!openItems)
return completion.listCompleter("history", filter); return completion.listCompleter("history", filter, maxItems);
var items = this.get({ searchTerms: filter }, 1000); var items = this.get({ searchTerms: filter }, maxItems);
if (items.length) if (items.length)
return liberator.open([i[0] for each (i in items)], liberator.NEW_TAB); return liberator.open([i[0] for each (i in items)], liberator.NEW_TAB);

View File

@@ -62,7 +62,7 @@ function CompletionContext(editor, name, offset)
self[key] = parent[key]); self[key] = parent[key]);
if (self != this) if (self != this)
return self; return self;
["_caret", "contextList", "onUpdate", "selectionTypes", "tabPressed", "updateAsync", "value", "waitingForTab"].forEach(function (key) { ["_caret", "contextList", "maxItems", "onUpdate", "selectionTypes", "tabPressed", "updateAsync", "value", "waitingForTab"].forEach(function (key) {
self.__defineGetter__(key, function () this.top[key]); self.__defineGetter__(key, function () this.top[key]);
self.__defineSetter__(key, function (val) this.top[key] = val); self.__defineSetter__(key, function (val) this.top[key] = val);
}); });
@@ -271,6 +271,8 @@ CompletionContext.prototype = {
delete this._substrings; delete this._substrings;
let filtered = this.filterFunc(items.map(function (item) ({ text: self.getKey({ item: item }, "text"), item: item }))); let filtered = this.filterFunc(items.map(function (item) ({ text: self.getKey({ item: item }, "text"), item: item })));
if (this.maxItems)
filtered = filtered.slice(0, this.maxItems);
let quote = this.quote; let quote = this.quote;
if (quote) if (quote)
@@ -1117,14 +1119,13 @@ function Completion() //{{{
return filter.split(/\s+/).every(function strIndex(str) itemsStr.indexOf(str) > -1); return filter.split(/\s+/).every(function strIndex(str) itemsStr.indexOf(str) > -1);
}, },
listCompleter: function listCompleter(name, filter) listCompleter: function listCompleter(name, filter, maxItems)
{ {
let context = CompletionContext(filter || ""); let context = CompletionContext(filter || "");
context.fork.apply(context, ["list", 0, completion, name].concat(Array.slice(arguments, 2))); context.fork.apply(context, ["list", 0, completion, name].concat(Array.slice(arguments, 2)));
context = context.contexts["/list"]; context = context.contexts["/list"];
context.maxItems = maxItems;
while (context.incomplete) context.wait();
liberator.threadYield(true, true);
let list = template.generic( let list = template.generic(
<div highlight="Completions"> <div highlight="Completions">
@@ -1339,7 +1340,7 @@ function Completion() //{{{
context.compare = null; context.compare = null;
//context.background = true; //context.background = true;
context.regenerate = true; context.regenerate = true;
context.generate = function () history.get(context.filter); context.generate = function () history.get(context.filter, this.maxItems);
}, },
get javascriptCompleter() javascript, get javascriptCompleter() javascript,