Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core/StarText.hpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-07-22 22:31:04 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-07-22 22:31:04 +1000
commitcb19eef701b5c9e27d0464795fffcf8a4d795a21 (patch)
tree5cfbdf49ebd7ac9539891eea850e244887d4c355 /source/core/StarText.hpp
parent4fbd67daccfa69df6988bdf17c67ee3d5f3049c5 (diff)
Add character swapping (no GUI yet)
Diffstat (limited to 'source/core/StarText.hpp')
-rw-r--r--source/core/StarText.hpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/core/StarText.hpp b/source/core/StarText.hpp
new file mode 100644
index 0000000..e318484
--- /dev/null
+++ b/source/core/StarText.hpp
@@ -0,0 +1,26 @@
+#ifndef STAR_TEXT_HPP
+#define STAR_TEXT_HPP
+#include "StarString.hpp"
+#include "StarStringView.hpp"
+
+namespace Star {
+
+namespace Text {
+ unsigned char const StartEsc = '\x1b';
+ unsigned char const EndEsc = ';';
+ unsigned char const CmdEsc = '^';
+ unsigned char const SpecialCharLimit = ' ';
+
+ String stripEscapeCodes(String const& s);
+ inline bool isEscapeCode(char c) { return c == CmdEsc || c == StartEsc; }
+
+ typedef function<bool(StringView text)> TextCallback;
+ typedef function<bool(StringView commands)> CommandsCallback;
+ bool processText(StringView text, TextCallback textFunc, CommandsCallback commandsFunc = CommandsCallback(), bool includeCommandSides = false);
+ String preprocessEscapeCodes(String const& s);
+ String extractCodes(String const& s);
+}
+
+}
+
+#endif \ No newline at end of file