1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 20:52:26 +01:00

Make 'mapleader' an option and fix the help fragment scrolling issue.

This commit is contained in:
Kris Maglione
2010-10-04 16:45:39 -04:00
parent 1d5eb0f991
commit 476c908da1
9 changed files with 34 additions and 22 deletions

View File

@@ -617,7 +617,7 @@ const Dactyl = Module("dactyl", {
}, },
/** /**
* Generates a help entry. * Generates a help entry and writes it to the clipboard.
* *
* @param {Command|Map|Option} obj A dactyl <b>Command</b>, * @param {Command|Map|Option} obj A dactyl <b>Command</b>,
* <b>Map</b> or <b>Option</b> object * <b>Map</b> or <b>Option</b> object
@@ -642,7 +642,7 @@ const Dactyl = Module("dactyl", {
let br = <> let br = <>
</>; </>;
return <> dactyl.clipboardWrite(<>
<item> <item>
<tags>{template.map(obj.names, tag, " ")}</tags> <tags>{template.map(obj.names, tag, " ")}</tags>
<spec>{spec((obj.specs || obj.names)[0])}</spec>{ <spec>{spec((obj.specs || obj.names)[0])}</spec>{
@@ -654,7 +654,7 @@ const Dactyl = Module("dactyl", {
extraHelp ? br+extraHelp : "" }{ extraHelp ? br+extraHelp : "" }{
!(extraHelp || obj.description) ? br+<p>Sorry, no help available.</p> : "" } !(extraHelp || obj.description) ? br+<p>Sorry, no help available.</p> : "" }
</description> </description>
</item></>.toXMLString(); </item></>.toXMLString(), true);
}, },

View File

@@ -892,7 +892,7 @@ const Events = Module("events", {
if (modes.extended & modes.HINTS) { if (modes.extended & modes.HINTS) {
// under HINT mode, certain keys are redirected to hints.onEvent // under HINT mode, certain keys are redirected to hints.onEvent
if (key == "<Return>" || key == "<Tab>" || key == "<S-Tab>" if (key == "<Return>" || key == "<Tab>" || key == "<S-Tab>"
|| key == mappings.mapLeader || key == options["mapleader"]
|| (key == "<BS>" && hints.prevInput == "number") || (key == "<BS>" && hints.prevInput == "number")
|| (hints.isHintKey(key) && !hints.escNumbers)) { || (hints.isHintKey(key) && !hints.escNumbers)) {
hints.onEvent(event); hints.onEvent(event);

View File

@@ -8,8 +8,13 @@ function checkFragment() {
document.title = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "title")[0].textContent; document.title = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "title")[0].textContent;
var frag = document.location.hash.substr(1); var frag = document.location.hash.substr(1);
var elem = document.getElementById(frag); var elem = document.getElementById(frag);
if (elem) function action() {
window.content.scrollTo(0, window.content.scrollY + elem.getBoundingClientRect().top - 10); // 10px context window.content.scrollTo(0, window.content.scrollY + elem.getBoundingClientRect().top - 10); // 10px context
}
if (elem) {
action();
setTimeout(action, 10);
}
} }
document.addEventListener("load", checkFragment, true); document.addEventListener("load", checkFragment, true);

View File

@@ -96,7 +96,7 @@ const Hints = Module("hints", {
* Display the current status to the user. * Display the current status to the user.
*/ */
_updateStatusline: function () { _updateStatusline: function () {
statusline.updateInputBuffer((hints.escNumbers ? mappings.mapLeader : "") + statusline.updateInputBuffer((hints.escNumbers ? options["mapleader"] : "") +
(this._hintNumber ? this.getHintString(this._hintNumber) : "")); (this._hintNumber ? this.getHintString(this._hintNumber) : ""));
}, },
@@ -863,7 +863,7 @@ const Hints = Module("hints", {
} }
break; break;
case mappings.mapLeader: case options["mapleader"]:
hints.escNumbers = !hints.escNumbers; hints.escNumbers = !hints.escNumbers;
if (hints.escNumbers && this._usedTabKey) if (hints.escNumbers && this._usedTabKey)
this._hintNumber = 0; this._hintNumber = 0;

View File

