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

changed behavior of :bmarks! and :history! (thanks dpb)

This commit is contained in:
Martin Stubenschrott
2008-01-07 13:04:59 +00:00
parent e097b79a0d
commit a43249672f
4 changed files with 80 additions and 64 deletions

View File

@@ -3,6 +3,7 @@
2008:
* Kurtis Rader
* Andrew Pantyukhin
2007:
* Richard Terrell

2
NEWS
View File

@@ -7,6 +7,8 @@
removed the following hint options: 'hintchars' 'maxhints'
added the following hint options: 'hinttimeout'
* IMPORTANT: changed 'I' key to Ctrl-Q to also work in textboxes
* IMPORTANT: :bmarks! and :history! open the matching items now in a tab, instead
of bringing up the bookmarks/history window
* new :command to add user defined commands
* new setCustomMode for plugin writers
* :au[tocmd] executes commands on events (only 'PageLoad' actually) on websites

View File

@@ -319,59 +319,64 @@ vimperator.Bookmarks = function () //{{{
return url; // can be null
},
list: function (filter, tags, fullmode)
// if openItems is true, open the matching bookmarks items in tabs rather than display
list: function (filter, tags, openItems)
{
if (fullmode)
var items = this.get(filter, tags, false);
if (items.length == 0)
{
vimperator.open("chrome://browser/content/bookmarks/bookmarksPanel.xul", vimperator.NEW_TAB);
if (filter.length > 0 || tags.length > 0)
vimperator.echoerr("E283: No bookmarks matching \"" + filter + "\"");
else
vimperator.echoerr("No bookmarks set");
return;
}
else
if (openItems)
{
var items = this.get(filter, tags, false);
// FIXME: use yes/no question
if (items.length > 50)
return vimperator.echoerr("For now, you can only open a hard limit of 50 items at once");
if (items.length == 0)
{
if (filter.length > 0 || tags.length > 0)
vimperator.echoerr("E283: No bookmarks matching \"" + filter + "\"");
else
vimperator.echoerr("No bookmarks set");
return;
}
var title, url, tags, keyword, extra;
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" +
"<table><tr align=\"left\" class=\"hl-Title\"><th>title</th><th>URL</th></tr>";
for (var i = 0; i < items.length; i++)
{
title = vimperator.util.escapeHTML(items[i][1]);
if (title.length > 50)
title = title.substr(0, 47) + "...";
url = vimperator.util.escapeHTML(items[i][0]);
keyword = items[i][2];
tags = items[i][3].join(", ");
vimperator.open(items[i][0], vimperator.NEW_TAB);
extra = "";
if (keyword)
{
extra = "<span style=\"color: gray;\"> (keyword: <span style=\"color: red;\">" + vimperator.util.escapeHTML(keyword) + "</span>";
if (tags)
extra += " tags: <span style=\"color: blue;\">" + vimperator.util.escapeHTML(tags) + ")</span>";
else
extra += ")</span>";
}
else if (tags)
{
extra = "<span style=\"color: gray;\"> (tags: <span style=\"color: blue;\">" + vimperator.util.escapeHTML(tags) + "</span>)</span>";
}
list += "<tr><td>" + title + "</td><td style=\"width: 100%\"><a href=\"#\" class=\"hl-URL\">" + url + "</a>" + extra + "</td></tr>";
}
list += "</table>";
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
return;
}
var title, url, tags, keyword, extra;
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" +
"<table><tr align=\"left\" class=\"hl-Title\"><th>title</th><th>URL</th></tr>";
for (var i = 0; i < items.length; i++)
{
title = vimperator.util.escapeHTML(items[i][1]);
if (title.length > 50)
title = title.substr(0, 47) + "...";
url = vimperator.util.escapeHTML(items[i][0]);
keyword = items[i][2];
tags = items[i][3].join(", ");
extra = "";
if (keyword)
{
extra = "<span style=\"color: gray;\"> (keyword: <span style=\"color: red;\">" + vimperator.util.escapeHTML(keyword) + "</span>";
if (tags)
extra += " tags: <span style=\"color: blue;\">" + vimperator.util.escapeHTML(tags) + ")</span>";
else
extra += ")</span>";
}
else if (tags)
{
extra = "<span style=\"color: gray;\"> (tags: <span style=\"color: blue;\">" + vimperator.util.escapeHTML(tags) + "</span>)</span>";
}
list += "<tr><td>" + title + "</td><td style=\"width: 100%\"><a href=\"#\" class=\"hl-URL\">" + url + "</a>" + extra + "</td></tr>";
}
list += "</table>";
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
}
};
@@ -493,25 +498,33 @@ vimperator.History = function () //{{{
getWebNavigation().gotoIndex(max);
},
list: function (filter, fullmode)
// if openItems is true, open the matching history items in tabs rather than display
list: function (filter, openItems)
{
if (fullmode)
var items = this.get(filter);
if (items.length == 0)
{
vimperator.open("chrome://browser/content/history/history-panel.xul", vimperator.NEW_TAB);
if (filter.length > 0)
vimperator.echoerr("E283: No history matching \"" + filter + "\"");
else
vimperator.echoerr("No history set");
return;
}
if (openItems)
{
// FIXME: use yes/no question
if (items.length > 50)
return vimperator.echoerr("For now, you can only open a hard limit of 50 items at once");
for (var i = 0; i < items.length; i++)
vimperator.open(items[i][0], vimperator.NEW_TAB);
return;
}
else
{
var items = this.get(filter);
if (items.length == 0)
{
if (filter.length > 0)
vimperator.echoerr("E283: No history matching \"" + filter + "\"");
else
vimperator.echoerr("No history set");
return;
}
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" +
"<table><tr align=\"left\" class=\"hl-Title\"><th>title</th><th>URL</th></tr>";

View File

@@ -675,10 +675,10 @@ vimperator.Commands = function () //{{{
vimperator.bookmarks.list(res.args.join(" "), tags, special);
},
{
usage: ["bmarks [filter]", "bmarks!"],
shortHelp: "Show bookmarks",
usage: ["bmarks[!] [filter]"],
shortHelp: "List or open multiple bookmarks",
help: "Open the message window at the bottom of the screen with all bookmarks which match <code class=\"argument\">[filter]</code> either in the title or URL.<br/>" +
"The special version <code class=\"command\">:bmarks!</code> opens the default Firefox bookmarks window.<br/>" +
"The special version <code class=\"command\">:bmarks!</code> works the same as <code class=\"command\">:bmarks</code> except it opens all the found bookmarks in new tabs.<br/>" +
"Filter can also contain the following options:<br/>" +
"-tags=comma,separated,tag,list<br/>",
completer: function (filter) { return [0, vimperator.bookmarks.get(filter)]; },
@@ -1106,10 +1106,10 @@ vimperator.Commands = function () //{{{
commandManager.add(new vimperator.Command(["hist[ory]", "hs"],
function (args, special) { vimperator.history.list(args, special); },
{
usage: ["hist[ory] [filter]", "history!"],
usage: ["hist[ory][!] [filter]"],
shortHelp: "Show recently visited URLs",
help: "Open the message window at the bottom of the screen with all history items which match <code class=\"argument\">[filter]</code> either in the title or URL.<br/>" +
"The special version <code class=\"command\">:history!</code> opens the default Firefox history window.",
"The special version <code class=\"command\">:history!</code> works the same as <code class=\"command\">:history</code> except it opens all the found items in new tabs.<br/>",
completer: function (filter) { return [0, vimperator.history.get(filter)]; }
}
));