// 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);
// 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();
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();