@@ -174,7 +174,7 @@ const Mappings = Module("mappings", {
} }
}, },
_expandLeader: function (keyString) keyString.replace(/<Leader>/i, mappings.mapLeader), _expandLeader: function (keyString) keyString.replace(/<Leader>/i, options["mapleader"]),
// Return all mappings present in all @modes // Return all mappings present in all @modes
_mappingsIterator: function (modes, stack) { _mappingsIterator: function (modes, stack) {
@@ -289,15 +289,6 @@ const Mappings = Module("mappings", {
return matches; return matches;
}, },
/*
* @property {string} The map leader string used to replace the special
* token "<Leader>" when user mappings are defined.
*/
get mapLeader() dactyl.globalVariables["mapleader"] || "\\",
/** @deprecated */
getMapLeader: function () this.mapLeader,
/** /**
* Returns whether there is a user-defined mapping <b>cmd</b> for the * Returns whether there is a user-defined mapping <b>cmd</b> for the
* specified <b>mode</b>. * specified <b>mode</b>.
@@ -589,6 +580,11 @@ const Mappings = Module("mappings", {
this._main[mode] = []; this._main[mode] = [];
this._user[mode] = []; this._user[mode] = [];
} }
},
options: function () {
options.add(["mapleader", "ml"],
"Defines the replacement keys for the <Leader> pseudo-key",
"string", "\\");
} }
}); });

View File

@@ -349,19 +349,19 @@
</item> </item>
<item> <item>
<tags><![CDATA[<Leader> mapleader \]]></tags> <tags><![CDATA[<Leader> \]]></tags>
<strut/> <strut/>
<spec>&lt;Leader></spec> <spec>&lt;Leader></spec>
<description> <description>
<p> <p>
Expands to the value of the mapleader variable in key mapping. If A pseudo-key which expands to the value of the <o>mapleader</o>
mapleader is unset or empty then \ is used. For example, by default, option. For example, by default,
</p> </p>
<code><ex>:map <k name="Leader"/>h</ex> <ex>:echo <str>Hello</str><k name="CR"/></ex></code> <code><ex>:map <k name="Leader"/>h</ex> <ex>:echo <str>Hello</str><k name="CR"/></ex></code>
<p>works like</p> <p>works like</p>
<code><ex>:map \h</ex> <ex>:echo <str>Hello</str><k name="CR"/></ex></code> <code><ex>:map \h</ex> <ex>:echo <str>Hello</str><k name="CR"/></ex></code>
<p>but after</p> <p>but after</p>
<code><ex>:let mapleader = <str>,</str></ex></code> <code><ex>:set mapleader=<str>,</str></ex></code>
<p>it works like</p> <p>it works like</p>
<code><ex>:map ,h</ex> <ex>:echo <str>Hello</str><k name="CR"/></ex></code> <code><ex>:map ,h</ex> <ex>:echo <str>Hello</str><k name="CR"/></ex></code>
</description> </description>

View File

@@ -925,6 +925,16 @@
</description> </description>
</item> </item>
<item>
<tags>'ml' 'mapleader'</tags>
<spec>'mapleader'</spec>
<type>string</type>
<default>\</default>
<description>
<p>Defines the replacement keys for the <k name="Leader"/> pseudo-key.</p>
</description>
</item>
<item> <item>
<tags>'maxitems'</tags> <tags>'maxitems'</tags>
<spec>'maxitems'</spec> <spec>'maxitems'</spec>

View File

@@ -46,6 +46,8 @@
* IMPORTANT: 'extendedhinttags' is now a regexmap rather than a * IMPORTANT: 'extendedhinttags' is now a regexmap rather than a
string. string.
* IMPORTANT: 'guioptions' default value has changed. * IMPORTANT: 'guioptions' default value has changed.
* IMPORTANT: 'mapleader' is now an option rather than a :let
variable.
* Added g; continued extended hint mode and removed ;F * Added g; continued extended hint mode and removed ;F
* Added "bookmarks", "diverted", and "links" to 'activate' * Added "bookmarks", "diverted", and "links" to 'activate'
option option

View File

@@ -27,7 +27,6 @@ BUGS:
FEATURES: FEATURES:
9 Add quoting help tag 9 Add quoting help tag
8 Document Caret and Visual modes. 8 Document Caret and Visual modes.
8 make 'mapleader' an option
8 replace global variables with plugin scoped user options 8 replace global variables with plugin scoped user options
8 fix local options 8 fix local options
8 adaptive timeout for auto-completions, :set completions can be updated more often than 8 adaptive timeout for auto-completions, :set completions can be updated more often than