mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-14 10:45:46 +01:00
Some 'passunknown' enhancements.
This commit is contained in:
@@ -653,11 +653,16 @@ var Editor = Module("editor", {
|
|||||||
modes.push(modes.TEXT_EDIT);
|
modes.push(modes.TEXT_EDIT);
|
||||||
});
|
});
|
||||||
|
|
||||||
mappings.add([modes.INPUT],
|
// Ugh.
|
||||||
["<BS>", "<Del>", "<Left>", "<Right>", "<Up>", "<Down>",
|
mappings.add([modes.INPUT, modes.CARET],
|
||||||
|
["<CR>", "<BS>", "<Del>", "<Left>", "<Right>", "<Up>", "<Down>",
|
||||||
"<Home>", "<End>", "<PageUp>", "<PageDown>",
|
"<Home>", "<End>", "<PageUp>", "<PageDown>",
|
||||||
"<C-BS>", "<C-Del>", "<C-Left>", "<C-Right>", "<C-Up>", "<C-Down>",
|
"<C-CR>", "<C-BS>", "<C-Del>", "<C-Left>", "<C-Right>", "<C-Up>", "<C-Down>",
|
||||||
"<C-Home>", "<C-End>", "<C-PageUp>", "<C-PageDown>"],
|
"<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,
|
"Handled by " + config.host,
|
||||||
function () Events.PASS);
|
function () Events.PASS);
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
|||||||
this.processors.unshift(KeyProcessor(modes.BASE, hive));
|
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 () {
|
notify: function () {
|
||||||
events.keyEvents = [];
|
events.keyEvents = [];
|
||||||
|
|||||||
@@ -100,6 +100,17 @@ var Modes = Module("modes", {
|
|||||||
bases: [this.COMMAND],
|
bases: [this.COMMAND],
|
||||||
input: true,
|
input: true,
|
||||||
ownsFocus: 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", {
|
this.addMode("OUTPUT_MULTILINE", {
|
||||||
description: "Active when the multi-line output buffer is open",
|
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),
|
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,
|
get mask() this,
|
||||||
|
|
||||||
@@ -547,14 +558,35 @@ var Modes = Module("modes", {
|
|||||||
"Pass through unknown keys in these modes",
|
"Pass through unknown keys in these modes",
|
||||||
"stringlist", "",
|
"stringlist", "",
|
||||||
{
|
{
|
||||||
has: function (val) this.value.indexOf(val.toLowerCase()) >= 0,
|
completer: function completer(context, extra) {
|
||||||
|
if (extra.value && context.filter[0] == "!")
|
||||||
setter: function (val) {
|
context.advance(1);
|
||||||
modes.all.forEach(function (m) { delete m.passUnknown });
|
return completer.superapply(this, arguments);
|
||||||
return val.map(String.toLowerCase);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
get values() [[m.name.toLowerCase(), m.description] for (m in values(modes._modes)) if (!m.hidden)]
|
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;
|
||||||
|
|
||||||
|
return set.has(this.valueMap, val) ? this.valueMap[val] : default_;
|
||||||
|
},
|
||||||
|
|
||||||
|
setter: function (vals) {
|
||||||
|
modes.all.forEach(function (m) { delete m.passUnknown });
|
||||||
|
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
|
||||||
|
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"],
|
options.add(["showmode", "smd"],
|
||||||
|
|||||||
Reference in New Issue
Block a user