X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/35f8d83dbb985f81b7b7b63f113b05e7ca243489..5c413e62cfe6d551d5297fca88721bc8897bb671:/src/stc/stc.cpp.in diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index eb6c021027..10ceabad07 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -199,7 +199,7 @@ bool wxStyledTextCtrl::Create(wxWindow *parent, m_swx = new ScintillaWX(this); m_stopWatch.Start(); m_lastKeyDownConsumed = false; - m_lastWheelTimestamp = 0; + m_timeToBlockWheelEventsUntil = 0; m_vScrollBar = NULL; m_hScrollBar = NULL; #if wxUSE_UNICODE @@ -210,7 +210,7 @@ bool wxStyledTextCtrl::Create(wxWindow *parent, SetInitialSize(size); // Reduces flicker on GTK+/X11 - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); // Make sure it can take the focus SetCanFocus(true); @@ -586,9 +586,11 @@ bool wxStyledTextCtrl::GetUseAntiAliasing() { -void wxStyledTextCtrl::AddTextRaw(const char* text) +void wxStyledTextCtrl::AddTextRaw(const char* text, int length) { - SendMsg(SCI_ADDTEXT, strlen(text), (sptr_t)text); + if (length == -1) + length = strlen(text); + SendMsg(SCI_ADDTEXT, length, (sptr_t)text); } void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text) @@ -626,16 +628,10 @@ wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line) wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw() { - long start; - long end; - - GetSelection(&start, &end); - int len = end - start; - if (!len) { - wxCharBuffer empty; - return empty; - } + // Calculate the length needed first. + const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0); + // And then really get the data. wxCharBuffer buf(len); SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data()); return buf; @@ -676,9 +672,11 @@ wxCharBuffer wxStyledTextCtrl::GetTextRaw() return buf; } -void wxStyledTextCtrl::AppendTextRaw(const char* text) +void wxStyledTextCtrl::AppendTextRaw(const char* text, int length) { - SendMsg(SCI_APPENDTEXT, strlen(text), (sptr_t)text); + if (length == -1) + length = strlen(text); + SendMsg(SCI_APPENDTEXT, length, (sptr_t)text); } @@ -764,18 +762,24 @@ void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) { - // prevent having an event queue with wheel events that cannot be processed - // reasonably fast (see ticket #9057) - if ( m_lastWheelTimestamp <= evt.GetTimestamp() ) + // Prevent having an event queue with wheel events that cannot be processed + // reasonably fast (see ticket #9057) by ignoring all of them that happen + // during the time interval corresponding to the time it took us to handle + // the last one. + // + // Notice the use of TimeInMicro() instead of Time() to avoid overflow in + // long running programs. + if ( m_timeToBlockWheelEventsUntil <= m_stopWatch.TimeInMicro() ) { - m_lastWheelTimestamp = m_stopWatch.Time(); + const wxLongLong beforeMouseWheel = m_stopWatch.TimeInMicro(); m_swx->DoMouseWheel(evt.GetWheelRotation(), evt.GetWheelDelta(), evt.GetLinesPerAction(), evt.ControlDown(), evt.IsPageScroll()); - m_lastWheelTimestamp = m_stopWatch.Time() - m_lastWheelTimestamp; - m_lastWheelTimestamp += evt.GetTimestamp(); + const wxLongLong afterMouseWheel = m_stopWatch.TimeInMicro(); + m_timeToBlockWheelEventsUntil = afterMouseWheel; + m_timeToBlockWheelEventsUntil += afterMouseWheel - beforeMouseWheel; } } @@ -1118,4 +1122,9 @@ wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event): //---------------------------------------------------------------------- //---------------------------------------------------------------------- +/*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo() +{ + return wxVersionInfo("Scintilla", 2, 3, 0, "Scintilla 2.03"); +} + #endif // wxUSE_STC