X-Git-Url: https://git.donarmstrong.com/dactyl.git?a=blobdiff_plain;f=common%2Fcontent%2Fmodes.js;h=50b2ee5b16f4570025d76636cb7bf1ebc74f70ca;hb=9044153cb63835e39b9de8ec4ade237c03e3888a;hp=c498830903670defc855de8d4e1723fe4acc806b;hpb=70740024f9c028c1fd63e1a1850ab062ff956054;p=dactyl.git diff --git a/common/content/modes.js b/common/content/modes.js index c498830..50b2ee5 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -4,7 +4,7 @@ // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -"use strict"; +/* use strict */ /** @scope modules */ @@ -57,24 +57,8 @@ var Modes = Module("modes", { description: "Active when nothing is focused", bases: [this.COMMAND] }); - this.addMode("VISUAL", { - char: "v", - description: "Active when text is selected", - display: function () "VISUAL" + (this._extended & modes.LINE ? " LINE" : ""), - bases: [this.COMMAND], - ownsFocus: true - }, { - leave: function (stack, newMode) { - if (newMode.main == modes.CARET) { - let selection = content.getSelection(); - if (selection && !selection.isCollapsed) - selection.collapseToStart(); - } - else if (stack.pop) - editor.unselectText(); - } - }); this.addMode("CARET", { + char: "caret", description: "Active when the caret is visible in the web content", bases: [this.NORMAL] }, { @@ -87,6 +71,8 @@ var Modes = Module("modes", { modes.pop(); else if (!stack.pop && !this.pref) this.pref = true; + if (!stack.pop) + buffer.resetCaret(); }, leave: function (stack) { @@ -94,27 +80,6 @@ var Modes = Module("modes", { this.pref = false; } }); - this.addMode("TEXT_EDIT", { - char: "t", - description: "Vim-like editing of input elements", - bases: [this.COMMAND], - ownsFocus: true - }, { - onKeyPress: function (eventList) { - const KILL = false, PASS = true; - - // Hack, really. - if (eventList[0].charCode || /^<(?:.-)*(?:BS|Del|C-h|C-w|C-u|C-k)>$/.test(events.toString(eventList[0]))) { - dactyl.beep(); - return KILL; - } - return PASS; - } - }); - this.addMode("OUTPUT_MULTILINE", { - description: "Active when the multi-line output buffer is open", - bases: [this.NORMAL] - }); this.addMode("INPUT", { char: "I", @@ -122,20 +87,10 @@ var Modes = Module("modes", { bases: [this.MAIN], insert: true }); - this.addMode("INSERT", { - char: "i", - description: "Active when an input element is focused", - insert: true, - ownsFocus: true - }); - this.addMode("AUTOCOMPLETE", { - description: "Active when an input autocomplete pop-up is active", - display: function () "AUTOCOMPLETE (insert)", - bases: [this.INSERT] - }); this.addMode("EMBED", { description: "Active when an or element is focused", + bases: [modes.MAIN], insert: true, ownsFocus: true, passthrough: true @@ -207,69 +162,36 @@ var Modes = Module("modes", { } }); - - function makeTree() { - let list = modes.all.filter(function (m) m.name !== m.description); - - let tree = {}; - - for (let mode in values(list)) - tree[mode.name] = {}; - - for (let mode in values(list)) - for (let base in values(mode.bases)) - tree[base.name][mode.name] = tree[mode.name]; - - let roots = iter([m.name, tree[m.name]] for (m in values(list)) if (!m.bases.length)).toObject(); - - default xml namespace = NS; - function rec(obj) { - XML.ignoreWhitespace = XML.prettyPrinting = false; - - let res =