mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 16:17:59 +01:00
Make source linkfication in :list* less annoying. Add help linkification to the entries. Make source links hintable.
--HG-- extra : rebase_source : 793a9d6a6d84dc3c2f8dc2dd5d0ad468e565b1c4
This commit is contained in:
@@ -165,6 +165,7 @@ const CommandWidgets = Class("CommandWidgets", {
|
|||||||
completionContainer: Class.memoize(function () this.completionList.parentNode),
|
completionContainer: Class.memoize(function () this.completionList.parentNode),
|
||||||
multilineOutput: Class.memoize(function () {
|
multilineOutput: Class.memoize(function () {
|
||||||
let elem = document.getElementById("dactyl-multiline-output");
|
let elem = document.getElementById("dactyl-multiline-output");
|
||||||
|
elem.contentWindow.addEventListener("unload", function (event) { event.preventDefault(); }, true);
|
||||||
elem.contentDocument.body.id = "dactyl-multiline-output-content";
|
elem.contentDocument.body.id = "dactyl-multiline-output-content";
|
||||||
["copy", "copylink", "selectall"].forEach(function (tail) {
|
["copy", "copylink", "selectall"].forEach(function (tail) {
|
||||||
// some host apps use "hostPrefixContext-copy" ids
|
// some host apps use "hostPrefixContext-copy" ids
|
||||||
@@ -942,6 +943,7 @@ const CommandLine = Module("commandline", {
|
|||||||
|
|
||||||
let command = event.originalTarget.getAttributeNS(NS.uri, "command");
|
let command = event.originalTarget.getAttributeNS(NS.uri, "command");
|
||||||
if (command && dactyl.commands[command]) {
|
if (command && dactyl.commands[command]) {
|
||||||
|
event.preventDefault();
|
||||||
return dactyl.withSavedValues(["forceNewTab"], function () {
|
return dactyl.withSavedValues(["forceNewTab"], function () {
|
||||||
dactyl.forceNewTab = event.ctrlKey || event.shiftKey || event.button == 1;
|
dactyl.forceNewTab = event.ctrlKey || event.shiftKey || event.button == 1;
|
||||||
dactyl.commands[command](event);
|
dactyl.commands[command](event);
|
||||||
|
|||||||
@@ -1400,7 +1400,8 @@ const Commands = Module("commands", {
|
|||||||
description: "List all Ex commands along with their short descriptions",
|
description: "List all Ex commands along with their short descriptions",
|
||||||
iterate: function (args) commands,
|
iterate: function (args) commands,
|
||||||
format: {
|
format: {
|
||||||
description: function (cmd) template.linkifyHelp(cmd.description + (cmd.replacementText ? ": " + cmd.action : ""))
|
description: function (cmd) template.linkifyHelp(cmd.description + (cmd.replacementText ? ": " + cmd.action : "")),
|
||||||
|
help: function (cmd) ":" + cmd.name
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -221,10 +221,9 @@ const ConfigBase = Class(ModuleBase, {
|
|||||||
Keyword color: red;
|
Keyword color: red;
|
||||||
Tag color: blue;
|
Tag color: blue;
|
||||||
|
|
||||||
Usage
|
Usage position: relative;
|
||||||
LineInfo
|
Usage>LineInfo position: absolute; left: 100%; padding: 0 1em; background: white;
|
||||||
Usage>LineInfo display: none;
|
Usage:not(:hover)>LineInfo opacity: 0; width: 1px; overflow: hidden;
|
||||||
Usage:hover>LineInfo display: inline;
|
|
||||||
|
|
||||||
!StatusLine color: white !important; background: black !important
|
!StatusLine color: white !important; background: black !important
|
||||||
StatusLineBroken color: black !important; background: #FFa0a0 !important /* light-red */
|
StatusLineBroken color: black !important; background: #FFa0a0 !important /* light-red */
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ const Dactyl = Module("dactyl", {
|
|||||||
this.observers = {};
|
this.observers = {};
|
||||||
|
|
||||||
this.commands["dactyl.help"] = function (event) {
|
this.commands["dactyl.help"] = function (event) {
|
||||||
dactyl.help(event.originalTarget.textContent);
|
let elem = event.originalTarget;
|
||||||
|
dactyl.help(elem.getAttribute("tag") || elem.textContent);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -302,7 +302,9 @@ const Hints = Module("hints", {
|
|||||||
if (!isVisible(elem))
|
if (!isVisible(elem))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (isinstance(elem, [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement]))
|
if (elem.hasAttributeNS(NS, "hint"))
|
||||||
|
[hint.text, hint.showText] = [elem.getAttributeNS(NS, "hint"), true];
|
||||||
|
else if (isinstance(elem, [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement]))
|
||||||
[hint.text, hint.showText] = this._getInputHint(elem, doc);
|
[hint.text, hint.showText] = this._getInputHint(elem, doc);
|
||||||
else if (elem.firstElementChild instanceof HTMLImageElement && /^\s*$/.test(elem.textContent))
|
else if (elem.firstElementChild instanceof HTMLImageElement && /^\s*$/.test(elem.textContent))
|
||||||
[hint.text, hint.showText] = [elem.firstElementChild.alt || elem.firstElementChild.title, true];
|
[hint.text, hint.showText] = [elem.firstElementChild.alt || elem.firstElementChild.title, true];
|
||||||
@@ -371,13 +373,18 @@ const Hints = Module("hints", {
|
|||||||
* @param {boolean} active Whether it is the currently active hint or not.
|
* @param {boolean} active Whether it is the currently active hint or not.
|
||||||
*/
|
*/
|
||||||
_setClass: function _setClass(elem, active) {
|
_setClass: function _setClass(elem, active) {
|
||||||
let prefix = (elem.getAttributeNS(NS, "hl") || "") + " ";
|
if (!("dactylHighlight" in elem))
|
||||||
|
elem.dactylHighlight = elem.getAttributeNS(NS, "highlight") || "";
|
||||||
|
|
||||||
|
let prefix = (elem.getAttributeNS(NS, "hl") || "") + " " + elem.dactylHighlight + " ";
|
||||||
if (active)
|
if (active)
|
||||||
highlight.highlightNode(elem, prefix + "HintActive");
|
highlight.highlightNode(elem, prefix + "HintActive");
|
||||||
else if (active != null)
|
else if (active != null)
|
||||||
highlight.highlightNode(elem, prefix + "HintElem");
|
highlight.highlightNode(elem, prefix + "HintElem");
|
||||||
else
|
else {
|
||||||
elem.removeAttributeNS(NS, "highlight");
|
highlight.highlightNode(elem, elem.dactylHighlight);
|
||||||
|
delete elem.dactylHighlight;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -402,7 +409,7 @@ const Hints = Module("hints", {
|
|||||||
hint.imgSpan.style.display = (valid ? "" : "none");
|
hint.imgSpan.style.display = (valid ? "" : "none");
|
||||||
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
hint.elem.removeAttributeNS(NS, "highlight");
|
this._setClass(hint.elem, null);
|
||||||
continue inner;
|
continue inner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +478,7 @@ const Hints = Module("hints", {
|
|||||||
for (let elem in util.evaluateXPath("//*[@dactyl:highlight='hints']", doc))
|
for (let elem in util.evaluateXPath("//*[@dactyl:highlight='hints']", doc))
|
||||||
elem.parentNode.removeChild(elem);
|
elem.parentNode.removeChild(elem);
|
||||||
for (let i in util.range(start, end + 1))
|
for (let i in util.range(start, end + 1))
|
||||||
this._pageHints[i].elem.removeAttributeNS(NS, "highlight");
|
this._setClass(this._pageHints[i].elem, null);
|
||||||
}
|
}
|
||||||
styles.removeSheet(true, "hint-positions");
|
styles.removeSheet(true, "hint-positions");
|
||||||
|
|
||||||
|
|||||||
@@ -527,7 +527,9 @@ const Mappings = Module("mappings", {
|
|||||||
? <span highlight="URLExtra">(passed by {template.helpLink("'passkeys'")})</span>
|
? <span highlight="URLExtra">(passed by {template.helpLink("'passkeys'")})</span>
|
||||||
: <></>}
|
: <></>}
|
||||||
{template.linkifyHelp(map.description + (map.rhs ? ": " + map.rhs : ""))}
|
{template.linkifyHelp(map.description + (map.rhs ? ": " + map.rhs : ""))}
|
||||||
</>)
|
</>),
|
||||||
|
help: function (map) let (char = array.compact(map.modes.map(function (m) m.char))[0])
|
||||||
|
char === "n" ? map.name : char ? char + "_" + map.name : ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -843,7 +843,8 @@ const Options = Module("options", {
|
|||||||
{opt.scope == Option.SCOPE_LOCAL
|
{opt.scope == Option.SCOPE_LOCAL
|
||||||
? <span highlight="URLExtra">(buffer local)</span> : ""}
|
? <span highlight="URLExtra">(buffer local)</span> : ""}
|
||||||
{template.linkifyHelp(opt.description)}
|
{template.linkifyHelp(opt.description)}
|
||||||
</>)
|
</>),
|
||||||
|
help: function (opt) "'" + opt.name + "'"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -79,14 +79,14 @@ const Template = Module("Template", {
|
|||||||
// </e4x>
|
// </e4x>
|
||||||
},
|
},
|
||||||
|
|
||||||
helpLink: function (topic, type) {
|
helpLink: function (topic, text, type) {
|
||||||
if (services["dactyl:"].initialized && !set.has(services["dactyl:"].HELP_TAGS, topic))
|
if (services["dactyl:"].initialized && !set.has(services["dactyl:"].HELP_TAGS, topic))
|
||||||
return <>{topic}</>;
|
return <span highlight={type || ""}>{text || topic}</span>;
|
||||||
|
|
||||||
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
|
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
|
||||||
type = type || /^'.*'$/.test(topic) ? "HelpOpt" :
|
type = type || (/^'.*'$/.test(topic) ? "HelpOpt" :
|
||||||
/^:\w/.test(topic) ? "HelpEx" : "HelpKey";
|
/^:\w/.test(topic) ? "HelpEx" : "HelpKey");
|
||||||
return <a highlight={type} href={"dactyl://help-tag/" + topic} dactyl:command="dactyl.help" xmlns:dactyl={NS}>{topic}</a>
|
return <a highlight={type} tag={topic} href={"dactyl://help-tag/" + topic} dactyl:command="dactyl.help" xmlns:dactyl={NS}>{text || topic}</a>
|
||||||
},
|
},
|
||||||
|
|
||||||
// if "processStrings" is true, any passed strings will be surrounded by " and
|
// if "processStrings" is true, any passed strings will be surrounded by " and
|
||||||
@@ -314,17 +314,25 @@ const Template = Module("Template", {
|
|||||||
usage: function usage(iter, format) {
|
usage: function usage(iter, format) {
|
||||||
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
|
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
|
||||||
let desc = format && format.description || function (item) template.linkifyHelp(item.description);
|
let desc = format && format.description || function (item) template.linkifyHelp(item.description);
|
||||||
|
let help = format && format.help || function (item) item.name;
|
||||||
|
function sourceLink(frame) {
|
||||||
|
let source = template.sourceLink(frame);
|
||||||
|
source.@NS::hint = source.text();
|
||||||
|
return source;
|
||||||
|
}
|
||||||
// <e4x>
|
// <e4x>
|
||||||
return <table>
|
return <table>
|
||||||
{
|
{
|
||||||
this.map(iter, function (item)
|
this.map(iter, function (item)
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-right: 20px" highlight="Usage">{
|
<td style="padding-right: 3em;">
|
||||||
let (name = item.name || item.names[0], frame = item.definedAt)
|
<span highlight="Usage">{
|
||||||
!frame ? name :
|
let (name = item.name || item.names[0], frame = item.definedAt)
|
||||||
<span highlight="Title">{name}</span> + <> </> +
|
!frame ? name :
|
||||||
<span highlight="LineInfo">Defined at {template.sourceLink(frame)}</span>
|
template.helpLink(help(item), name, "Title") +
|
||||||
}</td>
|
<span highlight="LineInfo" xmlns:dactyl={NS}>Defined at {sourceLink(frame)}</span>
|
||||||
|
}</span>
|
||||||
|
</td>
|
||||||
<td>{desc(item)}</td>
|
<td>{desc(item)}</td>
|
||||||
</tr>)
|
</tr>)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user