X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ea6c48d33d32836030d4ae631df3d61427f70f..f72ed385786eccca7a73cbace9bae975e3a2ae21:/src/richtext/richtextctrl.cpp diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index baf346df1c..dbc9ea9080 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -293,12 +293,12 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va // Accelerators wxAcceleratorEntry entries[6]; - entries[0].Set(wxACCEL_CMD, (int) 'C', wxID_COPY); - entries[1].Set(wxACCEL_CMD, (int) 'X', wxID_CUT); - entries[2].Set(wxACCEL_CMD, (int) 'V', wxID_PASTE); - entries[3].Set(wxACCEL_CMD, (int) 'A', wxID_SELECTALL); - entries[4].Set(wxACCEL_CMD, (int) 'Z', wxID_UNDO); - entries[5].Set(wxACCEL_CMD, (int) 'Y', wxID_REDO); + entries[0].Set(wxACCEL_CTRL, (int) 'C', wxID_COPY); + entries[1].Set(wxACCEL_CTRL, (int) 'X', wxID_CUT); + entries[2].Set(wxACCEL_CTRL, (int) 'V', wxID_PASTE); + entries[3].Set(wxACCEL_CTRL, (int) 'A', wxID_SELECTALL); + entries[4].Set(wxACCEL_CTRL, (int) 'Z', wxID_UNDO); + entries[5].Set(wxACCEL_CTRL, (int) 'Y', wxID_REDO); wxAcceleratorTable accel(6, entries); SetAcceleratorTable(accel); @@ -2925,13 +2925,19 @@ void wxRichTextCtrl::SetSelection(long from, long to) // Editing // ---------------------------------------------------------------------------- -void wxRichTextCtrl::Replace(long WXUNUSED(from), long WXUNUSED(to), +void wxRichTextCtrl::Replace(long from, long to, const wxString& value) { BeginBatchUndo(_("Replace")); + SetSelection(from, to); + + wxRichTextAttr attr = GetDefaultStyle(); + DeleteSelectedContent(); + SetDefaultStyle(attr); + DoWriteText(value, SetValue_SelectionOnly); EndBatchUndo(); @@ -3371,13 +3377,26 @@ void wxRichTextCtrl::PositionCaret(wxRichTextParagraphLayoutBox* container) if (GetCaret()->GetSize() != newSz) GetCaret()->SetSize(newSz); - int halfSize = newSz.y/2; - // If the caret is beyond the margin, hide it by moving it out of the way - if (((pt.y + halfSize) < GetBuffer().GetTopMargin()) || ((pt.y + halfSize) > (GetClientSize().y - GetBuffer().GetBottomMargin()))) + // Adjust size so the caret size and position doesn't appear in the margins + if (((pt.y + newSz.y) <= GetBuffer().GetTopMargin()) || (pt.y >= (GetClientSize().y - GetBuffer().GetBottomMargin()))) { pt.x = -200; pt.y = -200; } + else if (pt.y < GetBuffer().GetTopMargin() && (pt.y + newSz.y) > GetBuffer().GetTopMargin()) + { + newSz.y -= (GetBuffer().GetTopMargin() - pt.y); + if (newSz.y > 0) + { + pt.y = GetBuffer().GetTopMargin(); + GetCaret()->SetSize(newSz); + } + } + else if (pt.y < (GetClientSize().y - GetBuffer().GetBottomMargin()) && (pt.y + newSz.y) > (GetClientSize().y - GetBuffer().GetBottomMargin())) + { + newSz.y = GetClientSize().y - GetBuffer().GetBottomMargin() - pt.y; + GetCaret()->SetSize(newSz); + } GetCaret()->Move(pt); GetCaret()->Show();