Browse files

Move helper function to Strings.

  • Loading branch information...
1 parent fba193d commit c342bcfb731c422eb9de707547994cf212e9cfc0 @adamv adamv committed Oct 23, 2009
Showing with 29 additions and 24 deletions.
  1. +3 −23 src/EditorCtrl.cpp
  2. +0 −1 src/EditorCtrl.h
  3. +21 −0 src/Strings.cpp
  4. +5 −0 src/Strings.h
View
26 src/EditorCtrl.cpp
@@ -42,7 +42,7 @@
#include "LiveCaret.h"
#include "eSettings.h"
#include "IAppPaths.h"
-
+#include "Strings.h"
#include "pcre.h"
// Document Icons
@@ -4451,7 +4451,7 @@ void EditorCtrl::OnPaste() {
if (copytext.empty()) return;
#ifdef __WXMSW__
- ConvertCRLFtoLF(copytext);
+ InplaceConvertCRLFtoLF(copytext);
#endif // __WXMSW__
Freeze();
@@ -4464,26 +4464,6 @@ void EditorCtrl::OnPaste() {
}
}
-#ifdef __WXMSW__
-void EditorCtrl::ConvertCRLFtoLF(wxString& text) { // static
- // WINDOWS ONLY!! newline conversion
- // The build-in replace is too slow so we do
- // it manually (at the price of some memory)
- //copytext.Replace(wxT("\r\n"), wxT("\n"));
- wxString newtext;
- newtext.reserve(text.size());
- unsigned int lastPos = 0;
- for (unsigned int i = 0; i < text.size(); ++i) {
- if (text[i] == wxT('\r')) {
- newtext += text.substr(lastPos, i - lastPos);
- lastPos = i + 1;
- }
- }
- if (lastPos < text.size()) newtext += text.substr(lastPos, text.size() - lastPos);
- text.swap(newtext);
-}
-#endif // __WXMSW__
-
bool EditorCtrl::IsSelected() const {
return m_lines.IsSelected();
}
@@ -8187,7 +8167,7 @@ void EditorCtrl::OnDragDropText(const wxString& text, wxDragResult dragType) {
#ifdef __WXMSW__
wxString copytext = text;
- ConvertCRLFtoLF(copytext);
+ InplaceConvertCRLFtoLF(copytext);
const unsigned int byte_len = RawInsert(pos, copytext);
#else
const unsigned int byte_len = RawInsert(pos, text);
View
1 src/EditorCtrl.h
@@ -547,7 +547,6 @@ class EditorCtrl : public KeyHookable<wxControl>,
bool cmd_Undo(int count, vector<int>& cStack, bool end=false);
// Utility functions
- static void ConvertCRLFtoLF(wxString& text);
static bool Isalnum(wxChar c) {
#ifdef __WXMSW__
return ::IsCharAlphaNumeric(c) != 0;
View
21 src/Strings.cpp
@@ -1,6 +1,27 @@
#include "Strings.h"
#include "wx/tokenzr.h"
+#ifdef __WXMSW__
+void InplaceConvertCRLFtoLF(wxString& text) {
+ // WINDOWS ONLY!! newline conversion
+ // The build-in replace is too slow so we do
+ // it manually (at the price of some memory)
+ //copytext.Replace(wxT("\r\n"), wxT("\n"));
+ wxString newtext;
+ newtext.reserve(text.size());
+ unsigned int lastPos = 0;
+ for (unsigned int i = 0; i < text.size(); ++i) {
+ if (text[i] == wxT('\r')) {
+ newtext += text.substr(lastPos, i - lastPos);
+ lastPos = i + 1;
+ }
+ }
+ if (lastPos < text.size()) newtext += text.substr(lastPos, text.size() - lastPos);
+ text.swap(newtext);
+}
+#endif // __WXMSW__
+
+
int wxCMPFUNC_CONV wxStringSortAscendingNoCase(wxString* s1, wxString* s2)
{
return s1->CmpNoCase(*s2);
View
5 src/Strings.h
@@ -10,6 +10,11 @@ int HexToNumber(wxChar hexDigit);
void SimpleHtmlEncode(wxString& s);
wxString URLDecode(const wxString &value);
+#ifdef __WXMSW__
+void InplaceConvertCRLFtoLF(wxString& text);
+#endif
+
+
// Back-port of wxJoin and wxSplit from newer versions of wxWidgets
// ----------------------------------------------------------------------------

0 comments on commit c342bcf

Please sign in to comment.