1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-08 08:04:11 +01:00

Make 'cpt' a stringlist. Add support for native autocomplete providers.

This commit is contained in:
Kris Maglione
2011-09-26 15:52:51 -04:00
parent 2ca292f55d
commit 45218f4141
15 changed files with 166 additions and 75 deletions

View File

@@ -168,6 +168,8 @@
- Boolean options no longer accept an argument. [b4]
- 'cdpath' and 'runtimepath' no longer treat ",,"
specially. Use "." instead. [b2]
- 'complete' is now a [stringlist] rather than a [charlist]
and supports native autocomplete providers. [b8]
- 'extendedhinttags' is now a [regexpmap] rather than a
string. [b2]
- 'guioptions' default value has changed. [b4][b7]

View File

@@ -128,7 +128,7 @@ var Config = Module("config", ConfigBase, {
},
defaults: {
complete: "slf",
complete: "search,location,file",
guioptions: "bCrs",
showtabline: "always",
titlestring: "Pentadactyl"
@@ -280,55 +280,12 @@ var Config = Module("config", ConfigBase, {
const { CompletionContext, bookmarkcache, completion } = modules;
const { document } = window;
var searchRunning = null;
completion.location = function location(context) {
if (!services.autoCompleteSearch)
return;
if (searchRunning) {
searchRunning.completions = searchRunning.completions;
searchRunning.cancel();
}
context.anchored = false;
context.compare = CompletionContext.Sort.unsorted;
context.filterFunc = null;
let words = context.filter.toLowerCase().split(/\s+/g);
context.hasItems = true;
context.completions = context.completions.filter(function ({ url, title })
words.every(function (w) (url + " " + title).toLowerCase().indexOf(w) >= 0))
context.incomplete = true;
context.format = modules.bookmarks.format;
context.keys.extra = function (item) (bookmarkcache.get(item.url) || {}).extra;
completion.autocomplete("history", context);
context.title = ["Smart Completions"];
context.cancel = function () {
this.incomplete = false;
if (searchRunning === this) {
services.autoCompleteSearch.stopSearch();
searchRunning = null;
}
};
services.autoCompleteSearch.startSearch(context.filter, "", context.result, {
onSearchResult: function onSearchResult(search, result) {
if (result.searchResult <= result.RESULT_SUCCESS)
searchRunning = null;
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
context.completions = [
{ url: result.getValueAt(i), title: result.getCommentAt(i), icon: result.getImageAt(i) }
for (i in util.range(0, result.matchCount))
];
},
get onUpdateSearchResult() this.onSearchResult
});
searchRunning = context;
};
completion.addUrlCompleter("l",
completion.addUrlCompleter("location",
"Firefox location bar entries (bookmarks and history sorted in an intelligent way)",
completion.location);