Permalink
Browse files

TextArea: added method for sorting text

  • Loading branch information...
1 parent 9c68811 commit c94948389a2a4bf0a5351d283b511d2e116e8bfb @lynxlynxlynx lynxlynxlynx committed Dec 29, 2013
Showing with 15 additions and 0 deletions.
  1. +14 −0 gemrb/core/GUI/TextArea.cpp
  2. +1 −0 gemrb/core/GUI/TextArea.h
View
14 gemrb/core/GUI/TextArea.cpp
@@ -18,6 +18,8 @@
*
*/
+#include <list>
+
#include "TextArea.h"
#include "win32def.h"
@@ -986,4 +988,16 @@ void TextArea::SetFocus(bool focus)
}
}
+static bool charSorter(const char *a, const char *b) {
+ return stricmp(a, b) < 0;
+}
+
+void TextArea::SortText()
+{
+ std::list<char*> sorter(lines.begin(), lines.end());
+ sorter.sort(charSorter);
+ lines.assign(sorter.begin(), sorter.end());
+ CalcRowCount();
+}
+
}
View
1 gemrb/core/GUI/TextArea.h
@@ -120,6 +120,7 @@ class GEM_EXPORT TextArea : public Control {
/** Marks textarea for redraw with a new value */
void UpdateState(const char* VariableName, unsigned int Sum);
int SetScrollBar(Control *ptr);
+ void SortText();
private: // Private attributes
std::vector< char*> lines;
std::vector< int> lrows;

0 comments on commit c949483

Please sign in to comment.