[Yulup-commits] rev 20929 - public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor

andi at wyona.com andi at wyona.com
Fri Dec 15 20:01:49 CET 2006


Author: andi
Date: 2006-12-15 20:01:48 +0100 (Fri, 15 Dec 2006)
New Revision: 20929

Added:
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/commandkeylistener.js
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/readlinekeybindingslistener.js
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/texteditorkeylistener.js
Modified:
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/editor.xul
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/view.js
Log:
Moved more components from view.js to their own files.


Added: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/commandkeylistener.js
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/commandkeylistener.js	2006-12-15 18:41:15 UTC (rev 20928)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/commandkeylistener.js	2006-12-15 19:01:48 UTC (rev 20929)
@@ -0,0 +1,147 @@
+/*
+ * ***** BEGIN LICENSE BLOCK *****
+ * Copyright 2006 Wyona AG Zurich
+ *
+ * This file is part of Yulup.
+ *
+ * Yulup is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Yulup is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Yulup; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * ***** END LICENSE BLOCK *****
+ */
+
+/**
+ * @author Andreas Wuest
+ *
+ */
+
+function CommandKeyListener() {
+    var prefAccelKey = null;
+
+    /* DEBUG */ dump("Yulup:commandkeylistener.js:CommandKeyListener() invoked\n");
+
+    /* Detect platform to set accel key correctly. This is a
+     * workaround until https://bugzilla.mozilla.org/show_bug.cgi?id=180840
+     * gets fixed. */
+
+    // try to retrieve pref (cf. http://lxr.mozilla.org/mozilla1.8.0/source/content/xbl/src/nsXBLPrototypeHandler.cpp#188)
+    if ((prefAccelKey = YulupPreferences.getAnyPref("ui.key.", "accelKey", "int")) != null) {
+        /* DEBUG */ dump("Yulup:commandkeylistener.js:CommandKeyListener: prefAccelKey = \"" + prefAccelKey + "\"\n");
+
+        switch (prefAccelKey) {
+            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_ALT:
+            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_CONTROL:
+            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_META:
+                this.__accelKey = prefAccelKey;
+                break;
+            default:
+        }
+    }
+
+    if (!this.__accelKey) {
+        if ((new RegExp("Mac")).test(navigator.platform)) {
+            this.__accelKey = Components.interfaces.nsIDOMKeyEvent.DOM_VK_META;
+        } else {
+            this.__accelKey = Components.interfaces.nsIDOMKeyEvent.DOM_VK_CONTROL;
+        }
+    }
+
+    /* DEBUG */ dump("Yulup:commandkeylistener.js:CommandKeyListener: this.__accelKey = \"" + this.__accelKey + "\"\n");
+}
+
+CommandKeyListener.prototype = {
+    __accelKey: null,
+
+    __isAccelKey: function (aKeyEvent) {
+        switch (this.__accelKey) {
+            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_ALT:
+                return aKeyEvent.altKey;
+            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_CONTROL:
+                return aKeyEvent.ctrlKey;
+            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_META:
+                return aKeyEvent.metaKey;
+            default:
+                return false;
+        }
+    },
+
+    handleEvent: function (aKeyEvent) {
+        var controller = null;
+
+        /* DEBUG */ dump("Yulup:commandkeylistener.js:CommandKeyListener.handleEvent() invoked\n");
+
+        if (this.__isAccelKey(aKeyEvent)) {
+            /* DEBUG */ dump("Yulup:commandkeylistener.js:CommandKeyListener.handleEvent: char code = " + String.fromCharCode(aKeyEvent.charCode) + "\n");
+
+            switch (String.fromCharCode(aKeyEvent.charCode)) {
+                case "e":
+                case "E":
+                    if (aKeyEvent.shiftKey) {
+                        Editor.exitEditor();
+
+                        // we consumed this event
+                        aKeyEvent.preventDefault();
+                        return true;
+                    }
+
+                    break;
+                case "t":
+                case "T":
+                    if (aKeyEvent.shiftKey) {
+                        Editor.goDoFileOperationsCommand("cmd_yulup_savetemp");
+
+                        // we consumed this event
+                        aKeyEvent.preventDefault();
+                        return true;
+                    }
+
+                    break;
+                case "s":
+                case "S":
+                    if (aKeyEvent.shiftKey) {
+                        Editor.goDoFileOperationsCommand("cmd_yulup_savecms");
+
+                        // we consumed this event
+                        aKeyEvent.preventDefault();
+                        return true;
+                    }
+
+                    break;
+                case "c":
+                case "C":
+                    if (aKeyEvent.shiftKey) {
+                        Editor.goDoFileOperationsCommand("cmd_yulup_checkincms");
+
+                        // we consumed this event
+                        aKeyEvent.preventDefault();
+                        return true;
+                    }
+
+                    break;
+                case "u":
+                case "U":
+                    if (aKeyEvent.shiftKey) {
+                        Editor.goDoFileOperationsCommand("cmd_yulup_upload");
+
+                        // we consumed this event
+                        aKeyEvent.preventDefault();
+                        return true;
+                    }
+
+                    break;
+                default:
+            }
+        }
+    }
+};

