diff options
author | Kris Maglione <maglione.k@gmail.com> | 2010-10-04 16:45:39 -0400 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2010-10-04 16:45:39 -0400 |
commit | 476c908da12dabdc14e4cef5c1e7d61dc9746e08 (patch) | |
tree | f09a8c7a33775145fe7d872b8329e6008cb89e0a | |
parent | 1d5eb0f9910eeea871c6c67e8d3acd9837392db0 (diff) | |
download | pentadactyl-476c908da12dabdc14e4cef5c1e7d61dc9746e08.tar.gz |
Make 'mapleader' an option and fix the help fragment scrolling issue.
-rw-r--r-- | common/content/dactyl.js | 6 | ||||
-rw-r--r-- | common/content/events.js | 2 | ||||
-rw-r--r-- | common/content/help.js | 7 | ||||
-rw-r--r-- | common/content/hints.js | 4 | ||||
-rw-r--r-- | common/content/mappings.js | 16 | ||||
-rw-r--r-- | common/locale/en-US/map.xml | 8 | ||||
-rw-r--r-- | common/locale/en-US/options.xml | 10 | ||||
-rw-r--r-- | pentadactyl/NEWS | 2 | ||||
-rw-r--r-- | pentadactyl/TODO | 1 |
9 files changed, 34 insertions, 22 deletions
diff --git a/common/content/dactyl.js b/common/content/dactyl.js index e2ce6921..a19dd8a6 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -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>, * <b>Map</b> or <b>Option</b> object @@ -642,7 +642,7 @@ const Dactyl = Module("dactyl", { let br = <> </>; - return <> + dactyl.clipboardWrite(<> <item> <tags>{template.map(obj.names, tag, " ")}</tags> <spec>{spec((obj.specs || obj.names)[0])}</spec>{ @@ -654,7 +654,7 @@ const Dactyl = Module("dactyl", { extraHelp ? br+extraHelp : "" }{ !(extraHelp || obj.description) ? br+<p>Sorry, no help available.</p> : "" } </description> - </item></>.toXMLString(); + </item></>.toXMLString(), true); }, diff --git a/common/content/events.js b/common/content/events.js index 1158fd03..2102cba7 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -892,7 +892,7 @@ const Events = Module("events", { if (modes.extended & modes.HINTS) { // under HINT mode, certain keys are redirected to hints.onEvent if (key == "<Return>" || key == "<Tab>" || key == "<S-Tab>" - || key == mappings.mapLeader + || key == options["mapleader"] || (key == "<BS>" && hints.prevInput == "number") || (hints.isHintKey(key) && !hints.escNumbers)) { hints.onEvent(event); diff --git a/common/content/help.js b/common/content/help.js index 092678aa..3b23994f 100644 --- a/common/content/help.js +++ b/common/content/help.js @@ -8,8 +8,13 @@ function checkFragment() { document.title = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "title")[0].textContent; var frag = document.location.hash.substr(1); var elem = document.getElementById(frag); - if (elem) + function action() { window.content.scrollTo(0, window.content.scrollY + elem.getBoundingClientRect().top - 10); // 10px context + } + if (elem) { + action(); + setTimeout(action, 10); + } } document.addEventListener("load", checkFragment, true); diff --git a/common/content/hints.js b/common/content/hints.js index 73bfedf5..a5638970 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -96,7 +96,7 @@ const Hints = Module("hints", { * Display the current status to the user. */ _updateStatusline: function () { - statusline.updateInputBuffer((hints.escNumbers ? mappings.mapLeader : "") + + statusline.updateInputBuffer((hints.escNumbers ? options["mapleader"] : "") + (this._hintNumber ? this.getHintString(this._hintNumber) : "")); }, @@ -863,7 +863,7 @@ const Hints = Module("hints", { } break; - case mappings.mapLeader: + case options["mapleader"]: hints.escNumbers = !hints.escNumbers; if (hints.escNumbers && this._usedTabKey) this._hintNumber = 0; diff --git a/common/content/mappings.js b/common/content/mappings.js index 040d552b..84d3be1e 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -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 _mappingsIterator: function (modes, stack) { @@ -289,15 +289,6 @@ const Mappings = Module("mappings", { 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 * specified <b>mode</b>. @@ -589,6 +580,11 @@ const Mappings = Module("mappings", { this._main[mode] = []; this._user[mode] = []; } + }, + options: function () { + options.add(["mapleader", "ml"], + "Defines the replacement keys for the <Leader> pseudo-key", + "string", "\\"); } }); diff --git a/common/locale/en-US/map.xml b/common/locale/en-US/map.xml index b50a9bf9..a1c8a1b9 100644 --- a/common/locale/en-US/map.xml +++ b/common/locale/en-US/map.xml @@ -349,19 +349,19 @@ </item> <item> - <tags><![CDATA[<Leader> mapleader \]]></tags> + <tags><![CDATA[<Leader> \]]></tags> <strut/> <spec><Leader></spec> <description> <p> - Expands to the value of the ‘mapleader’ variable in key mapping. If - ‘mapleader’ is unset or empty then ‘\’ is used. For example, by default, + A pseudo-key which expands to the value of the <o>mapleader</o> + option. For example, by default, </p> <code><ex>:map <k name="Leader"/>h</ex> <ex>:echo <str>Hello</str><k name="CR"/></ex></code> <p>works like</p> <code><ex>:map \h</ex> <ex>:echo <str>Hello</str><k name="CR"/></ex></code> <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> <code><ex>:map ,h</ex> <ex>:echo <str>Hello</str><k name="CR"/></ex></code> </description> diff --git a/common/locale/en-US/options.xml b/common/locale/en-US/options.xml index a94d3978..720235f9 100644 --- a/common/locale/en-US/options.xml +++ b/common/locale/en-US/options.xml @@ -926,6 +926,16 @@ </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> <tags>'maxitems'</tags> <spec>'maxitems'</spec> <type>number</type> diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS index 3ac303df..bb041635 100644 --- a/pentadactyl/NEWS +++ b/pentadactyl/NEWS @@ -46,6 +46,8 @@ * IMPORTANT: 'extendedhinttags' is now a regexmap rather than a string. * 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 "bookmarks", "diverted", and "links" to 'activate' option diff --git a/pentadactyl/TODO b/pentadactyl/TODO index 07082469..abf079af 100644 --- a/pentadactyl/TODO +++ b/pentadactyl/TODO @@ -27,7 +27,6 @@ BUGS: FEATURES: 9 Add quoting help tag 8 Document Caret and Visual modes. -8 make 'mapleader' an option 8 replace global variables with plugin scoped user options 8 fix local options 8 adaptive timeout for auto-completions, :set completions can be updated more often than |