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

More completion stuff. Add proper :bmarks completion

This commit is contained in:
Kris Maglione
2008-11-22 11:09:36 +00:00
parent fbd5fde3b4
commit 5db27607ad
4 changed files with 17 additions and 14 deletions

View File

@@ -78,13 +78,7 @@ function Bookmarks() //{{{
let tags = taggingService.getTagsForURI(uri, {}) || []; let tags = taggingService.getTagsForURI(uri, {}) || [];
//return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId)); //return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId));
return bookmarks.push({ url: node.uri, return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId));
title: node.title,
get icon() getFavicon(node.uri), // TODO; must be a direct way to get the icon
keyword: keyword,
tags: tags,
id: node.itemId,
get xml() template.bookmarkItem(this)});
} }
function readBookmark(id) function readBookmark(id)
@@ -287,6 +281,9 @@ function Bookmarks() //{{{
}, },
{ argCount: "0" }); { argCount: "0" });
function tags() util.Array.uniq(util.Array.flatten([b.tags for ([k, b] in Iterator(cache.bookmarks))]))
.map(function (tag) [tag, tag]);
commands.add(["bma[rk]"], commands.add(["bma[rk]"],
"Add a bookmark", "Add a bookmark",
function (args, special) function (args, special)
@@ -322,8 +319,14 @@ function Bookmarks() //{{{
}, },
{ {
bang: true, bang: true,
completer: function (context) completion.bookmark(context.filter), completer: function (context, args)
options: [[["-tags", "-T"], commands.OPTION_LIST]] {
if (args.completeOpt)
return;
context.advance(args.completeStart); // TODO: Move this to completion.ex?
completion.url(context, "b");
},
options: [[["-tags", "-T"], commands.OPTION_LIST, null, tags]]
}); });
commands.add(["delbm[arks]"], commands.add(["delbm[arks]"],

View File

@@ -534,7 +534,7 @@ function Commands() //{{{
if (complete) if (complete)
{ {
if (quote || !invalid && count) if (quote || !invalid && count && i + optname.length + 1 + arg.length == str.length)
{ {
args.completeStart += optname.length + 1; args.completeStart += optname.length + 1;
args.completeOpt = opt[0][0]; args.completeOpt = opt[0][0];

View File

@@ -266,9 +266,9 @@ function Completion() //{{{
completion.filterMap = [null, function (v) template.highlight(v, true)]; completion.filterMap = [null, function (v) template.highlight(v, true)];
if (cacheFilter.js === cacheKey) //if (cacheFilter.js === cacheKey)
return cacheResults.js; // return cacheResults.js;
cacheFilter.js = cacheKey; //cacheFilter.js = cacheKey;
// Can't use the cache. Build a member list. // Can't use the cache. Build a member list.
compl = []; compl = [];

View File

@@ -1344,7 +1344,7 @@ function ItemList(id) //{{{
function fill(offset) function fill(offset)
{ {
let diff = offset - startIndex; let diff = offset - startIndex;
if (items == null || offset == null || offset - startIndex == 0 || offset < 0) if (items == null || offset == null || diff == 0 || offset < 0)
return; return;
startIndex = offset; startIndex = offset;