Modified: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/editor.xul
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/editor.xul	2006-12-15 18:41:15 UTC (rev 20928)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/editor.xul	2006-12-15 19:01:48 UTC (rev 20929)
@@ -65,6 +65,12 @@
   <script type="application/x-javascript"
           src="chrome://yulup/content/editor/view.js"/>
   <script type="application/x-javascript"
+          src="chrome://yulup/content/editor/texteditorkeylistener.js"/>
+  <script type="application/x-javascript"
+          src="chrome://yulup/content/editor/commandkeylistener.js"/>
+  <script type="application/x-javascript"
+          src="chrome://yulup/content/editor/readlinekeybindingslistener.js"/>
+  <script type="application/x-javascript"
           src="chrome://yulup/content/editor/guidedtaginserter.js"/>
   <script type="application/x-javascript"
           src="chrome://yulup/content/editor/xpathparser.js"/>

Added: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/readlinekeybindingslistener.js
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/readlinekeybindingslistener.js	2006-12-15 18:41:15 UTC (rev 20928)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/readlinekeybindingslistener.js	2006-12-15 19:01:48 UTC (rev 20929)
@@ -0,0 +1,248 @@
+/*
+ * ***** BEGIN LICENSE BLOCK *****
+ * Copyright 2006 Wyona AG Zurich
+ *
+ * This file is part of Yulup.
+ *
+ * Yulup is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Yulup is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Yulup; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * ***** END LICENSE BLOCK *****
+ */
+
+/**
+ * @author Andreas Wuest
+ *
+ */
+
+function ReadlineKeyBindingsListener(aEditorElem) {
+    /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener() invoked\n");
+
+    /* DEBUG */ YulupDebug.ASSERT(aEditorElem != null);
+
+    this.editorElem = aEditorElem;
+}
+
+ReadlineKeyBindingsListener.prototype = {
+    editorElem: null,
+
+    handleEvent: function (aKeyEvent) {
+        var controller = null;
+
+        /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent() invoked\n");
+
+        switch (String.fromCharCode(aKeyEvent.charCode)) {
+        case "a":
+        case "A":
+            /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent: char code = a\n");
+            if (!aKeyEvent.ctrlKey) {
+                break;
+            } else {
+                if (aKeyEvent.shiftKey) {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_selectBeginLine");
+                    controller.doCommand("cmd_selectBeginLine");
+                } else {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_beginLine");
+                    controller.doCommand("cmd_beginLine");
+                }
+
+                // we consumed this event
+                aKeyEvent.preventDefault();
+                return true;
+                break;
+            }
+        case "b":
+        case "B":
+            /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent: char code = b\n");
+            if (!aKeyEvent.ctrlKey) {
+                break;
+            } else {
+                if (aKeyEvent.shiftKey) {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_selectCharPrevious");
+                    controller.doCommand("cmd_selectCharPrevious");
+                } else {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_charPrevious");
+                    controller.doCommand("cmd_charPrevious");
+                }
+
+                // we consumed this event
+                aKeyEvent.preventDefault();
+                return true;
+                break;
+            }
+        case "d":
+            /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent: char code = d\n");
+            if (!aKeyEvent.ctrlKey) {
+                break;
+            } else {
+                controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_deleteCharForward");
+                controller.doCommand("cmd_deleteCharForward");
+
+                // we consumed this event
+                aKeyEvent.preventDefault();
+                return true;
+                break;
+            }
+        case "e":
+        case "E":
+            /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent: char code = e\n");
+            if (!aKeyEvent.ctrlKey) {
+                break;
+            } else {
+                if (aKeyEvent.shiftKey) {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_selectEndLine");
+                    controller.doCommand("cmd_selectEndLine");
+                } else {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_endLine");
+                    controller.doCommand("cmd_endLine");
+                }
+
+                // we consumed this event
+                aKeyEvent.preventDefault();
+                return true;
+                break;
+            }
+        case "f":
+        case "F":
+            /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent: char code = f\n");
+            if (!aKeyEvent.ctrlKey) {
+                break;
+            } else {
+                if (aKeyEvent.shiftKey) {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_selectCharPrevious");
+                    controller.doCommand("cmd_selectCharNext");
+                } else {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_charNext");
+                    controller.doCommand("cmd_charNext");
+                }
+
+                // we consumed this event
+                aKeyEvent.preventDefault();
+                return true;
+                break;
+            }
+        case "h":
+            /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent: char code = h\n");
+            if (!aKeyEvent.ctrlKey) {
+                break;
+            } else {
+                controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_deleteCharBackward");
+                controller.doCommand("cmd_deleteCharBackward");
+
+                // we consumed this event
+                aKeyEvent.preventDefault();
+                return true;
+                break;
+            }
+        case "k":
+            /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent: char code = k\n");
+            if (!aKeyEvent.ctrlKey) {
+                break;
+            } else {
+                controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_deleteToEndOfLine");
+                controller.doCommand("cmd_deleteToEndOfLine");
+
+                // we consumed this event
+                aKeyEvent.preventDefault();
+                return true;
+                break;
+            }
+        case "n":
+        case "N":
+            /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent: char code = n\n");
+            if (!aKeyEvent.ctrlKey) {
+                break;
+            } else {
+                if (aKeyEvent.shiftKey) {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_selectLineNext");
+                    controller.doCommand("cmd_selectLineNext");
+                } else {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_lineNext");
+                    controller.doCommand("cmd_lineNext");
+                }
+
+                // we consumed this event
+                aKeyEvent.preventDefault();
+                return true;
+                break;
+            }
+        case "p":
+        case "P":
+            /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent: char code = p\n");
+            if (!aKeyEvent.ctrlKey) {
+                break;
+            } else {
+                if (aKeyEvent.shiftKey) {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_selectLinePrevious");
+                    controller.doCommand("cmd_selectLinePrevious");
+                } else {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_linePrevious");
+                    controller.doCommand("cmd_linePrevious");
+                }
+
+                // we consumed this event
+                aKeyEvent.preventDefault();
+                return true;
+                break;
+            }
+        case "u":
+            /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent: char code = u\n");
+            if (!aKeyEvent.ctrlKey) {
+                break;
+            } else {
+                controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_deleteToBeginningOfLine");
+                controller.doCommand("cmd_deleteToBeginningOfLine");
+
+                // we consumed this event
+                aKeyEvent.preventDefault();
+                return true;
+                break;
+            }
+        case "w":
+        case "W":
+            /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent: char code = w\n");
+            if (!aKeyEvent.ctrlKey) {
+                break;
+            } else {
+                if (aKeyEvent.shiftKey) {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_deleteWordForward");
+                    controller.doCommand("cmd_deleteWordForward");
+                } else {
+                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_deleteWordBackward");
+                    controller.doCommand("cmd_deleteWordBackward");
+                }
+
+                // we consumed this event
+                aKeyEvent.preventDefault();
+                return true;
+                break;
+            }
+        case "_":
+            /* DEBUG */ dump("Yulup:readlinekeybindingslistener.js:ReadlineKeyBindingsListener.handleEvent: char code = _\n");
+            if (!aKeyEvent.ctrlKey) {
+                break;
+            } else {
+                controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_undo");
+                controller.doCommand("cmd_undo");
+
+                // we consumed this event
+                aKeyEvent.preventDefault();
+                return true;
+                break;
+            }
+        }
+
+        return true;
+    }
+};

