X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c26dba42b75b2c19df5834417ffbe330bc375b20..31d7fc0f9cb3f5913ecd4a039a816487a6753a93:/contrib/src/stc/stc.cpp?ds=sidebyside diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index 708ecbeb4e..c3a5c5a725 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -2547,9 +2547,12 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename) if (len > 0) { #if wxUSE_UNICODE - wxMemoryBuffer buffer(len); + wxMemoryBuffer buffer(len+1); success = (file.Read(buffer.GetData(), len) == len); - contents = wxString(buffer, *wxConvCurrent); + if (success) { + ((char*)buffer.GetData())[len] = 0; + contents = wxString(buffer, *wxConvCurrent, len); + } #else wxString buffer; success = (file.Read(wxStringBuffer(buffer, len), len) == len); @@ -2656,6 +2659,14 @@ void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) { void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { wxPoint pt = evt.GetPosition(); ScreenToClient(&pt.x, &pt.y); + /* + Show context menu at event point if it's within the window, + or at caret location if not + */ + wxHitTest ht = this->HitTest(pt); + if (ht != wxHT_WINDOW_INSIDE) { + pt = this->PointFromPosition(this->GetCurrentPos()); + } m_swx->DoContextMenu(Point(pt.x, pt.y)); } @@ -2683,7 +2694,7 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { // printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n", // key, m_lastKeyDownConsumed, ctrl, alt, skip); - if ( (key <= WXK_START || key > WXK_NUMPAD_DIVIDE) && + if ( (key <= WXK_START || key > WXK_COMMAND) && !m_lastKeyDownConsumed && !skip) { m_swx->DoAddChar(key); return;