]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/textcmn.cpp
Brazilian Portuguese translations update from Felipe.
[wxWidgets.git] / src / common / textcmn.cpp
index 9e04aedcaa99882f38fa6b0acb5218f0a30a3b4f..d64baccfb743c73d8cf8a6f0a9cc7409638e4320 100644 (file)
@@ -773,7 +773,7 @@ bool wxTextAttr::BitlistsEqPartial(int valueA, int valueB, int flags)
 {
     int relevantBitsA = valueA & flags;
     int relevantBitsB = valueB & flags;
-    return (relevantBitsA != relevantBitsB);
+    return relevantBitsA == relevantBitsB;
 }
 
 /// Split into paragraph and character styles
@@ -940,12 +940,47 @@ int wxTextCtrlBase::overflow(int c)
 
 bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
 {
+    bool handled = false;
     // we have a native implementation for Win32 and so don't need this one
 #ifndef __WIN32__
     wxChar ch = 0;
     int keycode = event.GetKeyCode();
+    
+    long from, to;
+    GetSelection(&from,&to);
+    long insert = GetInsertionPoint();
+    long last = GetLastPosition();
+    
+    // catch arrow left and right 
+    
     switch ( keycode )
     {
+        case WXK_LEFT:
+            if ( event.ShiftDown() )
+                SetSelection( (from > 0 ? from - 1 : 0) , to );
+            else
+            {
+                if ( from != to )
+                    insert = from;
+                else if ( insert > 0 )
+                    insert -= 1;
+                SetInsertionPoint( insert );
+            }
+            handled = true;
+            break;
+        case WXK_RIGHT:
+            if ( event.ShiftDown() )
+                SetSelection( from, (to < last ? to + 1 : last) );
+            else
+            {
+                if ( from != to )
+                    insert = to;
+                else if ( insert < last )
+                    insert += 1;
+                SetInsertionPoint( insert );
+            }
+            handled = true;
+            break;
         case WXK_NUMPAD0:
         case WXK_NUMPAD1:
         case WXK_NUMPAD2:
@@ -991,6 +1026,7 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
                 const long pos = GetInsertionPoint();
                 if ( pos < GetLastPosition() )
                     Remove(pos, pos + 1);
+                handled = true;
             }
             break;
 
@@ -1000,6 +1036,7 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
                 const long pos = GetInsertionPoint();
                 if ( pos > 0 )
                     Remove(pos - 1, pos);
+                handled = true;
             }
             break;
 
@@ -1031,13 +1068,13 @@ bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
     {
         WriteText(ch);
 
-        return true;
+        handled = true;
     }
 #else // __WIN32__
     wxUnusedVar(event);
 #endif // !__WIN32__/__WIN32__
 
-    return false;
+    return handled;
 }
 
 // do the window-specific processing after processing the update event