Fixed a bug setting caret position after setting or clearing selection

Implemented forced line breaks within a paragraph, entered with Shift-Return.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43540 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2006-11-20 11:33:44 +00:00
parent 2c40325930
commit ff76711fbe
4 changed files with 132 additions and 20 deletions

View File

@@ -556,7 +556,15 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event)
DeleteSelectedContent(& newPos);
GetBuffer().InsertNewlineWithUndo(newPos+1, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE);
if (event.ShiftDown())
{
wxString text;
text = wxRichTextLineBreakChar;
GetBuffer().InsertTextWithUndo(newPos+1, text, this);
}
else
GetBuffer().InsertNewlineWithUndo(newPos+1, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE);
EndBatchUndo();
SetDefaultStyleToCursorStyle();
@@ -2092,6 +2100,13 @@ bool wxRichTextCtrl::Newline()
return GetBuffer().InsertNewlineWithUndo(m_caretPosition+1, this);
}
/// Insert a line break at the current insertion point.
bool wxRichTextCtrl::LineBreak()
{
wxString text;
text = wxRichTextLineBreakChar;
return GetBuffer().InsertTextWithUndo(m_caretPosition+1, text, this);
}
// ----------------------------------------------------------------------------
// Clipboard operations
@@ -2240,7 +2255,8 @@ void wxRichTextCtrl::DoSetSelection(long from, long to, bool WXUNUSED(scrollCare
{
m_selectionAnchor = from;
m_selectionRange.SetRange(from, to-1);
m_caretPosition = from-1;
if (from > -2)
m_caretPosition = from-1;
Refresh(false);
PositionCaret();