1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-19 21:57:59 +01:00

Kludgily make it possible to use Text Edit mode from Command Line mode.

--HG--
branch : key-processing
This commit is contained in:
Kris Maglione
2011-01-26 23:13:13 -05:00
parent 554c8cd18a
commit 00a2b7116d
2 changed files with 21 additions and 11 deletions

View File

@@ -88,6 +88,7 @@ var CommandWidgets = Class("CommandWidgets", {
this.addElement({
name: "command",
test: function (stack, prev) stack.pop && !isinstance(prev.main, modes.COMMAND_LINE),
id: "commandline-command",
get: function (elem) {
// The long path is because of complications with the
@@ -163,6 +164,7 @@ var CommandWidgets = Class("CommandWidgets", {
if (!(obj.noValue || obj.getValue)) {
Object.defineProperty(this, obj.name, Modes.boundProperty({
test: obj.test,
get: function get_widgetValue() {
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);
},
get commandMode() this.commandSession && isinstance(modes.main, modes.COMMAND_LINE),
events: update(
iter(CommandMode.prototype.events).map(
function ([event, handler]) [
event, function (event) {
if (this.commandSession)
if (this.commandMode)
handler.call(this.commandSession, event);
}
]).toObject(),
{
blur: function onBlur(event) {
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);
});
},
focus: function onFocus(event) {
if (!this.commandSession
if (!this.commandMode
&& event.originalTarget === this.widgets.active.command.inputField) {
event.target.blur();
dactyl.beep();

View File

@@ -264,15 +264,16 @@ var Modes = Module("modes", {
delayed: [],
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))
for (let elem in array.iterValues(this._modeStack))
elem.saved[id] = { obj: obj, prop: prop, value: obj[prop] };
this.boundProperties[id] = { obj: Cu.getWeakReference(obj), prop: prop };
elem.saved[id] = { obj: obj, prop: prop, value: obj[prop], test: test };
this.boundProperties[id] = { obj: Cu.getWeakReference(obj), prop: prop, test: test };
},
// helper function to set both modes in one go
set: function set(mainMode, extendedMode, params, stack) {
util.dumpStack(" ========== " + mainMode.toString());
params = params || this.getMode(mainMode || this.main).params;
if (!stack && mainMode != null && this._modeStack.length > 1)
@@ -294,15 +295,17 @@ var Modes = Module("modes", {
let push = mainMode != null && !(stack && stack.pop) &&
Modes.StackElement(this._main, this._extended, params, {});
if (push && this.topOfStack) {
if (this.topOfStack.params.leave)
dactyl.trapErrors("leave", this.topOfStack.params,
{ 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())
delete this.boundProperties[id];
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);
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)) {
util.dump("pop " + obj + " " + prop + " " + !!test + " " + (test && test(stack, prev)));
if (!test || !test(stack, prev))
obj[prop] = value;
}
this.show();
@@ -455,7 +461,7 @@ var Modes = Module("modes", {
return val === undefined ? value : val;
},
set: function (val) {
modes.save(id, this, prop);
modes.save(id, this, prop, desc.test);
if (desc.set)
value = desc.set.call(this, val);
value = !desc.set || value === undefined ? val : value;