1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 21:37:57 +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:
Kris Maglione
2010-12-18 13:47:56 -05:00
parent 3414138989
commit 2a27292e8b
8 changed files with 46 additions and 25 deletions

View File

@@ -165,6 +165,7 @@ const CommandWidgets = Class("CommandWidgets", {
completionContainer: Class.memoize(function () this.completionList.parentNode),
multilineOutput: Class.memoize(function () {
let elem = document.getElementById("dactyl-multiline-output");
elem.contentWindow.addEventListener("unload", function (event) { event.preventDefault(); }, true);
elem.contentDocument.body.id = "dactyl-multiline-output-content";
["copy", "copylink", "selectall"].forEach(function (tail) {
// some host apps use "hostPrefixContext-copy" ids
@@ -942,6 +943,7 @@ const CommandLine = Module("commandline", {
let command = event.originalTarget.getAttributeNS(NS.uri, "command");
if (command && dactyl.commands[command]) {
event.preventDefault();
return dactyl.withSavedValues(["forceNewTab"], function () {
dactyl.forceNewTab = event.ctrlKey || event.shiftKey || event.button == 1;
dactyl.commands[command](event);

View File

@@ -1400,7 +1400,8 @@ const Commands = Module("commands", {
description: "List all Ex commands along with their short descriptions",
iterate: function (args) commands,
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
}
});

View File

@@ -221,10 +221,9 @@ const ConfigBase = Class(ModuleBase, {
Keyword color: red;
Tag color: blue;
Usage
LineInfo
Usage>LineInfo display: none;
Usage:hover>LineInfo display: inline;
Usage position: relative;
Usage>LineInfo position: absolute; left: 100%; padding: 0 1em; background: white;
Usage:not(:hover)>LineInfo opacity: 0; width: 1px; overflow: hidden;
!StatusLine color: white !important; background: black !important
StatusLineBroken color: black !important; background: #FFa0a0 !important /* light-red */

View File

@@ -50,7 +50,8 @@ const Dactyl = Module("dactyl", {
this.observers = {};
this.commands["dactyl.help"] = function (event) {
dactyl.help(event.originalTarget.textContent);
let elem = event.originalTarget;
dactyl.help(elem.getAttribute("tag") || elem.textContent);
};
},

View File

@@ -302,7 +302,9 @@ const Hints = Module("hints", {
if (!isVisible(elem))
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);
else if (elem.firstElementChild instanceof HTMLImageElement && /^\s*$/.test(elem.textContent))
[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.
*/
_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)
highlight.highlightNode(elem, prefix + "HintActive");
else if (active != null)
highlight.highlightNode(elem, prefix + "HintElem");
else
elem.removeAttributeNS(NS, "highlight");
else {
highlight.highlightNode(elem, elem.dactylHighlight);
delete elem.dactylHighlight;
}
},
/**
@@ -402,7 +409,7 @@ const Hints = Module("hints", {
hint.imgSpan.style.display = (valid ? "" : "none");
if (!valid) {
hint.elem.removeAttributeNS(NS, "highlight");
this._setClass(hint.elem, null);
continue inner;
}
@@ -471,7 +478,7 @@ const Hints = Module("hints", {
for (let elem in util.evaluateXPath("//*[@dactyl:highlight='hints']", doc))
elem.parentNode.removeChild(elem);
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");

View File

@@ -527,7 +527,9 @@ const Mappings = Module("mappings", {
? <span highlight="URLExtra">(passed by {template.helpLink("'passkeys'")})</span>
: <></>}
{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 : ""
}
}

View File

@@ -843,7 +843,8 @@ const Options = Module("options", {
{opt.scope == Option.SCOPE_LOCAL
? <span highlight="URLExtra">(buffer local)</span> : ""}
{template.linkifyHelp(opt.description)}
</>)
</>),
help: function (opt) "'" + opt.name + "'"
}
});

View File

@@ -79,14 +79,14 @@ const Template = Module("Template", {
// </e4x>
},
helpLink: function (topic, type) {
helpLink: function (topic, text, type) {
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;
type = type || /^'.*'$/.test(topic) ? "HelpOpt" :
/^:\w/.test(topic) ? "HelpEx" : "HelpKey";
return <a highlight={type} href={"dactyl://help-tag/" + topic} dactyl:command="dactyl.help" xmlns:dactyl={NS}>{topic}</a>
type = type || (/^'.*'$/.test(topic) ? "HelpOpt" :
/^:\w/.test(topic) ? "HelpEx" : "HelpKey");
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
@@ -314,17 +314,25 @@ const Template = Module("Template", {
usage: function usage(iter, format) {
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
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>
return <table>
{
this.map(iter, function (item)
<tr>
<td style="padding-right: 20px" highlight="Usage">{
<td style="padding-right: 3em;">
<span highlight="Usage">{
let (name = item.name || item.names[0], frame = item.definedAt)
!frame ? name :
<span highlight="Title">{name}</span> + <> </> +
<span highlight="LineInfo">Defined at {template.sourceLink(frame)}</span>
}</td>
template.helpLink(help(item), name, "Title") +
<span highlight="LineInfo" xmlns:dactyl={NS}>Defined at {sourceLink(frame)}</span>
}</span>
</td>
<td>{desc(item)}</td>
</tr>)
}