aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-01-19 16:13:53 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-01-19 16:13:53 -0500
commit40be400ecca8c370afa31b60d8f779654b87d1b0 (patch)
treee48b90aceb12c67155735303fd4143b2eac71c85
parent8c2607133c1147eee5588738c9b05467b799b127 (diff)
Go to help page with right-click or modified-click in keybar
-rw-r--r--docs/repl.js13
-rw-r--r--docs/try.html1
2 files changed, 12 insertions, 2 deletions
diff --git a/docs/repl.js b/docs/repl.js
index 7180ec53..cf7a9071 100644
--- a/docs/repl.js
+++ b/docs/repl.js
@@ -86,11 +86,12 @@ sysvals.setplot = (x,w) => { startPlot(); setPlot(x,w); }
let keymode=0; // 1 for prefix
let prefix='\\';
+let modified=ev=>ev.shiftKey||ev.ctrlKey||ev.altKey||ev.metaKey;
doc.code.onkeydown = ev => {
let k = ev.which;
if (16<=k && k<=20) {
return;
- } if (k==13 && (ev.shiftKey||ev.ctrlKey||ev.altKey||ev.metaKey)) { // *-enter
+ } if (k==13 && modified(ev)) { // *-enter
repl(); return false;
} if (keymode) {
keymode = 0;
@@ -128,6 +129,7 @@ let setPrefix = () => {
let c = Array.from(d)[1];
let t = d.slice(1+c.length).replace(';','\n');
let k = revkeys[c]; if (k) t += '\n'+prefix+(k==='"'?'&quot;':k);
+ x.hashelp = i < 64;
x.title = primhelp[c] = t;
});
}
@@ -135,7 +137,14 @@ setPrefix();
doc.kb.onmousedown = ev => {
let t = ev.target;
if (t.nodeName === 'SPAN') {
- return typeChar(doc.code, t.textContent, ev);
+ if (ev.button || modified(ev)) {
+ let name = t.title.toLowerCase().replace(/ |\n\\.*/g,'')
+ .replace(/[\n/]/g,'_');
+ if (t.hashelp) window.open('help/'+name+'.html');
+ return false;
+ } else {
+ return typeChar(doc.code, t.textContent, ev);
+ }
}
}
diff --git a/docs/try.html b/docs/try.html
index 65b462f4..5b4526b9 100644
--- a/docs/try.html
+++ b/docs/try.html
@@ -32,6 +32,7 @@
<ul>
<li>Documentation links for primitives are <a href="doc/primitive.html#functions">here</a>.</li>
<li>You can type special characters with a back<em>slash</em> prefix, as shown by hovering over the character bar above. Customize the prefix with the input at the right.</li>
+ <li>Right- or modified click on a primitive to go to its help page!</li>
<li>Any modifier with enter will execute, not just shift.</li>
<li>The code window is vertically resizeable.</li>
</ul>