1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 09:17:59 +01:00

Changed 'complete' option default to "sfl", meaning we have awesomebar completions by default now.

In constrast removed history cache, which should make startup faster and use less memory. As we only need it for :history anyway, there is no real performance penalty as Places does search quite fast.
This commit is contained in:
Martin Stubenschrott
2008-11-20 19:46:38 +00:00
parent 069a8e57f1
commit cd2c0d6c6d
5 changed files with 61 additions and 128 deletions

4
NEWS
View File

@@ -1,5 +1,8 @@
2008-XX-XX: 2008-XX-XX:
* version 2.0 (probably) * version 2.0 (probably)
* IMPORTANT: Due to much improved autocompletion, changed default 'complete' option
value to 'sfl', listing intelligent Firefox location bar results. Removed possibility
to use 'h' in 'complete'.
* IMPORTANT: AlwaysHint modes were removed as they didn't make too * IMPORTANT: AlwaysHint modes were removed as they didn't make too
much sense with the new hint system much sense with the new hint system
* IMPORTANT: command actions now take an args object, returned from * IMPORTANT: command actions now take an args object, returned from
@@ -12,6 +15,7 @@
special versions for the old behavior special versions for the old behavior
* IMPORTANT: renamed Startup and Quit autocmd events to VimperatorEnter and * IMPORTANT: renamed Startup and Quit autocmd events to VimperatorEnter and
VimperatorLeave respectively VimperatorLeave respectively
* :buffers supports a filter now to only list buffers matching filter (vim * :buffers supports a filter now to only list buffers matching filter (vim
incompatible, but consistent with other commands) incompatible, but consistent with other commands)
* Favicon support in many places * Favicon support in many places

View File

