1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-05 02:15:46 +01:00

Minor mode magic.

This commit is contained in:
Kris Maglione
2010-12-07 01:21:42 -05:00
parent bf73483d42
commit 0af0b5340e
3 changed files with 19 additions and 19 deletions

View File

@@ -11,8 +11,8 @@
/** @instance editor */
const Editor = Module("editor", {
get isCaret() modes.getStack(1).main === modes.CARET,
get isTextEdit() modes.getStack(1).main === modes.TEXT_EDIT,
get isCaret() modes.getStack(1).main == modes.CARET,
get isTextEdit() modes.getStack(1).main == modes.TEXT_EDIT,
unselectText: function (toEnd) {
try {

View File

@@ -738,7 +738,7 @@ const Events = Module("events", {
if (elem instanceof HTMLTextAreaElement || (elem && util.computedStyle(elem).MozUserModify == "read-write")
|| elem == null && win && Editor.getEditor(win)) {
if (modes.main === modes.VISUAL && elem.selectionEnd == elem.selectionStart)
if (modes.main == modes.VISUAL && elem.selectionEnd == elem.selectionStart)
modes.pop();
if (!(modes.main & (modes.INSERT | modes.TEXT_EDIT | modes.VISUAL)))
@@ -764,7 +764,7 @@ const Events = Module("events", {
if (elem == null && urlbar && urlbar.inputField == this._lastFocus)
util.threadYield(true);
while (modes.getMode(modes.main).ownsFocus)
while (modes.main.ownsFocus)
modes.pop();
}
finally {
@@ -938,7 +938,7 @@ const Events = Module("events", {
}
else {
// Hack.
if (map.name == "<C-v>" && main === modes.QUOTE)
if (map.name == "<C-v>" && main == modes.QUOTE)
stop = false;
else {
if (modes.isReplaying && !this.waitForPageLoad())
@@ -969,11 +969,11 @@ const Events = Module("events", {
this._input.motionCount = null;
if (!isEscape(key)) {
stop = (mode.main === modes.TEXT_EDIT);
stop = (mode.main == modes.TEXT_EDIT);
if (stop)
dactyl.beep();
if (mode.main === modes.COMMAND_LINE)
if (mode.main == modes.COMMAND_LINE)
if (!(mode.extended & modes.INPUT_MULTILINE))
dactyl.trapErrors(commandline.onEvent, commandline, event);
}
@@ -993,7 +993,7 @@ const Events = Module("events", {
// This is a stupid, silly, and revolting hack.
if (isEscape(key))
this.onEscape();
if (main === modes.QUOTE)
if (main == modes.QUOTE)
modes.push(main);
}
},
@@ -1007,8 +1007,8 @@ const Events = Module("events", {
(!dactyl.focus || Events.isContentNode(dactyl.focus)) &&
options.get("passkeys").has(events.toString(event));
if (modes.main === modes.PASS_THROUGH ||
modes.main === modes.QUOTE
if (modes.main == modes.PASS_THROUGH ||
modes.main == modes.QUOTE
&& modes.getStack(1).main !== modes.PASS_THROUGH
&& !shouldPass() ||
!modes.passThrough && shouldPass())
@@ -1048,7 +1048,7 @@ const Events = Module("events", {
let controller = document.commandDispatcher.getControllerForCommand("cmd_copy");
let couldCopy = controller && controller.isCommandEnabled("cmd_copy");
if (dactyl.mode === modes.VISUAL) {
if (dactyl.mode == modes.VISUAL) {
if (!couldCopy)
modes.pop(); // Really not ideal.
}

View File

@@ -94,7 +94,7 @@ const Modes = Module("modes", {
statusline.updateUrl();
if (prev.mainMode.input || prev.mainMode.ownsFocus)
dactyl.focusContent(true);
if (prev.main === modes.NORMAL) {
if (prev.main == modes.NORMAL) {
dactyl.focusContent(true);
// clear any selection made
let selection = window.content.getSelection();
@@ -141,7 +141,7 @@ const Modes = Module("modes", {
addMode: function (name, extended, options, params) {
let disp = name.replace("_", " ", "g");
this[name] = 1 << this._lastMode++;
let mode = this[name] = new Number(1 << this._lastMode++);
if (typeof extended == "object") {
params = options;
@@ -149,7 +149,7 @@ const Modes = Module("modes", {
extended = false;
}
let mode = util.extend({
util.extend(mode, {
count: true,
disp: disp,
extended: extended,
@@ -221,9 +221,9 @@ const Modes = Module("modes", {
let oldMain = this._main, oldExtended = this._extended;
if (typeof extendedMode === "number")
if (extendedMode != null)
this._extended = extendedMode;
if (typeof mainMode === "number") {
if (mainMode != null) {
this._main = mainMode;
if (!extendedMode)
this._extended = this.NONE;
@@ -265,9 +265,9 @@ const Modes = Module("modes", {
},
onCaretChange: function onPrefChange(value) {
if (!value && modes.main === modes.CARET)
if (!value && modes.main == modes.CARET)
modes.pop();
if (value && modes.main === modes.NORMAL)
if (value && modes.main == modes.NORMAL)
modes.push(modes.CARET);
},
@@ -325,7 +325,7 @@ const Modes = Module("modes", {
let struct = Struct("main", "extended", "params", "saved");
struct.prototype.__defineGetter__("mainMode", function () modes.getMode(this.main));
struct.prototype.toString = function () !loaded.modes ? this.main : "[mode " +
modes.getMode(this.main).name +
this.mainMode.name +
(!this.extended ? "" :
"(" +
[modes.getMode(1 << i).name for (i in util.range(0, 32)) if (this.extended & (1 << i))].join("|") +