summaryrefslogtreecommitdiff
path: root/src/os/macosx/string_osx.h
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2018-10-21 18:40:39 +0200
committerMichael Lutz <michi@icosahedron.de>2018-12-08 20:13:27 +0100
commit4bf216993a1df7a29922bf34e2d8191460842452 (patch)
treea8de9ee762949c1cb0fb07f0d14d6ebdeb1e5510 /src/os/macosx/string_osx.h
parent8d7cd6a5262ae151e30fe6db18d04648ebe9d8d7 (diff)
downloadopenttd-4bf216993a1df7a29922bf34e2d8191460842452.tar.xz
Add: [OSX] Native text caret handling.
Diffstat (limited to 'src/os/macosx/string_osx.h')
-rw-r--r--src/os/macosx/string_osx.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/os/macosx/string_osx.h b/src/os/macosx/string_osx.h
index 90bac48d2..ea7904f54 100644
--- a/src/os/macosx/string_osx.h
+++ b/src/os/macosx/string_osx.h
@@ -12,6 +12,32 @@
#ifndef STRING_OSX_H
#define STRING_OSX_H
+#include "../../gfx_layout.h"
+#include "../../string_base.h"
+#include <vector>
+
+/** String iterator using CoreText as a backend. */
+class OSXStringIterator : public StringIterator {
+ /** Break info for a character. */
+ struct CharInfo {
+ bool word_stop : 1; ///< Code point is suitable as a word break.
+ bool char_stop : 1; ///< Code point is the start of a grapheme cluster, i.e. a "character".
+ };
+
+ std::vector<CharInfo> str_info; ///< Break information for each code point.
+ std::vector<size_t> utf16_to_utf8; ///< Mapping from UTF-16 code point position to index in the UTF-8 source string.
+
+ size_t cur_pos; ///< Current iteration position.
+
+public:
+ virtual void SetString(const char *s);
+ virtual size_t SetCurPosition(size_t pos);
+ virtual size_t Next(IterType what);
+ virtual size_t Prev(IterType what);
+
+ static StringIterator *Create();
+};
+
void MacOSSetCurrentLocaleName(const char *iso_code);
int MacOSStringCompare(const char *s1, const char *s2);