@@ -550,47 +550,6 @@ function History() //{{{
const historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"] const historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
.getService(Components.interfaces.nsINavHistoryService); .getService(Components.interfaces.nsINavHistoryService);
// const History = new Struct("url", "title", "icon");
// History.defaultValue("title", function () "[No Title]");
// History.defaultValue("icon", function () bookmarks.getFavicon(this.url));
var placesHistory;
var cachedHistory = []; // add pages here after loading the initial Places history
function load()
{
placesHistory = [];
// no query parameters will get all history
// XXX default sorting is... ?
var options = historyService.getNewQueryOptions();
var query = historyService.getNewQuery();
// execute the query
var result = historyService.executeQuery(query, options);
var rootNode = result.root;
rootNode.containerOpen = true;
// iterate over the immediate children of this folder
for (let i = 0; i < rootNode.childCount; i++)
{
var node = rootNode.getChild(i);
// liberator.dump("History child " + node.itemId + ": " + node.title + " - " + node.type);
if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark
placesHistory.push({ url: node.uri, title: node.title, get icon() function() bookmarks.getFavicon(this.url) });
}
// close a container after using it!
rootNode.containerOpen = false;
}
liberator.registerObserver("enter", function () {
if (options["preload"])
{
// Forces a load, if not already loaded but wait 15sec
// so that we don't load it at the same time as bookmarks
setTimeout(function() { liberator.callFunctionInThread(null, load); }, 15000);
}
});
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// MAPPINGS //////////////////////////////////////////////// ////////////////////// MAPPINGS ////////////////////////////////////////////////
@@ -736,77 +695,57 @@ function History() //{{{
return { return {
load: function() { load(); }, // temporary only, for performance testing get: function (filter, maxItems)
get: function (filter)
{ {
if (!placesHistory) let items = [];
load();
if (!filter) // no query parameters will get all history
return cachedHistory.concat(placesHistory); let query = historyService.getNewQuery();
return completion.cached("history", filter, function () cachedHistory.concat(placesHistory), query.searchTerms = filter;
"filterURLArray");
},
// the history is automatically added to the Places global history let options = historyService.getNewQueryOptions();
// so just update our cached history here options.sortingMode = options.SORT_BY_DATE_DESCENDING;
add: function (url, title) if (maxItems > 0)
{ options.maxResults = maxItems;
let filter = function (h) h[0] != url;
// don't let cachedHistory grow too large // execute the query
if (placesHistory && cachedHistory.length > 1000) let root = historyService.executeQuery(query, options).root;
root.containerOpen = true;
for (let i = 0; i < root.childCount; i++)
{ {
placesHistory = cachedHistory.concat(placesHistory); let node = root.getChild(i);
placesHistory = placesHistory.filter(filter); if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark
cachedHistory = []; items.push({ url: node.uri, title: node.title, get icon() function() bookmarks.getFavicon(node.uri) });
} }
else root.containerOpen = false; // close a container after using it!
cachedHistory = cachedHistory.filter(filter);
cachedHistory.unshift({ url: url, title: title, get icon() function() bookmarks.getFavicon(this.url) }); return items;
return true;
}, },
// TODO: better names? // TODO: better names and move to buffer.?
// and move to buffer.?
stepTo: function (steps) stepTo: function (steps)
{ {
var index = getWebNavigation().sessionHistory.index + steps; let index = getWebNavigation().sessionHistory.index + steps;
if (index >= 0 && index < getWebNavigation().sessionHistory.count) if (index >= 0 && index < getWebNavigation().sessionHistory.count)
{
getWebNavigation().gotoIndex(index); getWebNavigation().gotoIndex(index);
}
else else
{
liberator.beep(); liberator.beep();
}
}, },
goToStart: function () goToStart: function ()
{ {
var index = getWebNavigation().sessionHistory.index; let index = getWebNavigation().sessionHistory.index;
if (index == 0) if (index == 0)
{ return liberator.beep(); // really wanted?
liberator.beep();
return;
}
getWebNavigation().gotoIndex(0); getWebNavigation().gotoIndex(0);
}, },
goToEnd: function () goToEnd: function ()
{ {
var index = getWebNavigation().sessionHistory.index; let index = getWebNavigation().sessionHistory.index;
var max = getWebNavigation().sessionHistory.count - 1; if (index == getWebNavigation().sessionHistory.count - 1)
return liberator.beep();
if (index == max)
{
liberator.beep();
return;
}
getWebNavigation().gotoIndex(max); getWebNavigation().gotoIndex(max);
}, },
@@ -814,7 +753,7 @@ 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 (filter, openItems) list: function (filter, openItems)
{ {
var items = this.get(filter); var items = this.get(filter, 1000);
if (items.length == 0) if (items.length == 0)
{ {
if (filter.length > 0) if (filter.length > 0)
@@ -828,7 +767,6 @@ function History() //{{{
if (openItems) if (openItems)
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);
// TODO: is there a faster way to limit to max. 1000 items?
let list = template.bookmarks("title", items); let list = template.bookmarks("title", items);
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE); commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
} }

View File

@@ -164,7 +164,7 @@ function Completion() //{{{
let orig = obj; let orig = obj;
if (obj.wrappedJSObject) if (obj.wrappedJSObject)
obj = obj.wrappedJSObject; obj = obj.wrappedJSObject;
compl.push([v for (v in this.iter(obj)) if (v[0] in orig || orig[v[0]])]) compl.push([v for (v in this.iter(obj)) if (v[0] in orig)])
// And if wrappedJSObject happens to be available, // And if wrappedJSObject happens to be available,
// return that, too. // return that, too.
if (orig.wrappedJSObject) if (orig.wrappedJSObject)
@@ -1063,30 +1063,33 @@ function Completion() //{{{
let keywords = bookmarks.getKeywords(); let keywords = bookmarks.getKeywords();
let engines = this.filter(keywords.concat(bookmarks.getSearchEngines()), filter, false, true); let engines = this.filter(keywords.concat(bookmarks.getSearchEngines()), filter, false, true);
let generate = function () { // NOTE: While i like the result of the code, due to the History simplification
let hist = history.get(); // that code is too slow to be here. We might use a direct Places History query instead for better speed
let searches = []; // let generate = function () {
for (let [, k] in Iterator(keywords)) // let hist = history.get();
{ // let searches = [];
if (k.keyword.toLowerCase() != keyword.toLowerCase() || k.url.indexOf("%s") == -1) // for (let [, k] in Iterator(keywords))
continue; // {
let [begin, end] = k.url.split("%s"); // if (k.keyword.toLowerCase() != keyword.toLowerCase() || k.url.indexOf("%s") == -1)
for (let [, h] in Iterator(hist)) // continue;
{ // let [begin, end] = k.url.split("%s");
if (h.url.indexOf(begin) == 0 && (!end.length || h.url.substr(-end.length) == end)) // for (let [, h] in Iterator(hist))
{ // {
let query = h.url.substring(begin.length, h.url.length - end.length); // if (h.url.indexOf(begin) == 0 && (!end.length || h.url.substr(-end.length) == end))
searches.push([decodeURIComponent(query.replace("+", "%20")), // {
<>{begin}<span class="hl-Filter">{query}</span>{end}</>, // let query = h.url.substring(begin.length, h.url.length - end.length);
k.icon]); // searches.push([decodeURIComponent(query.replace("+", "%20")),
} // <>{begin}<span class="hl-Filter">{query}</span>{end}</>,
} // k.icon]);
} // }
return searches; // }
} // }
let searches = this.cached("searches-" + keyword, args, generate, "filter", [false, true]); // return searches;
searches = searches.map(function (a) (a = a.concat(), a[0] = keyword + " " + a[0], a)); // }
return [0, searches.concat(engines)]; // let searches = this.cached("searches-" + keyword, args, generate, "filter", [false, true]);
// searches = searches.map(function (a) (a = a.concat(), a[0] = keyword + " " + a[0], a));
// return [0, searches.concat(engines)];
return [0, engines];
}, },
// XXX: Move to bookmarks.js? // XXX: Move to bookmarks.js?
@@ -1260,8 +1263,6 @@ function Completion() //{{{
completions = completions.concat(this.searchEngineSuggest(filter, suggestEngineAlias)[1]); completions = completions.concat(this.searchEngineSuggest(filter, suggestEngineAlias)[1]);
else if (c == "b") else if (c == "b")
completions = completions.concat(bookmarks.get(filter)); completions = completions.concat(bookmarks.get(filter));
else if (c == "h")
completions = completions.concat(history.get(filter));
else if (c == "l" && completionService) // add completions like Firefox's smart location bar else if (c == "l" && completionService) // add completions like Firefox's smart location bar
{ {
historyCache = []; historyCache = [];

View File

@@ -517,10 +517,6 @@ function Events() //{{{
let url = doc.location.href; let url = doc.location.href;
let title = doc.title; let title = doc.title;
// update history
if (url && liberator.has("history"))
history.add(url, title);
// mark the buffer as loaded, we can't use buffer.loaded // mark the buffer as loaded, we can't use buffer.loaded
// since that always refers to the current buffer, while doc can be // since that always refers to the current buffer, while doc can be
// any buffer, even in a background tab // any buffer, even in a background tab

View File

@@ -218,26 +218,20 @@ ____
|\'cpt'| |\'complete'| |\'cpt'| |\'complete'|
||'complete' 'cpt'|| charlist (default: sfbh) ||'complete' 'cpt'|| charlist (default: sfl)
____ ____
Items which are completed at the [c]:[tab]open[c] prompt. Available items: Items which are completed at the [c]:[tab]open[c] prompt. Available items:
`---`-------------------------------------------------------------------------------- `---`--------------------------------------------------------------------------------
*s* Search engines and keyword URLs *s* Search engines and keyword URLs
*f* Local files *f* Local files
*b* Bookmarks
*h* History
*l* Firefox location bar entries (bookmarks and history sorted in an intelligent way) *l* Firefox location bar entries (bookmarks and history sorted in an intelligent way)
*b* Bookmarks
*S* Suggest engines *S* Suggest engines
------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------
The order is important, so [c]:set complete=bs[c] would list bookmarks first, 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 and then any available quick searches.
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".
____ ____