mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-19 16:27:58 +01:00
Add missing docs and make 'showmode' a stringlist like 'passunknown' rather than a regexplist.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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"],
|
||||
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;
|
||||
|
||||
return set.has(this.valueMap, val) ? this.valueMap[val] : default_;
|
||||
},
|
||||
|
||||
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] !== "!"
|
||||
}));
|
||||
|
||||
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)),
|
||||
|
||||
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",
|
||||
{
|
||||
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;
|
||||
|
||||
return set.has(this.valueMap, val) ? this.valueMap[val] : default_;
|
||||
},
|
||||
|
||||
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] !== "!"
|
||||
}));
|
||||
|
||||
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)),
|
||||
|
||||
get values() array.toObject([[m.name.toLowerCase(), m.description] for (m in values(modes._modes)) if (!m.hidden)])
|
||||
});
|
||||
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));
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1143,6 +1143,21 @@
|
||||
</description>
|
||||
</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>
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 : "")),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user