1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-24 14:05: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 */ /** @instance editor */
const Editor = Module("editor", { const Editor = Module("editor", {
get isCaret() modes.getStack(1).main === modes.CARET, get isCaret() modes.getStack(1).main == modes.CARET,
get isTextEdit() modes.getStack(1).main === modes.TEXT_EDIT, get isTextEdit() modes.getStack(1).main == modes.TEXT_EDIT,
unselectText: function (toEnd) { unselectText: function (toEnd) {
try { try {

View File

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

View File

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