1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 05:57:58 +01:00

experimental wildoptions=auto and awesome bar support, display flickers a

little for now
This commit is contained in:
Martin Stubenschrott
2008-06-17 23:40:52 +00:00
parent f4dc048685
commit ee6f8df80f
5 changed files with 74 additions and 12 deletions

4
NEWS
View File

@@ -8,6 +8,10 @@
generous donation which made this behavior possible)
* IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just
too unpredictable
* new "l" flag for 'complete' to reuse the Firefox awesome bar for getting better
completions for :open. Works only when 'wildoptions' contains "auto"
* new wildoptions=auto option (default off for now), to automatically list
completions without the need to press the tab key
* new argument parser for ex commands, should tell better error messages when
you do things like :bmark -tag=a,b instead of :bmark -tags=a,b
* :bdelete accepts an optional argument now

1
TODO
View File

@@ -13,6 +13,7 @@ BUGS:
- :sidebar improvements (:sidebar! Downloads while downloads is open should refocus the sidebar)
- http://www.maximonline.com/jokes/ - the prev and next buttons on the image map are not hinted
- ;f seems broken after a page load
- ;s saves the page rather than the image
FEATURES:
8 middleclick in content == p, and if command line is open, paste there the clipboard buffer

View File

@@ -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];

View File

@@ -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;
}

View File

@@ -148,17 +148,22 @@ ____
____
Items which are completed at the [c]:[tab]open[c] prompt. Available items:
`---`--------------------------------
`---`--------------------------------------------------------------------------------
*s* Search engines and keyword URLs
*f* Local files
*b* Bookmarks
*h* History
*l* Firefox location bar entries (bookmarks and history sorted in an intelligent way)
*S* Suggest engines
-------------------------------------
-------------------------------------------------------------------------------------
The order is important, so [c]:set complete=bs[c] would list bookmarks first,
and then any available quick searches. Add "sort" to the 'wildoptions' option
if you want all entries sorted.
if you want all entries sorted. If 'wildoptions' contains "auto", "b" and "h"
are not available for performance reasons but you can use "l" to achieve
a similar effect. On the other hand "l" does not yet work, when 'wildoptions'
does NOT contain "auto".
____
@@ -614,8 +619,9 @@ ____
____
A list of words that change how command line completion is done.
Currently only one word is allowed:
Possible words:
`------`---------------------------------
auto Automatically show completions while you are typing
sort Always sorts completion list, overriding the 'complete' option.
-----------------------------------------