X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f52eff546ab16990767e06e25c00b3d8fd2729f9..fcb29b233888f7012ca6cf486c8287f5463787e0:/src/richtext/richtextctrl.cpp diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 9fc9317ce0..749eba3829 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -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(); @@ -2031,7 +2039,7 @@ void wxRichTextCtrl::DoWriteText(const wxString& value, int flags) { wxString valueUnix = wxTextFile::Translate(value, wxTextFileType_Unix); - GetBuffer().InsertTextWithUndo(m_caretPosition+1, valueUnix, this); + GetBuffer().InsertTextWithUndo(m_caretPosition+1, valueUnix, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE); if ( flags & SetValue_SendEvent ) SendTextUpdatedEvent(); @@ -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(); @@ -2913,7 +2929,7 @@ bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def) { // Flags are defined within each definition, so only certain // attributes are applied. - wxRichTextAttr attr(def->GetStyle()); + wxRichTextAttr attr(GetStyleSheet() ? def->GetStyleMergedWithBase(GetStyleSheet()) : def->GetStyle()); int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE;