]> git.saurik.com Git - wxWidgets.git/blobdiff - src/stc/ScintillaWX.cpp
Applied patch [ 807164 ] fixes for core library
[wxWidgets.git] / src / stc / ScintillaWX.cpp
index 5f04433a23c980cfdf4765129fd2de8017ebbf5a..f294cd6ba2f24c96583333f99f387952b1c67859 100644 (file)
@@ -16,6 +16,7 @@
 
 
 #include "ScintillaWX.h"
+#include "ExternalLexer.h"
 #include "wx/stc/stc.h"
 #include "PlatWX.h"
 
@@ -337,12 +338,7 @@ void ScintillaWX::Copy() {
     if (currentPos != anchor) {
         SelectionText st;
         CopySelectionRange(&st);
-        if (wxTheClipboard->Open()) {
-            wxTheClipboard->UsePrimarySelection(FALSE);
-            wxString text = stc2wx(st.s, st.len);
-            wxTheClipboard->SetData(new wxTextDataObject(text));
-            wxTheClipboard->Close();
-        }
+        CopyToClipboard(st);
     }
 }
 
@@ -372,18 +368,31 @@ void ScintillaWX::Paste() {
 }
 
 
+void ScintillaWX::CopyToClipboard(const SelectionText& st) {
+    if (wxTheClipboard->Open()) {
+        wxTheClipboard->UsePrimarySelection(FALSE);
+        wxString text = stc2wx(st.s, st.len);
+        wxTheClipboard->SetData(new wxTextDataObject(text));
+        wxTheClipboard->Close();
+    }
+}
+
+
 bool ScintillaWX::CanPaste() {
     bool canPaste = FALSE;
     bool didOpen;
 
-    if ( (didOpen = !wxTheClipboard->IsOpened()) )
-        wxTheClipboard->Open();
+    if (Editor::CanPaste()) {
+        didOpen = !wxTheClipboard->IsOpened();
+        if ( didOpen )
+            wxTheClipboard->Open();
 
-    if (wxTheClipboard->IsOpened()) {
-        wxTheClipboard->UsePrimarySelection(FALSE);
-        canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
-        if (didOpen)
-            wxTheClipboard->Close();
+        if (wxTheClipboard->IsOpened()) {
+            wxTheClipboard->UsePrimarySelection(FALSE);
+            canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
+            if (didOpen)
+                wxTheClipboard->Close();
+        }
     }
     return canPaste;
 }
@@ -472,6 +481,11 @@ long ScintillaWX::WndProc(unsigned int iMessage, unsigned long wParam, long lPar
           break;
       }
 
+#ifdef SCI_LEXER
+       case SCI_LOADLEXERLIBRARY:
+            LexerManager::GetInstance()->Load((const char*)lParam);
+            break;
+#endif
       default:
           return ScintillaBase::WndProc(iMessage, wParam, lParam);
       }
@@ -584,7 +598,7 @@ void ScintillaWX::DoMouseWheel(int rotation, int delta,
 }
 
 
-void ScintillaWX::DoSize(int width, int height) {
+void ScintillaWX::DoSize(int WXUNUSED(width), int WXUNUSED(height)) {
 //      PRectangle rcClient(0,0,width,height);
 //      SetScrollBarsTo(rcClient);
 //      DropGraphics();
@@ -615,8 +629,8 @@ void ScintillaWX::DoLeftButtonMove(Point pt) {
     ButtonMove(pt);
 }
 
-void ScintillaWX::DoMiddleButtonUp(Point pt) {
 #ifdef __WXGTK__
+void ScintillaWX::DoMiddleButtonUp(Point pt) {
     // Set the current position to the mouse click point and
     // then paste in the PRIMARY selection, if any.  wxGTK only.
     int newPos = PositionFromLocation(pt);
@@ -643,8 +657,11 @@ void ScintillaWX::DoMiddleButtonUp(Point pt) {
 
     ShowCaretAtCurrentPosition();
     EnsureCaretVisible();
-#endif
 }
+#else
+void ScintillaWX::DoMiddleButtonUp(Point WXUNUSED(pt)) {
+}
+#endif
 
 
 void ScintillaWX::DoAddChar(int key) {
@@ -660,9 +677,10 @@ void ScintillaWX::DoAddChar(int key) {
 }
 
 
-int  ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) {
+int  ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool meta, bool* consumed) {
 #if defined(__WXGTK__) || defined(__WXMAC__)
-    // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK...
+    // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
+    // TODO:  Check this, it shouldn't be true any longer.
     if (ctrl && key >= 1 && key <= 26)
         key += 'A' - 1;
 #endif
@@ -696,6 +714,21 @@ int  ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* cons
     case WXK_MENU:              key = 0; break;
     }
 
+#ifdef __WXMAC__
+    if ( meta ) {
+        // check for a few common Mac Meta-key combos and remap them to Ctrl
+        // for Scintilla
+        switch ( key ) {
+        case 'Z':       // Undo
+        case 'X':       // Cut
+        case 'C':       // Copy
+        case 'V':       // Paste
+        case 'A':       // Select All
+            ctrl = true;
+            break;
+        }                
+#endif
+    
     int rv = KeyDown(key, shift, ctrl, alt, consumed);
 
     if (key)
@@ -747,7 +780,7 @@ bool ScintillaWX::DoDropText(long x, long y, const wxString& data) {
 }
 
 
-wxDragResult ScintillaWX::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) {
+wxDragResult ScintillaWX::DoDragEnter(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxDragResult def) {
     dragResult = def;
     return dragResult;
 }
@@ -804,8 +837,8 @@ void ScintillaWX::DoScrollToColumn(int column) {
     HorizontalScrollTo(column * vs.spaceWidth);
 }
 
-void ScintillaWX::ClipChildren(wxDC& dc, PRectangle rect) {
 #ifdef __WXGTK__
+void ScintillaWX::ClipChildren(wxDC& dc, PRectangle rect) {
     wxRegion rgn(wxRectFromPRectangle(rect));
     if (ac.Active()) {
         wxRect childRect = ((wxWindow*)ac.lb->GetID())->GetRect();
@@ -817,9 +850,11 @@ void ScintillaWX::ClipChildren(wxDC& dc, PRectangle rect) {
     }
 
     dc.SetClippingRegion(rgn);
-#endif
 }
-
+#else
+void ScintillaWX::ClipChildren(wxDC& WXUNUSED(dc), PRectangle WXUNUSED(rect)) {
+}
+#endif
 
 //----------------------------------------------------------------------
 //----------------------------------------------------------------------