For consistency with all the other wxTextCtrl-like classes, the value returned
by this method must not include line terminator characters (like '\n'). Notice
that Scintilla-specific GetLine() does still include them, for consistency
with the Scintilla API itself.
Closes #13646.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73140
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// ---------------------------------------------
virtual int GetLineLength(long n) const { return GetLine(n).length(); }
- virtual wxString GetLineText(long n) const { return GetLine(n); }
+ virtual wxString GetLineText(long lineNo) const
+ {
+ wxString text = GetLine(static_cast<int>(lineNo));
+ size_t lastNewLine = text.find_last_not_of(wxS("\r\n"));
+
+ if ( lastNewLine != wxString::npos )
+ text.erase(lastNewLine + 1); // remove trailing cr+lf
+ else
+ text.clear();
+ return text;
+ }
virtual int GetNumberOfLines() const { return GetLineCount(); }
virtual bool IsModified() const { return GetModify(); }
// ---------------------------------------------
virtual int GetLineLength(long n) const { return GetLine(n).length(); }
- virtual wxString GetLineText(long n) const { return GetLine(n); }
+ virtual wxString GetLineText(long lineNo) const
+ {
+ wxString text = GetLine(static_cast<int>(lineNo));
+ size_t lastNewLine = text.find_last_not_of(wxS("\r\n"));
+
+ if ( lastNewLine != wxString::npos )
+ text.erase(lastNewLine + 1); // remove trailing cr+lf
+ else
+ text.clear();
+ return text;
+ }
virtual int GetNumberOfLines() const { return GetLineCount(); }
virtual bool IsModified() const { return GetModify(); }