1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 03:57:59 +01:00

Add n_s and n_S.

This commit is contained in:
Kris Maglione
2011-08-11 14:03:17 -04:00
parent ac3f218620
commit c4a40df0b7
6 changed files with 64 additions and 37 deletions

View File

@@ -220,6 +220,14 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
"Open one or more URLs, based on current location", "Open one or more URLs, based on current location",
function () { CommandExMode().open("open " + decode(buffer.uri.spec)); }); function () { CommandExMode().open("open " + decode(buffer.uri.spec)); });
mappings.add([modes.NORMAL], ["s"],
"Open a search prompt",
function () { CommandExMode().open("open " + options["defsearch"] + " "); });
mappings.add([modes.NORMAL], ["S"],
"Open a search prompt for a new tab",
function () { CommandExMode().open("tabopen " + options["defsearch"] + " "); });
mappings.add([modes.NORMAL], ["t"], mappings.add([modes.NORMAL], ["t"],
"Open one or more URLs in a new tab", "Open one or more URLs in a new tab",
function () { CommandExMode().open("tabopen "); }); function () { CommandExMode().open("tabopen "); });

View File

@@ -21,19 +21,18 @@ var History = Module("history", {
for (let [k, v] in Iterator(filter)) for (let [k, v] in Iterator(filter))
query[k] = v; query[k] = v;
order = order || "+date"; let _order = /^([+-])(.+)/.exec(order || "+date");
dactyl.assert((order = /^([+-])(.+)/.exec(order)) && dactyl.assert(_order, _("error.invalidSort", order));
(order = "SORT_BY_" + order[2].toUpperCase() + "_" +
(order[1] == "+" ? "ASCENDING" : "DESCENDING")) &&
order in options,
_("error.invalidSort", order));
options.sortingMode = options[order]; _order = "SORT_BY_" + _order[2].toUpperCase() + "_" +
(_order[1] == "+" ? "ASCENDING" : "DESCENDING");
dactyl.assert(_order in options, _("error.invalidSort", order));
options.sortingMode = options[_order];
options.resultType = options.RESULTS_AS_URI; options.resultType = options.RESULTS_AS_URI;
if (maxItems > 0) if (maxItems > 0)
options.maxResults = maxItems; options.maxResults = maxItems;
// execute the query
let root = services.history.executeQuery(query, options).root; let root = services.history.executeQuery(query, options).root;
root.containerOpen = true; root.containerOpen = true;
let items = iter(util.range(0, root.childCount)).map(function (i) { let items = iter(util.range(0, root.childCount)).map(function (i) {
@@ -44,7 +43,7 @@ var History = Module("history", {
icon: node.icon ? node.icon : DEFAULT_FAVICON icon: node.icon ? node.icon : DEFAULT_FAVICON
}; };
}).toArray(); }).toArray();
root.containerOpen = false; // close a container after using it! root.containerOpen = false;
return items; return items;
}, },
@@ -58,12 +57,11 @@ var History = Module("history", {
obj.__defineSetter__("index", function (val) { webNav.gotoIndex(val) }); obj.__defineSetter__("index", function (val) { webNav.gotoIndex(val) });
obj.__iterator__ = function () array.iterItems(this); obj.__iterator__ = function () array.iterItems(this);
for (let i in util.range(0, sh.count)) { for (let item in iter(sh.SHistoryEnumerator, Ci.nsIHistoryEntry))
obj[i] = update(Object.create(sh.getEntryAtIndex(i, false)), obj.push(update(Object.create(item), {
{ index: i }); index: obj.length,
memoize(obj[i], "icon", icon: Class.memoize(function () services.favicon.getFaviconImageForPage(this.URI).spec)
function () services.favicon.getFaviconImageForPage(this.URI).spec); }));
}
return obj; return obj;
}, },
@@ -87,7 +85,7 @@ var History = Module("history", {
try { try {
sh.index = Math.constrain(sh.index + steps, 0, sh.length - 1); sh.index = Math.constrain(sh.index + steps, 0, sh.length - 1);
} }
catch (e) {} // We get NS_ERROR_FILE_NOT_FOUND if files in history don't exist catch (e if e.result == Cr.NS_ERROR_FILE_NOT_FOUND) {}
}, },
/** /**

View File

@@ -86,6 +86,16 @@
</description> </description>
</item> </item>
<item>
<tags>O</tags>
<spec>O</spec>
<description short="true">
<p>
Open an <ex>:open</ex> prompt followed by the current URL.
</p>
</description>
</item>
<item> <item>
<tags>T</tags> <tags>T</tags>
<spec>T</spec> <spec>T</spec>
@@ -96,6 +106,22 @@
</description> </description>
</item> </item>
<item>
<tags>s</tags>
<spec>s</spec>
<description short="true">
<p>Open a search prompt.</p>
</description>
</item>
<item>
<tags>S</tags>
<spec>S</spec>
<description short="true">
<p>Open a search prompt for a new tab.</p>
</description>
</item>
<item> <item>
<tags>:tabdu :tabduplicate</tags> <tags>:tabdu :tabduplicate</tags>
<spec>:<oa>count</oa>tabdu<oa>plicate</oa><oa>!</oa></spec> <spec>:<oa>count</oa>tabdu<oa>plicate</oa><oa>!</oa></spec>
@@ -108,16 +134,6 @@
</description> </description>
</item> </item>
<item>
<tags>O</tags>
<spec>O</spec>
<description short="true">
<p>
Open an <ex>:open</ex> prompt followed by the current URL.
</p>
</description>
</item>
<item> <item>
<tags>w :winopen :wopen</tags> <tags>w :winopen :wopen</tags>
<spec>:wino<oa>pen</oa><oa>!</oa> <oa>args</oa></spec> <spec>:wino<oa>pen</oa><oa>!</oa> <oa>args</oa></spec>

View File

@@ -1297,9 +1297,13 @@ function octal(decimal) parseInt(decimal, 8);
* function. * function.
* *
* @param {object} obj * @param {object} obj
* @param {nsIJSIID} iface The interface to which to query all elements.
* @returns {Generator} * @returns {Generator}
*/ */
function iter(obj) { function iter(obj, iface) {
if (arguments.length == 2 && iface instanceof Ci.nsIJSIID)
return iter(obj).map(function (item) item.QueryInterface(iface));
let args = arguments; let args = arguments;
let res = Iterator(obj); let res = Iterator(obj);

View File

@@ -369,20 +369,18 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
prefToArg: function (pref) pref.replace(/.*\./, "").toLowerCase(), prefToArg: function (pref) pref.replace(/.*\./, "").toLowerCase(),
iterCookies: function iterCookies(host) { iterCookies: function iterCookies(host) {
for (let c in iter(services.cookies)) { for (let c in iter(services.cookies, Ci.nsICookie2))
c.QueryInterface(Ci.nsICookie2); if (!host || util.isSubdomain(c.rawHost, host) ||
if (!host || util.isSubdomain(c.rawHost, host) || c.host[0] == "." && c.host.length < host.length && host.indexOf(c.host) == host.length - c.host.length) c.host[0] == "." && c.host.length < host.length
&& host.indexOf(c.host) == host.length - c.host.length)
yield c; yield c;
}
}, },
iterPermissions: function iterPermissions(host) { iterPermissions: function iterPermissions(host) {
for (let p in iter(services.permissions)) { for (let p in iter(services.permissions, Ci.nsIPermission))
p.QueryInterface(Ci.nsIPermission);
if (!host || util.isSubdomain(p.host, host)) if (!host || util.isSubdomain(p.host, host))
yield p; yield p;
} }
}
}, { }, {
load: function (dactyl, modules, window) { load: function (dactyl, modules, window) {
if (!sanitizer.firstRun++ && sanitizer.runAtShutdown && !sanitizer.ranAtShutdown) if (!sanitizer.firstRun++ && sanitizer.runAtShutdown && !sanitizer.ranAtShutdown)
@@ -390,16 +388,18 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
sanitizer.ranAtShutdown = false; sanitizer.ranAtShutdown = false;
}, },
autocommands: function (dactyl, modules, window) { autocommands: function (dactyl, modules, window) {
const { autocommands } = modules;
storage.addObserver("private-mode", storage.addObserver("private-mode",
function (key, event, value) { function (key, event, value) {
modules.autocommands.trigger("PrivateMode", { state: value }); autocommands.trigger("PrivateMode", { state: value });
}, window); }, window);
storage.addObserver("sanitizer", storage.addObserver("sanitizer",
function (key, event, value) { function (key, event, value) {
if (event == "domain") if (event == "domain")
modules.autocommands.trigger("SanitizeDomain", { domain: value }); autocommands.trigger("SanitizeDomain", { domain: value });
else if (!value[1]) else if (!value[1])
modules.autocommands.trigger("Sanitize", { name: event.substr("clear-".length), domain: value[1] }); autocommands.trigger("Sanitize", { name: event.substr("clear-".length), domain: value[1] });
}, window); }, window);
}, },
commands: function (dactyl, modules, window) { commands: function (dactyl, modules, window) {

View File

@@ -78,6 +78,7 @@
- It's now possible to map keys in many more modes, including - It's now possible to map keys in many more modes, including
Hint, Multi-line Output, and Menu. [b4] Hint, Multi-line Output, and Menu. [b4]
- <C-o> and <C-i> now behave more like Vim. [b8] - <C-o> and <C-i> now behave more like Vim. [b8]
- Add n_s and n_S. [b8]
- Added Operator mode for motion maps, per Vim. [b8] - Added Operator mode for motion maps, per Vim. [b8]
- Added site-specific mapping groups and related command - Added site-specific mapping groups and related command
changes. [b6] changes. [b6]