summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2011-03-26 15:27:59 -0400
committerKris Maglione <maglione.k@gmail.com>2011-03-26 15:27:59 -0400
commitd0831ec8e6efc27b335e65fbbfd36147f0a33aa7 (patch)
treea03242611d9eed7ed0148f0e6c14fc0ae2fc068f
parent204f8ca25c713e3420023786c37a31385bdbc4f3 (diff)
downloadpentadactyl-d0831ec8e6efc27b335e65fbbfd36147f0a33aa7.tar.gz
Add missing docs and make 'showmode' a stringlist like 'passunknown' rather than a regexplist.
-rw-r--r--common/content/dactyl.js4
-rw-r--r--common/content/modes.js113
-rw-r--r--common/locale/en-US/map.xml11
-rw-r--r--common/locale/en-US/options.xml23
-rw-r--r--common/locale/en-US/tabs.xml4
-rw-r--r--common/modules/commands.jsm2
-rw-r--r--common/modules/config.jsm5
-rw-r--r--pentadactyl/NEWS2
8 files changed, 126 insertions, 38 deletions
diff --git a/common/content/dactyl.js b/common/content/dactyl.js
index f5824435..1bb6a68a 100644
--- a/common/content/dactyl.js
+++ b/common/content/dactyl.js
@@ -605,6 +605,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
* Initialize the help system.
*/
initHelp: function (force) {
+ // Waits for the add-on to become available, if necessary.
+ config.addon;
+ config.version;
+
if (force || !this.helpInitialized) {
if ("noscriptOverlay" in window) {
noscriptOverlay.safeAllow("chrome-data:", true, false);
diff --git a/common/content/modes.js b/common/content/modes.js
index 2840ea6c..4976db15 100644
--- a/common/content/modes.js
+++ b/common/content/modes.js
@@ -207,6 +207,51 @@ var Modes = Module("modes", {
}
});
+
+ function makeTree() {
+ let list = modes.all.filter(function (m) m.name !== m.description);
+
+ let tree = {};
+
+ for (let mode in values(list))
+ tree[mode.name] = {};
+
+ for (let mode in values(list))
+ for (let base in values(mode.bases))
+ tree[base.name][mode.name] = tree[mode.name];
+
+ let roots = iter([m.name, tree[m.name]] for (m in values(list)) if (!m.bases.length)).toObject();
+
+ default xml namespace = NS;
+ function rec(obj) {
+ XML.ignoreWhitespace = XML.prettyPrinting = false;
+
+ let res = <ul dactyl:highlight="Dense" xmlns:dactyl={NS}/>;
+ Object.keys(obj).sort().forEach(function (mode) {
+ res.* += <li><em>{mode}</em>: {modes.getMode(mode).description}{
+ rec(obj[mode])
+ }</li>;
+ });
+
+ if (res.*.length())
+ return res;
+ return <></>;
+ }
+
+ return rec(roots).toXMLString();
+ }
+
+ util.timeout(function () {
+ // Waits for the add-on to become available, if necessary.
+ config.addon;
+ config.version;
+
+ services["dactyl:"].pages["modes.dtd"] = services["dactyl:"].pages["modes.dtd"]();
+ });
+
+ services["dactyl:"].pages["modes.dtd"] = function () [null,
+ util.makeDTD(iter({ "modes.tree": makeTree() },
+ config.dtd))];
},
cleanup: function cleanup() {
modes.reset();
@@ -278,9 +323,13 @@ var Modes = Module("modes", {
// show the current mode string in the command line
show: function show() {
+ if (!loaded.modes)
+ return;
+
let msg = null;
- if (options.get("showmode").getKey(this.main.name, true))
+ if (options.get("showmode").getKey([this.main].concat(this.main.allBases), false))
msg = this._getModeMessage();
+
if (msg || loaded.commandline)
commandline.widgets.mode = msg || null;
},
@@ -452,7 +501,7 @@ var Modes = Module("modes", {
this === obj || this.allBases.indexOf(obj) >= 0 || callable(obj) && this instanceof obj,
allBases: Class.memoize(function () {
- let seen = {}, res = [], queue = this.bases;
+ let seen = {}, res = [], queue = this.bases.slice();
for (let mode in array.iterValues(queue))
if (!set.add(seen, mode)) {
res.push(mode);
@@ -552,45 +601,47 @@ var Modes = Module("modes", {
function () { events.feedkeys("<Esc>"); });
},
options: function initOptions() {
- options.add(["passunknown"],
- "Pass through unknown keys in these modes",
- "stringlist", "!text_edit,!input,base",
- {
- completer: function completer(context, extra) {
- if (extra.value && context.filter[0] == "!")
- context.advance(1);
- return completer.superapply(this, arguments);
- },
+ let opts = {
+ completer: function completer(context, extra) {
+ if (extra.value && context.filter[0] == "!")
+ context.advance(1);
+ return completer.superapply(this, arguments);
+ },
- getKey: function getKey(val, default_) {
- if (isArray(val))
- return (array.nth(this.value, function (v) val.some(function (m) m.name === v.mode), 0)
- || { result: default_ }).result;
+ getKey: function getKey(val, default_) {
+ if (isArray(val))
+ return (array.nth(this.value, function (v) val.some(function (m) m.name === v.mode), 0)
+ || { result: default_ }).result;
- return set.has(this.valueMap, val) ? this.valueMap[val] : default_;
- },
+ return set.has(this.valueMap, val) ? this.valueMap[val] : default_;
+ },
- setter: function (vals) {
- modes.all.forEach(function (m) { delete m.passUnknown });
+ setter: function (vals) {
+ modes.all.forEach(function (m) { delete m.passUnknown });
- vals = vals.map(function (v) update(new String(v.toLowerCase()), {
- mode: v.replace(/^!/, "").toUpperCase(),
- result: v[0] !== "!"
- }));
+ vals = vals.map(function (v) update(new String(v.toLowerCase()), {
+ mode: v.replace(/^!/, "").toUpperCase(),
+ result: v[0] !== "!"
+ }));
- this.valueMap = values(vals).map(function (v) [v.mode, v.result]).toObject();
- return vals;
- },
+ this.valueMap = values(vals).map(function (v) [v.mode, v.result]).toObject();
+ return vals;
+ },
- validator: function validator(vals) vals.map(function (v) v.replace(/^!/, "")).every(set.has(this.values)),
+ validator: function validator(vals) vals.map(function (v) v.replace(/^!/, "")).every(set.has(this.values)),
- get values() array.toObject([[m.name.toLowerCase(), m.description] for (m in values(modes._modes)) if (!m.hidden)])
- });
+ get values() array.toObject([[m.name.toLowerCase(), m.description] for (m in values(modes._modes)) if (!m.hidden)])
+ };
+
+ options.add(["passunknown", "pu"],
+ "Pass through unknown keys in these modes",
+ "stringlist", "!text_edit,!input,base",
+ opts);
options.add(["showmode", "smd"],
"Show the current mode in the command line when it matches this expression",
- "regexplist", "!^normal$",
- { regexpFlags: "i" });
+ "stringlist", "!normal,base",
+ opts);
},
prefs: function initPrefs() {
prefs.watch("accessibility.browsewithcaret", function () modes.onCaretChange.apply(modes, arguments));
diff --git a/common/locale/en-US/map.xml b/common/locale/en-US/map.xml
index 7b777129..92b0291a 100644
--- a/common/locale/en-US/map.xml
+++ b/common/locale/en-US/map.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="dactyl://content/help.xsl"?>
-<!DOCTYPE document SYSTEM "dactyl://content/dtd">
+<!DOCTYPE document SYSTEM "dactyl://content/modes.dtd">
<document
name="map"
@@ -75,6 +75,15 @@
saved via the <ex>:mk&dactyl.name;rc</ex> command.
</warning>
+<p tag="modes">
+ The following tree represents all of the modes understood by
+ dactyl. Mappings for a mode also apply to its children and
+ descendants. So a mapping in the BASE mode, for instance, is
+ also active in NORMAL and EX mode.
+</p>
+
+&modes.tree;
+
<h3 tag=":map-commands">Map commands</h3>
<item>
diff --git a/common/locale/en-US/options.xml b/common/locale/en-US/options.xml
index b130321c..080fe4c1 100644
--- a/common/locale/en-US/options.xml
+++ b/common/locale/en-US/options.xml
@@ -1144,6 +1144,21 @@
</item>
<item>
+ <tags>'pu' 'passunknown'</tags>
+ <spec>'passunknown' 'pu'</spec>
+ <type>&option.showmode.type;</type>
+ <default>&option.showmode.default;</default>
+ <description>
+ <p>
+ Pass unknown keys through to &dactyl.host; in these
+ <t>modes</t>. The first element matching a currently
+ active mode is the one that takes effect. Modes may be
+ negated by prefixing them with a <tt>!</tt>.
+ </p>
+ </description>
+</item>
+
+<item>
<tags>'pps' 'popups'</tags>
<spec>'popups' 'pps'</spec>
<type>&option.popups.type;</type>
@@ -1330,13 +1345,17 @@
</item>
<item>
- <tags>'nosmd' 'noshowmode'</tags>
<tags>'smd' 'showmode'</tags>
<spec>'showmode' 'smd'</spec>
<type>&option.showmode.type;</type>
<default>&option.showmode.default;</default>
<description>
- <p>Show the current mode in the command line if it matches this expression.</p>
+ <p>
+ Show the current mode in the command line if it or any
+ of its parent <t>modes</t> is included in the list.
+ Modes may be negated by prefixing them with a
+ <tt>!</tt>.
+ </p>
</description>
</item>
diff --git a/common/locale/en-US/tabs.xml b/common/locale/en-US/tabs.xml
index 25e668c8..64138dcb 100644
--- a/common/locale/en-US/tabs.xml
+++ b/common/locale/en-US/tabs.xml
@@ -384,7 +384,7 @@
<h2 tag="app-tabs application-tabs pinned-tabs">Application Tabs</h2>
<item>
- <tags>pin pintab</tags>
+ <tags>:pin :pintab</tags>
<spec><oa>count</oa>pin<oa>tab</oa><oa>!</oa> <oa>arg</oa></spec>
<description>
<p>
@@ -396,7 +396,7 @@
</item>
<item>
- <tags>unpin unpintab</tags>
+ <tags>:unpin :unpintab</tags>
<spec><oa>count</oa>pin<oa>tab</oa> <oa>arg</oa></spec>
<description>
<p>
diff --git a/common/modules/commands.jsm b/common/modules/commands.jsm
index 7f40a961..3c60ad87 100644
--- a/common/modules/commands.jsm
+++ b/common/modules/commands.jsm
@@ -1573,7 +1573,7 @@ var Commands = Module("commands", {
]
})),
iterateIndex: function (args) let (tags = services["dactyl:"].HELP_TAGS)
- this.iterate(args).filter(function (cmd) cmd.hive === commands.builtin || set.has(cmd.helpTag)),
+ this.iterate(args).filter(function (cmd) cmd.hive === commands.builtin || set.has(tags, cmd.helpTag)),
format: {
headings: ["Command", "Group", "Description"],
description: function (cmd) template.linkifyHelp(cmd.description + (cmd.replacementText ? ": " + cmd.action : "")),
diff --git a/common/modules/config.jsm b/common/modules/config.jsm
index cb18251f..bc67e657 100644
--- a/common/modules/config.jsm
+++ b/common/modules/config.jsm
@@ -206,7 +206,7 @@ var ConfigBase = Class("ConfigBase", {
"version"
],
- helpStyles: /^(Help|StatusLine|REPL)|^(Boolean|Indicator|MoreMsg|Number|Object|Logo|Key(word)?|String)$/,
+ helpStyles: /^(Help|StatusLine|REPL)|^(Boolean|Dense|Indicator|MoreMsg|Number|Object|Logo|Key(word)?|String)$/,
styleHelp: function styleHelp() {
if (!this.helpStyled) {
const { highlight } = require("highlight");
@@ -457,6 +457,9 @@ var ConfigBase = Class("ConfigBase", {
CompMore::after content: "⌄";
+ Dense margin-top: 0; margin-bottom: 0;
+
+
EditorEditing;;* background: #bbb !important; -moz-user-input: none !important; -moz-user-modify: read-only !important;
EditorError;;* background: red !important;
EditorBlink1;;* background: yellow !important;
diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS
index f852b61b..79321c2d 100644
--- a/pentadactyl/NEWS
+++ b/pentadactyl/NEWS
@@ -181,8 +181,10 @@
triggers when the URL begins as above. [b1]
- Added 's' flag to 'pageinfo' and changed default value. [b7]
- Added 'passkeys' option. [b3]
+ - Added 'passunknown' option. [b7]
- Changed 'urlseparator' default value to "|". [b3]
- Added "passwords" and "venkman" dialogs to :dialog. [b2]
+ - Make 'showmode' a stringlist option. [b7]
- Added 'wildanchor' option. [b2]
- Added 'cookies', 'cookieaccept', and 'cookielifetime' options. [b3]
• Added BookmarkChange, BookmarkRemove autocommands. [b2]