Jacek Caban : mshtml: Added editor mode up key implementation.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jun 11 08:46:39 CDT 2007


Module: wine
Branch: master
Commit: ec24f20bb1986ae1b37c186b5647afff8006681d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ec24f20bb1986ae1b37c186b5647afff8006681d

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Sun Jun 10 11:49:56 2007 +0200

mshtml: Added editor mode up key implementation.

---

 dlls/mshtml/editor.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/dlls/mshtml/editor.c b/dlls/mshtml/editor.c
index 9c59dae..4c1485d 100644
--- a/dlls/mshtml/editor.c
+++ b/dlls/mshtml/editor.c
@@ -44,8 +44,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 #define NSCMD_INDENT       "cmd_indent"
 #define NSCMD_INSERTHR     "cmd_insertHR"
 #define NSCMD_ITALIC       "cmd_italic"
+#define NSCMD_LINEPREVIOUS "cmd_linePrevious"
+#define NSCMD_MOVEPAGEUP   "cmd_movePageUp"
 #define NSCMD_OL           "cmd_ol"
 #define NSCMD_OUTDENT      "cmd_outdent"
+#define NSCMD_SELECTLINEPREVIOUS  "cmd_selectLinePrevious"
+#define NSCMD_SELECTPAGEUP "cmd_selectPageUp"
 #define NSCMD_UL           "cmd_ul"
 #define NSCMD_UNDERLINE    "cmd_underline"
 
@@ -94,6 +98,18 @@ static void do_ns_command(NSContainer *This, const char *cmd, nsICommandParams *
     nsICommandManager_Release(cmdmgr);
 }
 
+static void do_ns_editor_command(NSContainer *This, const char *cmd)
+{
+    nsresult nsres;
+
+    if(!This->editor_controller)
+        return;
+
+    nsres = nsIController_DoCommand(This->editor_controller, cmd);
+    if(NS_FAILED(nsres))
+        ERR("DoCommand(%s) failed: %08x\n", debugstr_a(cmd), nsres);
+}
+
 static nsresult get_ns_command_state(NSContainer *This, const char *cmd, nsICommandParams *nsparam)
 {
     nsICommandManager *cmdmgr;
@@ -550,6 +566,24 @@ static void collapse_next_char(HTMLDocument *doc, nsIDOMKeyEvent *event, BOOL ne
     nsISelection_Release(selection);
 }
 
+static void handle_arrow_key(HTMLDocument *This, nsIDOMKeyEvent *event, const char **cmds)
+{
+    int i=0;
+    PRBool b;
+
+    nsIDOMKeyEvent_GetCtrlKey(event, &b);
+    if(b)
+        i |= 1;
+
+    nsIDOMKeyEvent_GetShiftKey(event, &b);
+    if(b)
+        i |= 2;
+
+    do_ns_editor_command(This->nscontainer, cmds[i]);
+
+    nsIDOMKeyEvent_PreventDefault(event);
+}
+
 void handle_edit_event(HTMLDocument *This, nsIDOMEvent *event)
 {
     nsIDOMKeyEvent *key_event;
@@ -567,6 +601,18 @@ void handle_edit_event(HTMLDocument *This, nsIDOMEvent *event)
     case DOM_VK_RIGHT:
         TRACE("right\n");
         collapse_next_char(This, key_event, TRUE);
+        break;
+    case DOM_VK_UP: {
+        static const char *cmds[] = {
+            NSCMD_LINEPREVIOUS,
+            NSCMD_MOVEPAGEUP,
+            NSCMD_SELECTLINEPREVIOUS,
+            NSCMD_SELECTPAGEUP
+        };
+
+        handle_arrow_key(This, key_event, cmds);
+        break;
+    }
     };
 
     nsIDOMKeyEvent_Release(key_event);




More information about the wine-cvs mailing list