mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-02 20:54:10 +01:00
experimental wildoptions=auto and awesome bar support, display flickers a
little for now
This commit is contained in:
@@ -232,6 +232,7 @@ liberator.Completion = function () //{{{
|
||||
}
|
||||
|
||||
var cpt = complete || liberator.options["complete"];
|
||||
var autoCompletions = liberator.options["wildoptions"].indexOf("auto") >= 0;
|
||||
var suggestEngineAlias = liberator.options["suggestengines"] || "google";
|
||||
// join all completion arrays together
|
||||
for (var i = 0; i < cpt.length; i++)
|
||||
@@ -240,12 +241,30 @@ liberator.Completion = function () //{{{
|
||||
completions = completions.concat(this.search(filter)[1]);
|
||||
else if (cpt[i] == "f")
|
||||
completions = completions.concat(this.file(filter, false)[1]);
|
||||
else if (cpt[i] == "b")
|
||||
else if (!autoCompletions && cpt[i] == "b")
|
||||
completions = completions.concat(liberator.bookmarks.get(filter));
|
||||
else if (cpt[i] == "h")
|
||||
else if (!autoCompletions && cpt[i] == "h")
|
||||
completions = completions.concat(liberator.history.get(filter));
|
||||
else if (cpt[i] == "S")
|
||||
completions = completions.concat(this.searchEngineSuggest(filter, suggestEngineAlias)[1]);
|
||||
else if (autoCompletions && cpt[i] == "l") // add completions like Firefox's smart location bar
|
||||
{
|
||||
var completionService = Components.classes["@mozilla.org/browser/global-history;2"].
|
||||
getService(Components.interfaces.nsIAutoCompleteSearch);
|
||||
completionService.startSearch(filter, "", null, {
|
||||
onSearchResult: function (search, result) {
|
||||
//var res = "";// + util.objectToString(result) + "\n---\n";
|
||||
//liberator.log(result.matchCount + " matches: " + result.searchResult);
|
||||
var comp = [];
|
||||
for (var i = 0; i < result.matchCount; i++)
|
||||
{
|
||||
comp.push([result.getValueAt(i), result.getCommentAt(i)]);
|
||||
}
|
||||
if (comp.length > 0 || result.searchResult == result.RESULT_SUCCESS)
|
||||
liberator.commandline.setCompletions(completions.concat(comp));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return [start, completions];
|
||||
|
||||
@@ -40,7 +40,7 @@ liberator.CommandLine = function () //{{{
|
||||
|
||||
const UNINITIALIZED = -2; // notifies us, if we need to start history/tab-completion from the beginning
|
||||
|
||||
var completionlist = new liberator.InformationList("liberator-completion", { minItems: 2, maxItems: 10 });
|
||||
var completionlist = new liberator.InformationList("liberator-completion", { minItems: 1, maxItems: 10 });
|
||||
var completions = [];
|
||||
|
||||
// TODO: clean this up when it's not 3am...
|
||||
@@ -130,6 +130,14 @@ liberator.CommandLine = function () //{{{
|
||||
var multilineRegexp = null;
|
||||
var multilineCallback = null;
|
||||
|
||||
liberator.registerCallback("change", liberator.modes.EX, function (command) {
|
||||
if (liberator.options["wildoptions"].indexOf("auto") >= 0)
|
||||
{
|
||||
var res = liberator.completion.ex(command);
|
||||
liberator.commandline.setCompletions(res[1], res[0]);
|
||||
}
|
||||
});
|
||||
|
||||
function setHighlightGroup(group)
|
||||
{
|
||||
commandlineWidget.setAttribute("class", group);
|
||||
@@ -285,11 +293,12 @@ liberator.CommandLine = function () //{{{
|
||||
"Pause the message list window when more than one screen of listings is displayed",
|
||||
"boolean", true);
|
||||
|
||||
// TODO: doesn't belong in ui.js
|
||||
liberator.options.add(["complete", "cpt"],
|
||||
"Items which are completed at the :[tab]open prompt",
|
||||
"charlist", "sfbh",
|
||||
{
|
||||
validator: function (value) { return !/[^sfbhS]/.test(value); }
|
||||
validator: function (value) { return !/[^sfbhSl]/.test(value); }
|
||||
});
|
||||
|
||||
liberator.options.add(["suggestengines"],
|
||||
@@ -326,7 +335,10 @@ liberator.CommandLine = function () //{{{
|
||||
"Change how command line completion is done",
|
||||
"stringlist", "",
|
||||
{
|
||||
validator: function (value) { return /^(sort|)$/.test(value); }
|
||||
validator: function (value)
|
||||
{
|
||||
return value.split(",").every(function (item) { return /^(sort|auto|)$/.test(item); });
|
||||
}
|
||||
});
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
@@ -434,6 +446,7 @@ liberator.CommandLine = function () //{{{
|
||||
multilineInputWidget.collapsed = true;
|
||||
multilineOutputWidget.collapsed = true;
|
||||
completionlist.hide();
|
||||
completions = [];
|
||||
|
||||
setLine("", this.HL_NORMAL);
|
||||
},
|
||||
@@ -673,6 +686,7 @@ liberator.CommandLine = function () //{{{
|
||||
completionlist.show();
|
||||
}
|
||||
|
||||
|
||||
if (full)
|
||||
{
|
||||
if (event.shiftKey)
|
||||
@@ -976,6 +990,24 @@ liberator.CommandLine = function () //{{{
|
||||
}
|
||||
},
|
||||
|
||||
// to allow asynchronous adding of completions
|
||||
setCompletions: function (compl, start)
|
||||
{
|
||||
if (liberator.mode != liberator.modes.COMMAND_LINE)
|
||||
return;
|
||||
|
||||
completions = compl;
|
||||
completionlist.show(compl, 10);
|
||||
completionIndex = -1;
|
||||
|
||||
var command = this.getCommand();
|
||||
completionPrefix = command.substring(0, commandWidget.selectionStart);
|
||||
completionPostfix = command.substring(commandWidget.selectionStart);
|
||||
|
||||
if (typeof start == "number")
|
||||
completionStartIndex = start;
|
||||
},
|
||||
|
||||
resetCompletions: function ()
|
||||
{
|
||||
completionIndex = historyIndex = UNINITIALIZED;
|
||||
@@ -1099,7 +1131,7 @@ liberator.InformationList = function (id, options) //{{{
|
||||
* use entries of 'compl' to fill the list.
|
||||
* Required format: [["left", "right"], ["another"], ["completion"]]
|
||||
*/
|
||||
show: function (compl)
|
||||
show: function (compl, rows)
|
||||
{
|
||||
//maxItems = liberator.options["previewheight"];
|
||||
|
||||
@@ -1114,7 +1146,7 @@ liberator.InformationList = function (id, options) //{{{
|
||||
length = maxItems;
|
||||
if (length >= minItems)
|
||||
{
|
||||
widget.setAttribute("rows", length.toString());
|
||||
widget.setAttribute("rows", rows ? rows : length.toString());
|
||||
widget.hidden = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user