Added: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/texteditorkeylistener.js
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/texteditorkeylistener.js	2006-12-15 18:41:15 UTC (rev 20928)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/texteditorkeylistener.js	2006-12-15 19:01:48 UTC (rev 20929)
@@ -0,0 +1,93 @@
+/*
+ * ***** BEGIN LICENSE BLOCK *****
+ * Copyright 2006 Wyona AG Zurich
+ *
+ * This file is part of Yulup.
+ *
+ * Yulup is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Yulup is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Yulup; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * ***** END LICENSE BLOCK *****
+ */
+
+/**
+ * @author Andreas Wuest
+ *
+ */
+
+function TextEditorKeyListener(aEditor, aUseSpaces, aNoOfSpaces) {
+    dump("Yulup:texteditorkeylistener.js:TextEditorKeyListener() invoked\n");
+
+    /* DEBUG */ YulupDebug.ASSERT(aEditor != null);
+    /* DEBUG */ YulupDebug.ASSERT(aUseSpaces != null);
+    /* DEBUG */ YulupDebug.ASSERT(typeof(aUseSpaces)  == "boolean");
+    /* DEBUG */ YulupDebug.ASSERT(aUseSpaces ? aNoOfSpaces != null : true);
+    /* DEBUG */ YulupDebug.ASSERT(aUseSpaces ? typeof(aNoOfSpaces) == "number" : true);
+    /* DEBUG */ YulupDebug.ASSERT(aUseSpaces ? aNoOfSpaces >= 0 : true);
+
+    this.__editor    = aEditor;
+    this.__useSpaces = aUseSpaces;
+    this.__spaces    = "";
+
+    if (aUseSpaces) {
+        for (var i = 0; i < aNoOfSpaces; i++) {
+            this.__spaces += " ";
+        }
+    }
+}
+
+TextEditorKeyListener.prototype = {
+    __editor   : null,
+    __useSpaces: null,
+    __spaces   : null,
+
+    handleEvent: function (aKeyEvent) {
+        var isAnyModifierKeyButShift = null;
+
+        dump("Yulup:texteditorkeylistener.js:TextEditorKeyListener:handleEvent() invoked\n");
+
+        if (0 != aKeyEvent.keyCode) {
+            isAnyModifierKeyButShift = aKeyEvent.altKey;
+
+            if (!isAnyModifierKeyButShift) {
+                isAnyModifierKeyButShift = aKeyEvent.metaKey;
+
+                if (!isAnyModifierKeyButShift) {
+                    isAnyModifierKeyButShift = aKeyEvent.ctrlKey;
+                }
+            }
+
+            switch (aKeyEvent.keyCode) {
+            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_TAB:
+                dump("key event = DOM_VK_TAB\n");
+
+                if (this.__useSpaces) {
+                    if (isAnyModifierKeyButShift)
+                        return true;
+
+                    // else we insert the tab straight through
+                    this.__editor.QueryInterface(Components.interfaces.nsIPlaintextEditor);
+                    this.__editor.insertText(this.__spaces);
+
+                    // we consumed this event
+                    aKeyEvent.preventDefault();
+                    return true;
+                }
+                break;
+            }
+        }
+
+        return true;
+    }
+};

