mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-19 23:47:58 +01:00
Kludgily make it possible to use Text Edit mode from Command Line mode.
--HG-- branch : key-processing
This commit is contained in:
@@ -88,6 +88,7 @@ var CommandWidgets = Class("CommandWidgets", {
|
|||||||
|
|
||||||
this.addElement({
|
this.addElement({
|
||||||
name: "command",
|
name: "command",
|
||||||
|
test: function (stack, prev) stack.pop && !isinstance(prev.main, modes.COMMAND_LINE),
|
||||||
id: "commandline-command",
|
id: "commandline-command",
|
||||||
get: function (elem) {
|
get: function (elem) {
|
||||||
// The long path is because of complications with the
|
// The long path is because of complications with the
|
||||||
@@ -163,6 +164,7 @@ var CommandWidgets = Class("CommandWidgets", {
|
|||||||
|
|
||||||
if (!(obj.noValue || obj.getValue)) {
|
if (!(obj.noValue || obj.getValue)) {
|
||||||
Object.defineProperty(this, obj.name, Modes.boundProperty({
|
Object.defineProperty(this, obj.name, Modes.boundProperty({
|
||||||
|
test: obj.test,
|
||||||
|
|
||||||
get: function get_widgetValue() {
|
get: function get_widgetValue() {
|
||||||
let elem = self.getGroup(obj.name, obj.value)[obj.name];
|
let elem = self.getGroup(obj.name, obj.value)[obj.name];
|
||||||
@@ -779,23 +781,25 @@ var CommandLine = Module("commandline", {
|
|||||||
this.timeout(function () { dactyl.focus(this.widgets.multilineInput); }, 10);
|
this.timeout(function () { dactyl.focus(this.widgets.multilineInput); }, 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get commandMode() this.commandSession && isinstance(modes.main, modes.COMMAND_LINE),
|
||||||
|
|
||||||
events: update(
|
events: update(
|
||||||
iter(CommandMode.prototype.events).map(
|
iter(CommandMode.prototype.events).map(
|
||||||
function ([event, handler]) [
|
function ([event, handler]) [
|
||||||
event, function (event) {
|
event, function (event) {
|
||||||
if (this.commandSession)
|
if (this.commandMode)
|
||||||
handler.call(this.commandSession, event);
|
handler.call(this.commandSession, event);
|
||||||
}
|
}
|
||||||
]).toObject(),
|
]).toObject(),
|
||||||
{
|
{
|
||||||
blur: function onBlur(event) {
|
blur: function onBlur(event) {
|
||||||
this.timeout(function () {
|
this.timeout(function () {
|
||||||
if (this.commandSession && event.originalTarget === this.widgets.active.command.inputField)
|
if (this.commandMode && event.originalTarget === this.widgets.active.command.inputField)
|
||||||
dactyl.focus(this.widgets.active.command.inputField);
|
dactyl.focus(this.widgets.active.command.inputField);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
focus: function onFocus(event) {
|
focus: function onFocus(event) {
|
||||||
if (!this.commandSession
|
if (!this.commandMode
|
||||||
&& event.originalTarget === this.widgets.active.command.inputField) {
|
&& event.originalTarget === this.widgets.active.command.inputField) {
|
||||||
event.target.blur();
|
event.target.blur();
|
||||||
dactyl.beep();
|
dactyl.beep();
|
||||||
|
|||||||
@@ -264,15 +264,16 @@ var Modes = Module("modes", {
|
|||||||
delayed: [],
|
delayed: [],
|
||||||
delay: function (callback, self) { this.delayed.push([callback, self]); },
|
delay: function (callback, self) { this.delayed.push([callback, self]); },
|
||||||
|
|
||||||
save: function save(id, obj, prop) {
|
save: function save(id, obj, prop, test) {
|
||||||
if (!(id in this.boundProperties))
|
if (!(id in this.boundProperties))
|
||||||
for (let elem in array.iterValues(this._modeStack))
|
for (let elem in array.iterValues(this._modeStack))
|
||||||
elem.saved[id] = { obj: obj, prop: prop, value: obj[prop] };
|
elem.saved[id] = { obj: obj, prop: prop, value: obj[prop], test: test };
|
||||||
this.boundProperties[id] = { obj: Cu.getWeakReference(obj), prop: prop };
|
this.boundProperties[id] = { obj: Cu.getWeakReference(obj), prop: prop, test: test };
|
||||||
},
|
},
|
||||||
|
|
||||||
// helper function to set both modes in one go
|
// helper function to set both modes in one go
|
||||||
set: function set(mainMode, extendedMode, params, stack) {
|
set: function set(mainMode, extendedMode, params, stack) {
|
||||||
|
util.dumpStack(" ========== " + mainMode.toString());
|
||||||
params = params || this.getMode(mainMode || this.main).params;
|
params = params || this.getMode(mainMode || this.main).params;
|
||||||
|
|
||||||
if (!stack && mainMode != null && this._modeStack.length > 1)
|
if (!stack && mainMode != null && this._modeStack.length > 1)
|
||||||
@@ -294,15 +295,17 @@ var Modes = Module("modes", {
|
|||||||
|
|
||||||
let push = mainMode != null && !(stack && stack.pop) &&
|
let push = mainMode != null && !(stack && stack.pop) &&
|
||||||
Modes.StackElement(this._main, this._extended, params, {});
|
Modes.StackElement(this._main, this._extended, params, {});
|
||||||
|
|
||||||
if (push && this.topOfStack) {
|
if (push && this.topOfStack) {
|
||||||
if (this.topOfStack.params.leave)
|
if (this.topOfStack.params.leave)
|
||||||
dactyl.trapErrors("leave", this.topOfStack.params,
|
dactyl.trapErrors("leave", this.topOfStack.params,
|
||||||
{ push: push }, push);
|
{ push: push }, push);
|
||||||
for (let [id, { obj, prop }] in Iterator(this.boundProperties)) {
|
|
||||||
|
for (let [id, { obj, prop, test }] in Iterator(this.boundProperties)) {
|
||||||
if (!obj.get())
|
if (!obj.get())
|
||||||
delete this.boundProperties[id];
|
delete this.boundProperties[id];
|
||||||
else
|
else
|
||||||
this.topOfStack.saved[id] = { obj: obj.get(), prop: prop, value: obj.get()[prop] };
|
this.topOfStack.saved[id] = { obj: obj.get(), prop: prop, value: obj.get()[prop], test: test };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,8 +317,11 @@ var Modes = Module("modes", {
|
|||||||
this._modeStack.push(push);
|
this._modeStack.push(push);
|
||||||
|
|
||||||
if (stack && stack.pop)
|
if (stack && stack.pop)
|
||||||
for (let { obj, prop, value } in values(this.topOfStack.saved))
|
for (let { obj, prop, value, test } in values(this.topOfStack.saved)) {
|
||||||
obj[prop] = value;
|
util.dump("pop " + obj + " " + prop + " " + !!test + " " + (test && test(stack, prev)));
|
||||||
|
if (!test || !test(stack, prev))
|
||||||
|
obj[prop] = value;
|
||||||
|
}
|
||||||
|
|
||||||
this.show();
|
this.show();
|
||||||
|
|
||||||
@@ -455,7 +461,7 @@ var Modes = Module("modes", {
|
|||||||
return val === undefined ? value : val;
|
return val === undefined ? value : val;
|
||||||
},
|
},
|
||||||
set: function (val) {
|
set: function (val) {
|
||||||
modes.save(id, this, prop);
|
modes.save(id, this, prop, desc.test);
|
||||||
if (desc.set)
|
if (desc.set)
|
||||||
value = desc.set.call(this, val);
|
value = desc.set.call(this, val);
|
||||||
value = !desc.set || value === undefined ? val : value;
|
value = !desc.set || value === undefined ? val : value;
|
||||||
|
|||||||
Reference in New Issue
Block a user