📄 scintillawx.cpp
字号:
delete surfaceWindow; if (paintState == paintAbandoned) { // Painting area was insufficient to cover new styling or brace // highlight positions FullPaint(); } paintState = notPainting;}void ScintillaWX::DoHScroll(int type, int pos) { int xPos = xOffset; PRectangle rcText = GetTextRectangle(); int pageWidth = rcText.Width() * 2 / 3; if (type == wxEVT_SCROLLWIN_LINEUP || type == wxEVT_SCROLL_LINEUP) xPos -= H_SCROLL_STEP; else if (type == wxEVT_SCROLLWIN_LINEDOWN || type == wxEVT_SCROLL_LINEDOWN) xPos += H_SCROLL_STEP; else if (type == wxEVT_SCROLLWIN_PAGEUP || type == wxEVT_SCROLL_PAGEUP) xPos -= pageWidth; else if (type == wxEVT_SCROLLWIN_PAGEDOWN || type == wxEVT_SCROLL_PAGEDOWN) { xPos += pageWidth; if (xPos > scrollWidth - rcText.Width()) { xPos = scrollWidth - rcText.Width(); } } else if (type == wxEVT_SCROLLWIN_TOP || type == wxEVT_SCROLL_TOP) xPos = 0; else if (type == wxEVT_SCROLLWIN_BOTTOM || type == wxEVT_SCROLL_BOTTOM) xPos = scrollWidth; else if (type == wxEVT_SCROLLWIN_THUMBTRACK || type == wxEVT_SCROLL_THUMBTRACK) xPos = pos; HorizontalScrollTo(xPos);}void ScintillaWX::DoVScroll(int type, int pos) { int topLineNew = topLine; if (type == wxEVT_SCROLLWIN_LINEUP || type == wxEVT_SCROLL_LINEUP) topLineNew -= 1; else if (type == wxEVT_SCROLLWIN_LINEDOWN || type == wxEVT_SCROLL_LINEDOWN) topLineNew += 1; else if (type == wxEVT_SCROLLWIN_PAGEUP || type == wxEVT_SCROLL_PAGEUP) topLineNew -= LinesToScroll(); else if (type == wxEVT_SCROLLWIN_PAGEDOWN || type == wxEVT_SCROLL_PAGEDOWN) topLineNew += LinesToScroll(); else if (type == wxEVT_SCROLLWIN_TOP || type == wxEVT_SCROLL_TOP) topLineNew = 0; else if (type == wxEVT_SCROLLWIN_BOTTOM || type == wxEVT_SCROLL_BOTTOM) topLineNew = MaxScrollPos(); else if (type == wxEVT_SCROLLWIN_THUMBTRACK || type == wxEVT_SCROLL_THUMBTRACK) topLineNew = pos; ScrollTo(topLineNew);}void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll ) { int topLineNew = topLine; int lines; if (ctrlDown) { // Zoom the fonts if Ctrl key down if (rotation < 0) { KeyCommand(SCI_ZOOMIN); } else { KeyCommand(SCI_ZOOMOUT); } } else { // otherwise just scroll the window if ( !delta ) delta = 120; wheelRotation += rotation; lines = wheelRotation / delta; wheelRotation -= lines * delta; if (lines != 0) { if (isPageScroll) lines = lines * LinesOnScreen(); // lines is either +1 or -1 else lines *= linesPerAction; topLineNew -= lines; ScrollTo(topLineNew); } }}void ScintillaWX::DoSize(int WXUNUSED(width), int WXUNUSED(height)) { ChangeSize();}void ScintillaWX::DoLoseFocus(){ focusEvent = true; SetFocusState(false); focusEvent = false; DestroySystemCaret();}void ScintillaWX::DoGainFocus(){ focusEvent = true; SetFocusState(true); focusEvent = false; DestroySystemCaret(); CreateSystemCaret();}void ScintillaWX::DoSysColourChange() { InvalidateStyleData();}void ScintillaWX::DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { ButtonDown(pt, curTime, shift, ctrl, alt);}void ScintillaWX::DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl) { ButtonUp(pt, curTime, ctrl);#if wxUSE_DRAG_AND_DROP if (startDragTimer->IsRunning()) { startDragTimer->Stop(); SetDragPosition(invalidPosition); SetEmptySelection(PositionFromLocation(pt)); ShowCaretAtCurrentPosition(); }#endif}void ScintillaWX::DoLeftButtonMove(Point pt) { ButtonMove(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); MovePositionTo(newPos, noSel, true); pdoc->BeginUndoAction(); wxTextDataObject data; bool gotData = false; if (wxTheClipboard->Open()) { wxTheClipboard->UsePrimarySelection(true); gotData = wxTheClipboard->GetData(data); wxTheClipboard->UsePrimarySelection(false); wxTheClipboard->Close(); } if (gotData) { wxString text = wxTextBuffer::Translate (data.GetText(), wxConvertEOLMode(pdoc->eolMode)); data.SetText(wxEmptyString); // free the data object content wxWX2MBbuf buf = (wxWX2MBbuf)wx2sci(text);//? text = wxEmptyString; // free text int len = strlen(buf); pdoc->InsertString(currentPos, buf, len); SetEmptySelection(currentPos + len); } pdoc->EndUndoAction(); NotifyChange(); Redraw(); ShowCaretAtCurrentPosition(); EnsureCaretVisible();}#elsevoid ScintillaWX::DoMiddleButtonUp(Point WXUNUSED(pt)) {}#endifvoid ScintillaWX::DoAddChar(int key) {#if wxUSE_UNICODE wxChar wszChars[2]; wszChars[0] = (wxChar)key; wszChars[1] = 0; wxWX2MBbuf buf = (wxWX2MBbuf)wx2sci(wszChars); AddCharUTF((char*)buf.data(), strlen(buf));#else AddChar((char)key);#endif}int ScintillaWX::DoKeyDown(const wxKeyEvent& evt, bool* consumed){ int key = evt.GetKeyCode(); bool shift = evt.ShiftDown(), ctrl = evt.ControlDown(), alt = evt.AltDown(); if (ctrl && key >= 1 && key <= 26 && key != WXK_BACK) key += 'A' - 1; switch (key) { case WXK_DOWN: key = SCK_DOWN; break; case WXK_UP: key = SCK_UP; break; case WXK_LEFT: key = SCK_LEFT; break; case WXK_RIGHT: key = SCK_RIGHT; break; case WXK_HOME: key = SCK_HOME; break; case WXK_END: key = SCK_END; break;#if !wxCHECK_VERSION(2, 7, 0) case WXK_PAGEUP: // fall through#endif case WXK_PAGEUP: key = SCK_PRIOR; break;#if !wxCHECK_VERSION(2, 7, 0) case WXK_PAGEDOWN: // fall through#endif case WXK_PAGEDOWN: key = SCK_NEXT; break; case WXK_DELETE: key = SCK_DELETE; break; case WXK_INSERT: key = SCK_INSERT; break; case WXK_ESCAPE: key = SCK_ESCAPE; break; case WXK_BACK: key = SCK_BACK; break; case WXK_TAB: key = SCK_TAB; break; case WXK_NUMPAD_ENTER: // fall through case WXK_RETURN: key = SCK_RETURN; break; case WXK_ADD: // fall through case WXK_NUMPAD_ADD: key = SCK_ADD; break; case WXK_SUBTRACT: // fall through case WXK_NUMPAD_SUBTRACT: key = SCK_SUBTRACT; break; case WXK_DIVIDE: // fall through case WXK_NUMPAD_DIVIDE: key = SCK_DIVIDE; break; case WXK_CONTROL: key = 0; break; case WXK_ALT: key = 0; break; case WXK_SHIFT: key = 0; break; case WXK_MENU: key = 0; break; }#ifdef __WXMAC__ if ( evt.MetaDown() ) { // 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) return rv; else return 1;}void ScintillaWX::DoCommand(int ID) { Command(ID);}void ScintillaWX::DoContextMenu(Point pt) { if (displayPopupMenu) ContextMenu(pt);}void ScintillaWX::DoOnListBox() { AutoCompleteCompleted();}void ScintillaWX::DoOnIdle(wxIdleEvent& evt) { if ( Idle() ) evt.RequestMore(); else SetIdle(false);}//----------------------------------------------------------------------#if wxUSE_DRAG_AND_DROPbool ScintillaWX::DoDropText(long x, long y, const wxString& data) { SetDragPosition(invalidPosition); wxString text = wxTextBuffer::Translate (data, wxConvertEOLMode(pdoc->eolMode)); // Send an event to allow the drag details to be changed wxScintillaEvent evt(wxEVT_SCI_DO_DROP, sci->GetId()); evt.SetEventObject(sci); evt.SetDragResult(dragResult); evt.SetX(x); evt.SetY(y); evt.SetPosition(PositionFromLocation(Point(x,y))); evt.SetDragText(text); sci->GetEventHandler()->ProcessEvent(evt); dragResult = evt.GetDragResult(); if (dragResult == wxDragMove || dragResult == wxDragCopy) { DropAt(evt.GetPosition(), wx2sci(evt.GetDragText()), dragResult == wxDragMove, dragRectangle); return true; } return false;}wxDragResult ScintillaWX::DoDragEnter(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxDragResult def) { dragResult = def; return dragResult;}wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { SetDragPosition(PositionFromLocation(Point(x, y))); // Send an event to allow the drag result to be changed wxScintillaEvent evt(wxEVT_SCI_DRAG_OVER, sci->GetId()); evt.SetEventObject(sci); evt.SetDragResult(def); evt.SetX(x); evt.SetY(y); evt.SetPosition(PositionFromLocation(Point(x,y))); sci->GetEventHandler()->ProcessEvent(evt); dragResult = evt.GetDragResult(); return dragResult;}void ScintillaWX::DoDragLeave() { SetDragPosition(invalidPosition);}#endif//----------------------------------------------------------------------// Force the whole window to be repaintedvoid ScintillaWX::FullPaint() {#ifndef __WXMAC__ sci->Refresh(false);#endif sci->Update();}void ScintillaWX::DoScrollToLine(int line) { ScrollTo(line);}void ScintillaWX::DoScrollToColumn(int column) { HorizontalScrollTo(column * vs.spaceWidth);}#ifdef __WXGTK__void ScintillaWX::ClipChildren(wxDC& dc, PRectangle rect) {// wxGTK > 2.5 doesn't appear to need this explicit clipping code any longer#if !wxCHECK_VERSION(2, 5, 0) wxRegion rgn(wxRectFromPRectangle(rect)); if (ac.Active()) { wxRect childRect = ((wxWindow*)ac.lb->GetID())->GetRect(); rgn.Subtract(childRect); } if (ct.inCallTipMode) { wxSCICallTip* tip = (wxSCICallTip*)ct.wCallTip.GetID(); wxRect childRect = tip->GetRect();#if wxUSE_POPUPWIN && wxSCI_USE_POPUP childRect.SetPosition(tip->GetMyPosition());#endif rgn.Subtract(childRect); } dc.SetClippingRegion(rgn);#endif}#elsevoid ScintillaWX::ClipChildren(wxDC& WXUNUSED(dc), PRectangle WXUNUSED(rect)) {}#endifvoid ScintillaWX::SetUseAntiAliasing(bool useAA) { vs.extraFontFlag = useAA; InvalidateStyleRedraw();}bool ScintillaWX::GetUseAntiAliasing() { return vs.extraFontFlag;}//----------------------------------------------------------------------//----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -