diff --git a/content/bookmarks.js b/content/bookmarks.js
index 0c4132ad..41a88f90 100644
--- a/content/bookmarks.js
+++ b/content/bookmarks.js
@@ -317,7 +317,7 @@ function Bookmarks() //{{{
"List or open multiple bookmarks",
function (args)
{
- bookmarks.list(args.join(" "), args["-tags"] || [], args.bang);
+ bookmarks.list(args.join(" "), args["-tags"] || [], args.bang, args["-max"]);
},
{
bang: true,
@@ -326,7 +326,8 @@ function Bookmarks() //{{{
context.quote = null;
completion.bookmark(context, args["-tags"]);
},
- options: [[["-tags", "-T"], commands.OPTION_LIST, null, tags]]
+ options: [[["-tags", "-T"], commands.OPTION_LIST, null, tags],
+ [["-max", "-m"], commands.OPTION_INT]]
});
commands.add(["delbm[arks]"],
@@ -559,12 +560,12 @@ function Bookmarks() //{{{
},
// if openItems is true, open the matching bookmarks items in tabs rather than display
- list: function list(filter, tags, openItems)
+ list: function list(filter, tags, openItems, maxItems)
{
if (!openItems)
- return completion.listCompleter("bookmark", filter, tags);
+ return completion.listCompleter("bookmark", filter, maxItems, tags);
+ let items = completion.runCompleter("bookmark", filter, maxItems, tags);
- let items = this.get(filter, tags, false);
if (items.length)
return liberator.open(items.map(function (i) i.url), liberator.NEW_TAB);
@@ -807,8 +808,8 @@ function History() //{{{
{
if (!openItems)
return completion.listCompleter("history", filter, maxItems);
+ let items = completion.runCompleter("history", filter, maxItems);
- var items = this.get({ searchTerms: filter }, maxItems);
if (items.length)
return liberator.open([i[0] for each (i in items)], liberator.NEW_TAB);
diff --git a/content/completion.js b/content/completion.js
index a333abef..e4c3f0fc 100644
--- a/content/completion.js
+++ b/content/completion.js
@@ -1019,19 +1019,21 @@ function Completion() //{{{
},
// FIXME
- _runCompleter: function _runCompleter(name, filter)
+ _runCompleter: function _runCompleter(name, filter, maxItems)
{
let context = CompletionContext(filter);
- let res = context.fork.apply(context, ["run", 0, this, name].concat(Array.slice(arguments, 2)));
+ context.maxItems = maxItems;
+ let res = context.fork.apply(context, ["run", 0, this, name].concat(Array.slice(arguments, 3)));
if (res) // FIXME
return { items: res.map(function (i) ({ item: i })) };
context.wait(true);
return context.allItems;
},
- runCompleter: function runCompleter(name, filter)
+ runCompleter: function runCompleter(name, filter, maxItems)
{
- return this._runCompleter(name, filter).items.map(function (i) i.item);
+ return this._runCompleter.apply(this, Array.slice(arguments))
+ .items.map(function (i) i.item);
},
// cancel any ongoing search
@@ -1122,16 +1124,17 @@ function Completion() //{{{
listCompleter: function listCompleter(name, filter, maxItems)
{
let context = CompletionContext(filter || "");
- context.fork.apply(context, ["list", 0, completion, name].concat(Array.slice(arguments, 2)));
- context = context.contexts["/list"];
context.maxItems = maxItems;
+ context.fork.apply(context, ["list", 0, completion, name].concat(Array.slice(arguments, 3)));
+ context = context.contexts["/list"];
context.wait();
let list = template.generic(
{ template.completionRow(context.title, "CompTitle") }
- { template.map(context.items, function (item) context.createRow(item), null, 50) }
+ { template.map(context.items, function (item) context.createRow(item), null, 100) }
);
+ commandline.clear();
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
},
@@ -1150,6 +1153,7 @@ function Completion() //{{{
context.format = bookmarks.format;
context.completions = bookmarks.get(context.filter)
context.filters = [];
+ liberator.dump(tags);
if (tags)
context.filters.push(function ({ item: item }) tags.every(function (tag) item.tags.indexOf(tag) > -1));
},
diff --git a/content/template.js b/content/template.js
index 3d26df55..d1eb61d7 100644
--- a/content/template.js
+++ b/content/template.js
@@ -70,7 +70,7 @@ const template = {
diff --git a/content/ui.js b/content/ui.js
index 041fa072..d6dac3e1 100644
--- a/content/ui.js
+++ b/content/ui.js
@@ -196,7 +196,7 @@ function CommandLine() //{{{
}
else
{
- var compl = null;
+ let compl = null;
if (longest && completions.items.length > 1)
compl = completions.longestSubstring;
else if (full)
@@ -369,7 +369,7 @@ function CommandLine() //{{{
* after interpolated data.
*/
XML.ignoreWhitespace = typeof str == "xml";
- var output = util.xmlToDom({template.maybeXML(str)}
, doc);
+ let output = util.xmlToDom({template.maybeXML(str)}
, doc);
XML.ignoreWhitespace = true;
lastMowOutput = output;
@@ -386,7 +386,7 @@ function CommandLine() //{{{
if (options["more"] && win.scrollMaxY > 0)
{
// start the last executed command's output at the top of the screen
- var elements = doc.getElementsByClassName("ex-command-output");
+ let elements = doc.getElementsByClassName("ex-command-output");
elements[elements.length - 1].scrollIntoView(true);
}
else
@@ -721,7 +721,7 @@ function CommandLine() //{{{
// normally used when pressing esc, does not execute a command
close: function close()
{
- var res = liberator.triggerCallback("cancel", currentExtendedMode);
+ let res = liberator.triggerCallback("cancel", currentExtendedMode);
inputHistory.add(this.getCommand());
statusline.updateProgress(""); // we may have a "match x of y" visible
this.clear();
@@ -740,7 +740,7 @@ function CommandLine() //{{{
// liberator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst
echo: function echo(str, highlightGroup, flags)
{
- var focused = document.commandDispatcher.focusedElement;
+ let focused = document.commandDispatcher.focusedElement;
if (focused && focused == commandWidget.inputField || focused == multilineInputWidget.inputField)
return false;
if (silent)
@@ -751,32 +751,27 @@ function CommandLine() //{{{
if (flags & this.APPEND_TO_MESSAGES)
messageHistory.add({ str: str, highlight: highlightGroup });
- // if we are modifing the GUI while we are not in the main thread
- // Firefox will hang up
- var threadManager = Components.classes["@mozilla.org/thread-manager;1"]
- .getService(Components.interfaces.nsIThreadManager);
- if (!threadManager.isMainThread)
- return false;
-
- var where = setLine;
- if (flags & this.FORCE_MULTILINE)
- where = setMultiline;
- else if (flags & this.FORCE_SINGLELINE)
- where = function () setLine(str, highlightGroup, true);
- else if (flags & this.DISALLOW_MULTILINE)
- {
- if (!outputContainer.collapsed)
- where = null;
- else
+ liberator.callInMainThread(function () {
+ let where = setLine;
+ if (flags & this.FORCE_MULTILINE)
+ where = setMultiline;
+ else if (flags & this.FORCE_SINGLELINE)
where = function () setLine(str, highlightGroup, true);
- }
- else if (/\n|
/.test(str))
- where = setMultiline;
+ else if (flags & this.DISALLOW_MULTILINE)
+ {
+ if (!outputContainer.collapsed)
+ where = null;
+ else
+ where = function () setLine(str, highlightGroup, true);
+ }
+ else if (/\n|
/.test(str))
+ where = setMultiline;
- if (where)
- where(str, highlightGroup);
+ if (where)
+ where(str, highlightGroup);
- currentExtendedMode = null;
+ currentExtendedMode = null;
+ });
return true;
},
@@ -857,7 +852,7 @@ function CommandLine() //{{{
if (!currentExtendedMode)
return true;
- var key = events.toString(event);
+ let key = events.toString(event);
//liberator.log("command line handling key: " + key + "\n");
// user pressed ENTER to carry out a command
@@ -976,10 +971,10 @@ function CommandLine() //{{{
{
if (event.type == "keypress")
{
- var key = events.toString(event);
+ let key = events.toString(event);
if (events.isAcceptKey(key))
{
- var text = multilineInputWidget.value.substr(0, multilineInputWidget.selectionStart);
+ let text = multilineInputWidget.value.substr(0, multilineInputWidget.selectionStart);
if (text.match(multilineRegexp))
{
text = text.replace(multilineRegexp, "");
@@ -1010,17 +1005,17 @@ function CommandLine() //{{{
// allow a down motion after an up rather than closing
onMultilineOutputEvent: function onMultilineOutputEvent(event)
{
- var win = multilineOutputWidget.contentWindow;
+ let win = multilineOutputWidget.contentWindow;
- var showMoreHelpPrompt = false;
- var showMorePrompt = false;
- var closeWindow = false;
- var passEvent = false;
+ let showMoreHelpPrompt = false;
+ let showMorePrompt = false;
+ let closeWindow = false;
+ let passEvent = false;
function isScrollable() !win.scrollMaxY == 0;
function atEnd() win.scrollY / win.scrollMaxY >= 1;
- var key = events.toString(event);
+ let key = events.toString(event);
if (startHints)
{
@@ -1095,7 +1090,7 @@ function CommandLine() //{{{
case "":
if (event.originalTarget.localName.toLowerCase() == "a")
{
- var where = /\btabopen\b/.test(options["activate"]) ?
+ let where = /\btabopen\b/.test(options["activate"]) ?
liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB;
liberator.open(event.originalTarget.textContent, where);
}
@@ -1631,8 +1626,7 @@ function StatusLine() //{{{
// make it even more vim-like
if (url == "about:blank")
{
- var title = buffer.title;
- if (!title)
+ if (!buffer.title)
url = "[No Name]";
}
else
@@ -1643,8 +1637,8 @@ function StatusLine() //{{{
// when session information is available, add [+] when we can go backwards
if (config.name == "Vimperator")
{
- var sh = getWebNavigation().sessionHistory;
- var modified = "";
+ let sh = getWebNavigation().sessionHistory;
+ let modified = "";
if (sh.index > 0)
modified += "+";
if (sh.index < sh.count -1)
@@ -1679,7 +1673,7 @@ function StatusLine() //{{{
}
else if (typeof progress == "number")
{
- var progressStr = "";
+ let progressStr = "";
if (progress <= 0)
progressStr = "[ Loading... ]";
else if (progress < 1)
@@ -1726,13 +1720,13 @@ function StatusLine() //{{{
{
if (!percent || typeof percent != "number")
{
- var win = document.commandDispatcher.focusedWindow;
+ let win = document.commandDispatcher.focusedWindow;
if (!win)
return;
percent = win.scrollMaxY == 0 ? -1 : win.scrollY / win.scrollMaxY;
}
- var bufferPositionStr = "";
+ let bufferPositionStr = "";
percent = Math.round(percent * 100);
if (percent < 0)
bufferPositionStr = "All";