2007-12-05 Luca Bruno <lethalman88@gmail.com>
authoralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Dec 2007 15:16:47 +0000 (15:16 +0000)
committeralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Dec 2007 15:16:47 +0000 (15:16 +0000)
        Reviewed by Alp Toker.

        Handle events for Home and End keys.

        * WebView/webkitwebview.cpp:
        (webkit_web_view_key_event):
        * WebCoreSupport/EditorClientGtk.cpp:
        (EditorClient::handleKeypress):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28438 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
WebKit/gtk/WebView/webkitwebview.cpp

index 99471070c8ab55bc48da64762d04ca4bcfcb85c5..7f2998ac9ae2845c863664309680ba42483179a0 100644 (file)
@@ -1,3 +1,14 @@
+2007-12-05  Luca Bruno  <lethalman88@gmail.com>
+
+        Reviewed by Alp Toker.
+
+        Handle events for Home and End keys.
+
+        * WebView/webkitwebview.cpp:
+        (webkit_web_view_key_event):
+        * WebCoreSupport/EditorClientGtk.cpp:
+        (EditorClient::handleKeypress):
+
 2007-12-05  Michael Natterer  <mitch@imendio.com>
 
         Reviewed by Alp Toker.
index 44786ebbe55cce1a3483dab6574a8de1cf9f28f8..c68069dd1948e335be525108ab40efc374a3f919 100644 (file)
@@ -269,6 +269,22 @@ void EditorClient::handleKeypress(KeyboardEvent* event)
             case VK_NEXT:  // PageDown
                 frame->editor()->execCommand("MoveDownByPageAndModifyCaret");
                 break;
+            case VK_HOME:
+                if (kevent->ctrlKey())
+                    frame->editor()->execCommand("MoveToBeginningOfDocument");
+                else if (kevent->shiftKey())
+                    frame->editor()->execCommand("MoveToBeginningOfLineAndModifySelection");
+                else
+                    frame->editor()->execCommand("MoveToBeginningOfLine");
+                break;
+            case VK_END:
+                if (kevent->ctrlKey())
+                    frame->editor()->execCommand("MoveToEndOfDocument");
+                else if (kevent->shiftKey())
+                    frame->editor()->execCommand("MoveToEndOfLineAndModifySelection");
+                else
+                    frame->editor()->execCommand("MoveToEndOfLine");
+                break;
             case VK_RETURN:
                 frame->editor()->execCommand("InsertLineBreak");
                 break;
index 08a8aef14ffff0514d79e553e48977c03ab7db04..050f0eae1f94b0537a690ab3665cb68341e09693 100644 (file)
@@ -113,6 +113,11 @@ static gboolean webkit_web_view_key_event(GtkWidget* widget, GdkEventKey* event)
 
     if (event->type == GDK_KEY_PRESS) {
         FrameView* view = frame->view();
+        SelectionController::EAlteration alteration;
+        if (event->state & GDK_SHIFT_MASK)
+            alteration = SelectionController::EXTEND;
+        else
+            alteration = SelectionController::MOVE;
 
         /* FIXME: at the very least we should be using the same code than the
            Windows port here, but our ScrollView file diverges enough to make
@@ -133,6 +138,12 @@ static gboolean webkit_web_view_key_event(GtkWidget* widget, GdkEventKey* event)
         case GDK_Left:
             view->scrollBy(-LINE_STEP, 0);
             return TRUE;
+        case GDK_Home:
+            frame->selectionController()->modify(alteration, SelectionController::BACKWARD, DocumentBoundary, true);
+            return TRUE;
+        case GDK_End:
+            frame->selectionController()->modify(alteration, SelectionController::FORWARD, DocumentBoundary, true);
+            return TRUE;
         }
     }