From 85543d154a540cfcebb977e7ff85e5532d90b50d Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 7 Jun 2007 12:49:35 +0000 Subject: [PATCH] Don't insert a newline when we get text git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@46354 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/richtext/richtextbuffer.cpp | 4 +--- src/richtext/richtextctrl.cpp | 21 ++++++--------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index a37a1cfc4d..088bea9e26 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -1429,8 +1429,6 @@ wxString wxRichTextParagraphLayoutBox::GetTextForRange(const wxRichTextRange& ra wxRichTextObject* child = node->GetData(); if (!child->GetRange().IsOutside(range)) { -// if (lineCount > 0) -// text += wxT("\n"); wxRichTextRange childRange = range; childRange.LimitTo(child->GetRange()); @@ -1438,7 +1436,7 @@ wxString wxRichTextParagraphLayoutBox::GetTextForRange(const wxRichTextRange& ra text += childText; - if (childRange.GetEnd() == child->GetRange().GetEnd()) + if ((childRange.GetEnd() == child->GetRange().GetEnd()) && node->GetNext()) text += wxT("\n"); lineCount ++; diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 952dc4baa2..1811d357eb 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -2035,30 +2035,21 @@ void wxRichTextCtrl::DoSetValue(const wxString& value, int flags) { Clear(); - // if the text is long enough, it's faster to just set it instead of first - // comparing it with the old one (chances are that it will be different - // anyhow, this comparison is there to avoid flicker for small single-line - // edit controls mostly) - if ( (value.length() > 0x400) || (value != GetValue()) ) + if (!value.IsEmpty()) { + // Remove empty paragraph + GetBuffer().Clear(); DoWriteText(value); // for compatibility, don't move the cursor when doing SetValue() SetInsertionPoint(0); } - else // same text + else { - if ( flags & SetValue_SendEvent ) - { - // still send an event for consistency + // still send an event for consistency + if (flags & SetValue_SendEvent) SendTextUpdatedEvent(); - } } - - // we should reset the modified flag even if the value didn't really change - - // mark the control as being not dirty - we changed its text, not the - // user DiscardEdits(); }