Modified: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/view.js
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/view.js	2006-12-15 18:41:15 UTC (rev 20928)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor/view.js	2006-12-15 19:01:48 UTC (rev 20929)
@@ -2771,416 +2771,6 @@
 };
 
 
-function TextEditorKeyListener(aEditor, aUseSpaces, aNoOfSpaces) {
-    dump("Yulup:view.js:TextEditorKeyListener() invoked\n");
-
-    /* DEBUG */ YulupDebug.ASSERT(aEditor != null);
-    /* DEBUG */ YulupDebug.ASSERT(aUseSpaces != null);
-    /* DEBUG */ YulupDebug.ASSERT(typeof(aUseSpaces)  == "boolean");
-    /* DEBUG */ YulupDebug.ASSERT(aUseSpaces ? aNoOfSpaces != null : true);
-    /* DEBUG */ YulupDebug.ASSERT(aUseSpaces ? typeof(aNoOfSpaces) == "number" : true);
-    /* DEBUG */ YulupDebug.ASSERT(aUseSpaces ? aNoOfSpaces >= 0 : true);
-
-    this.__editor    = aEditor;
-    this.__useSpaces = aUseSpaces;
-    this.__spaces    = "";
-
-    if (aUseSpaces) {
-        for (var i = 0; i < aNoOfSpaces; i++) {
-            this.__spaces += " ";
-        }
-    }
-}
-
-TextEditorKeyListener.prototype = {
-    __editor   : null,
-    __useSpaces: null,
-    __spaces   : null,
-
-    handleEvent: function (aKeyEvent) {
-        var isAnyModifierKeyButShift = null;
-
-        dump("Yulup:view.js:TextEditorKeyListener:handleEvent() invoked\n");
-
-        if (0 != aKeyEvent.keyCode) {
-            isAnyModifierKeyButShift = aKeyEvent.altKey;
-
-            if (!isAnyModifierKeyButShift) {
-                isAnyModifierKeyButShift = aKeyEvent.metaKey;
-
-                if (!isAnyModifierKeyButShift) {
-                    isAnyModifierKeyButShift = aKeyEvent.ctrlKey;
-                }
-            }
-
-            switch (aKeyEvent.keyCode) {
-            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_TAB:
-                dump("key event = DOM_VK_TAB\n");
-
-                if (this.__useSpaces) {
-                    if (isAnyModifierKeyButShift)
-                        return true;
-
-                    // else we insert the tab straight through
-                    this.__editor.QueryInterface(Components.interfaces.nsIPlaintextEditor);
-                    this.__editor.insertText(this.__spaces);
-
-                    // we consumed this event
-                    aKeyEvent.preventDefault();
-                    return true;
-                }
-                break;
-            }
-        }
-
-        return true;
-    }
-};
-
-
-function CommandKeyListener() {
-    var prefAccelKey = null;
-
-    /* DEBUG */ dump("Yulup:view.js:CommandKeyListener() invoked\n");
-
-    /* Detect platform to set accel key correctly. This is a
-     * workaround until https://bugzilla.mozilla.org/show_bug.cgi?id=180840
-     * gets fixed. */
-
-    // try to retrieve pref (cf. http://lxr.mozilla.org/mozilla1.8.0/source/content/xbl/src/nsXBLPrototypeHandler.cpp#188)
-    if ((prefAccelKey = YulupPreferences.getAnyPref("ui.key.", "accelKey", "int")) != null) {
-        /* DEBUG */ dump("Yulup:view.js:CommandKeyListener: prefAccelKey = \"" + prefAccelKey + "\"\n");
-
-        switch (prefAccelKey) {
-            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_ALT:
-            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_CONTROL:
-            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_META:
-                this.__accelKey = prefAccelKey;
-                break;
-            default:
-        }
-    }
-
-    if (!this.__accelKey) {
-        if ((new RegExp("Mac")).test(navigator.platform)) {
-            this.__accelKey = Components.interfaces.nsIDOMKeyEvent.DOM_VK_META;
-        } else {
-            this.__accelKey = Components.interfaces.nsIDOMKeyEvent.DOM_VK_CONTROL;
-        }
-    }
-
-    /* DEBUG */ dump("Yulup:view.js:CommandKeyListener: this.__accelKey = \"" + this.__accelKey + "\"\n");
-}
-
-CommandKeyListener.prototype = {
-    __accelKey: null,
-
-    __isAccelKey: function (aKeyEvent) {
-        switch (this.__accelKey) {
-            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_ALT:
-                return aKeyEvent.altKey;
-            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_CONTROL:
-                return aKeyEvent.ctrlKey;
-            case Components.interfaces.nsIDOMKeyEvent.DOM_VK_META:
-                return aKeyEvent.metaKey;
-            default:
-                return false;
-        }
-    },
-
-    handleEvent: function (aKeyEvent) {
-        var controller = null;
-
-        /* DEBUG */ dump("Yulup:view.js:CommandKeyListener.handleEvent() invoked\n");
-
-        if (this.__isAccelKey(aKeyEvent)) {
-            /* DEBUG */ dump("Yulup:view.js:CommandKeyListener.handleEvent: char code = " + String.fromCharCode(aKeyEvent.charCode) + "\n");
-
-            switch (String.fromCharCode(aKeyEvent.charCode)) {
-                case "e":
-                case "E":
-                    if (aKeyEvent.shiftKey) {
-                        Editor.exitEditor();
-
-                        // we consumed this event
-                        aKeyEvent.preventDefault();
-                        return true;
-                    }
-
-                    break;
-                case "t":
-                case "T":
-                    if (aKeyEvent.shiftKey) {
-                        Editor.goDoFileOperationsCommand("cmd_yulup_savetemp");
-
-                        // we consumed this event
-                        aKeyEvent.preventDefault();
-                        return true;
-                    }
-
-                    break;
-                case "s":
-                case "S":
-                    if (aKeyEvent.shiftKey) {
-                        Editor.goDoFileOperationsCommand("cmd_yulup_savecms");
-
-                        // we consumed this event
-                        aKeyEvent.preventDefault();
-                        return true;
-                    }
-
-                    break;
-                case "c":
-                case "C":
-                    if (aKeyEvent.shiftKey) {
-                        Editor.goDoFileOperationsCommand("cmd_yulup_checkincms");
-
-                        // we consumed this event
-                        aKeyEvent.preventDefault();
-                        return true;
-                    }
-
-                    break;
-                case "u":
-                case "U":
-                    if (aKeyEvent.shiftKey) {
-                        Editor.goDoFileOperationsCommand("cmd_yulup_upload");
-
-                        // we consumed this event
-                        aKeyEvent.preventDefault();
-                        return true;
-                    }
-
-                    break;
-                default:
-            }
-        }
-    }
-};
-
-
-function ReadlineKeyBindingsListener(aEditorElem) {
-    /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener() invoked\n");
-
-    /* DEBUG */ YulupDebug.ASSERT(aEditorElem != null);
-
-    this.editorElem = aEditorElem;
-}
-
-ReadlineKeyBindingsListener.prototype = {
-    editorElem: null,
-
-    handleEvent: function (aKeyEvent) {
-        var controller = null;
-
-        /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent() invoked\n");
-
-        switch (String.fromCharCode(aKeyEvent.charCode)) {
-        case "a":
-        case "A":
-            /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent: char code = a\n");
-            if (!aKeyEvent.ctrlKey) {
-                break;
-            } else {
-                if (aKeyEvent.shiftKey) {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_selectBeginLine");
-                    controller.doCommand("cmd_selectBeginLine");
-                } else {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_beginLine");
-                    controller.doCommand("cmd_beginLine");
-                }
-
-                // we consumed this event
-                aKeyEvent.preventDefault();
-                return true;
-                break;
-            }
-        case "b":
-        case "B":
-            /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent: char code = b\n");
-            if (!aKeyEvent.ctrlKey) {
-                break;
-            } else {
-                if (aKeyEvent.shiftKey) {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_selectCharPrevious");
-                    controller.doCommand("cmd_selectCharPrevious");
-                } else {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_charPrevious");
-                    controller.doCommand("cmd_charPrevious");
-                }
-
-                // we consumed this event
-                aKeyEvent.preventDefault();
-                return true;
-                break;
-            }
-        case "d":
-            /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent: char code = d\n");
-            if (!aKeyEvent.ctrlKey) {
-                break;
-            } else {
-                controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_deleteCharForward");
-                controller.doCommand("cmd_deleteCharForward");
-
-                // we consumed this event
-                aKeyEvent.preventDefault();
-                return true;
-                break;
-            }
-        case "e":
-        case "E":
-            /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent: char code = e\n");
-            if (!aKeyEvent.ctrlKey) {
-                break;
-            } else {
-                if (aKeyEvent.shiftKey) {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_selectEndLine");
-                    controller.doCommand("cmd_selectEndLine");
-                } else {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_endLine");
-                    controller.doCommand("cmd_endLine");
-                }
-
-                // we consumed this event
-                aKeyEvent.preventDefault();
-                return true;
-                break;
-            }
-        case "f":
-        case "F":
-            /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent: char code = f\n");
-            if (!aKeyEvent.ctrlKey) {
-                break;
-            } else {
-                if (aKeyEvent.shiftKey) {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_selectCharPrevious");
-                    controller.doCommand("cmd_selectCharNext");
-                } else {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_charNext");
-                    controller.doCommand("cmd_charNext");
-                }
-
-                // we consumed this event
-                aKeyEvent.preventDefault();
-                return true;
-                break;
-            }
-        case "h":
-            /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent: char code = h\n");
-            if (!aKeyEvent.ctrlKey) {
-                break;
-            } else {
-                controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_deleteCharBackward");
-                controller.doCommand("cmd_deleteCharBackward");
-
-                // we consumed this event
-                aKeyEvent.preventDefault();
-                return true;
-                break;
-            }
-        case "k":
-            /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent: char code = k\n");
-            if (!aKeyEvent.ctrlKey) {
-                break;
-            } else {
-                controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_deleteToEndOfLine");
-                controller.doCommand("cmd_deleteToEndOfLine");
-
-                // we consumed this event
-                aKeyEvent.preventDefault();
-                return true;
-                break;
-            }
-        case "n":
-        case "N":
-            /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent: char code = n\n");
-            if (!aKeyEvent.ctrlKey) {
-                break;
-            } else {
-                if (aKeyEvent.shiftKey) {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_selectLineNext");
-                    controller.doCommand("cmd_selectLineNext");
-                } else {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_lineNext");
-                    controller.doCommand("cmd_lineNext");
-                }
-
-                // we consumed this event
-                aKeyEvent.preventDefault();
-                return true;
-                break;
-            }
-        case "p":
-        case "P":
-            /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent: char code = p\n");
-            if (!aKeyEvent.ctrlKey) {
-                break;
-            } else {
-                if (aKeyEvent.shiftKey) {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_selectLinePrevious");
-                    controller.doCommand("cmd_selectLinePrevious");
-                } else {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_linePrevious");
-                    controller.doCommand("cmd_linePrevious");
-                }
-
-                // we consumed this event
-                aKeyEvent.preventDefault();
-                return true;
-                break;
-            }
-        case "u":
-            /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent: char code = u\n");
-            if (!aKeyEvent.ctrlKey) {
-                break;
-            } else {
-                controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_deleteToBeginningOfLine");
-                controller.doCommand("cmd_deleteToBeginningOfLine");
-
-                // we consumed this event
-                aKeyEvent.preventDefault();
-                return true;
-                break;
-            }
-        case "w":
-        case "W":
-            /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent: char code = w\n");
-            if (!aKeyEvent.ctrlKey) {
-                break;
-            } else {
-                if (aKeyEvent.shiftKey) {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_deleteWordForward");
-                    controller.doCommand("cmd_deleteWordForward");
-                } else {
-                    controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_deleteWordBackward");
-                    controller.doCommand("cmd_deleteWordBackward");
-                }
-
-                // we consumed this event
-                aKeyEvent.preventDefault();
-                return true;
-                break;
-            }
-        case "_":
-            /* DEBUG */ dump("Yulup:view.js:ReadlineKeyBindingsListener.handleEvent: char code = _\n");
-            if (!aKeyEvent.ctrlKey) {
-                break;
-            } else {
-                controller = this.editorElem.contentWindow.controllers.getControllerForCommand("cmd_undo");
-                controller.doCommand("cmd_undo");
-
-                // we consumed this event
-                aKeyEvent.preventDefault();
-                return true;
-                break;
-            }
-        }
-
-        return true;
-    }
-};
-
-
 /**
  * URIRewriter constructor. Instantiates a new object of
  * type URIRewriter.




More information about the Phoenix-commits mailing list