diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/content/editor.js | 13 | ||||
-rw-r--r-- | common/content/events.js | 2 | ||||
-rw-r--r-- | common/content/modes.js | 42 |
3 files changed, 47 insertions, 10 deletions
diff --git a/common/content/editor.js b/common/content/editor.js index 7c7a79d2..35aff712 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -653,11 +653,16 @@ var Editor = Module("editor", { modes.push(modes.TEXT_EDIT); }); - mappings.add([modes.INPUT], - ["<BS>", "<Del>", "<Left>", "<Right>", "<Up>", "<Down>", + // Ugh. + mappings.add([modes.INPUT, modes.CARET], + ["<CR>", "<BS>", "<Del>", "<Left>", "<Right>", "<Up>", "<Down>", "<Home>", "<End>", "<PageUp>", "<PageDown>", - "<C-BS>", "<C-Del>", "<C-Left>", "<C-Right>", "<C-Up>", "<C-Down>", - "<C-Home>", "<C-End>", "<C-PageUp>", "<C-PageDown>"], + "<C-CR>", "<C-BS>", "<C-Del>", "<C-Left>", "<C-Right>", "<C-Up>", "<C-Down>", + "<C-Home>", "<C-End>", "<C-PageUp>", "<C-PageDown>", + "<S-CR>", "<S-BS>", "<S-Del>", "<S-Left>", "<S-Right>", "<S-Up>", "<S-Down>", + "<S-Home>", "<S-End>", "<S-PageUp>", "<S-PageDown>", + "<C-S-CR>", "<C-S-BS>", "<C-S-Del>", "<C-S-Left>", "<C-S-Right>", "<C-S-Up>", "<C-S-Down>", + "<C-S-Home>", "<C-S-End>", "<C-S-PageUp>", "<C-S-PageDown>"], "Handled by " + config.host, function () Events.PASS); diff --git a/common/content/events.js b/common/content/events.js index 77847739..d3365c1f 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -44,7 +44,7 @@ var ProcessorStack = Class("ProcessorStack", { this.processors.unshift(KeyProcessor(modes.BASE, hive)); }, - passUnknown: Class.memoize(function () this.modes.some(function (m) m.passUnknown)), + passUnknown: Class.memoize(function () options.get("passunknown").getKey(this.modes)), notify: function () { events.keyEvents = []; diff --git a/common/content/modes.js b/common/content/modes.js index 0d286ffa..231de65f 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -100,6 +100,17 @@ var Modes = Module("modes", { bases: [this.COMMAND], input: true, 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", @@ -472,7 +483,7 @@ var Modes = Module("modes", { passEvent: function passEvent(event) this.input && event.charCode && !(event.ctrlKey || event.altKey || event.metaKey), - passUnknown: Class.memoize(function () options.get("passunknown").has(this.name)), + passUnknown: Class.memoize(function () options.get("passunknown").getKey(this.name)), get mask() this, @@ -547,14 +558,35 @@ var Modes = Module("modes", { "Pass through unknown keys in these modes", "stringlist", "", { - has: function (val) this.value.indexOf(val.toLowerCase()) >= 0, + completer: function completer(context, extra) { + if (extra.value && context.filter[0] == "!") + context.advance(1); + return completer.superapply(this, arguments); + }, + + getKey: function getKey(val, default_) { + if (isArray(val)) + return (array.nth(this.value, function (v) val.some(function (m) m.name === v.mode), 0) + || { result: default_ }).result; - setter: function (val) { + return set.has(this.valueMap, val) ? this.valueMap[val] : default_; + }, + + setter: function (vals) { modes.all.forEach(function (m) { delete m.passUnknown }); - return val.map(String.toLowerCase); + + vals = vals.map(function (v) update(new String(v.toLowerCase()), { + mode: v.replace(/^!/, "").toUpperCase(), + result: v[0] !== "!" + })); + + this.valueMap = values(vals).map(function (v) [v.mode, v.result]).toObject(); + return vals; }, - get values() [[m.name.toLowerCase(), m.description] for (m in values(modes._modes)) if (!m.hidden)] + validator: function validator(vals) vals.map(function (v) v.replace(/^!/, "")).every(set.has(this.values)), + + get values() array.toObject([[m.name.toLowerCase(), m.description] for (m in values(modes._modes)) if (!m.hidden)]) }); options.add(["showmode", "smd"], |