2024-02-25 15:46:47 +01:00
|
|
|
#pragma once
|
|
|
|
|
2023-07-22 22:31:04 +10:00
|
|
|
#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);
|
2023-10-27 12:24:22 +11:00
|
|
|
inline bool isEscapeCode(Utf32Type c) { return c == CmdEsc || c == StartEsc; }
|
2023-07-22 22:31:04 +10:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|