Use StringBuilder for GetString/GetStringWithArgs, as per upstream

Update dependent code as required
This commit is contained in:
Jonathan G Rennison
2024-01-05 21:12:54 +00:00
parent 1b7a5372ec
commit f034714559
61 changed files with 1064 additions and 1228 deletions

View File

@@ -30,37 +30,36 @@ enum HandleKeyPressResult
struct Textbuf {
CharSetFilter afilter; ///< Allowed characters
char * const buf; ///< buffer in which text is saved
uint16 max_bytes; ///< the maximum size of the buffer in bytes (including terminating '\0')
uint16 max_chars; ///< the maximum size of the buffer in characters (including terminating '\0')
uint16 bytes; ///< the current size of the string in bytes (including terminating '\0')
uint16 chars; ///< the current size of the string in characters (including terminating '\0')
uint16 pixels; ///< the current size of the string in pixels
uint16_t max_bytes; ///< the maximum size of the buffer in bytes (including terminating '\0')
uint16_t max_chars; ///< the maximum size of the buffer in characters (including terminating '\0')
uint16_t bytes; ///< the current size of the string in bytes (including terminating '\0')
uint16_t chars; ///< the current size of the string in characters (including terminating '\0')
uint16_t pixels; ///< the current size of the string in pixels
bool caret; ///< is the caret ("_") visible or not
uint16 caretpos; ///< the current position of the caret in the buffer, in bytes
uint16 caretxoffs; ///< the current position of the caret in pixels
uint16 markpos; ///< the start position of the marked area in the buffer, in bytes
uint16 markend; ///< the end position of the marked area in the buffer, in bytes
uint16 markxoffs; ///< the start position of the marked area in pixels
uint16 marklength; ///< the length of the marked area in pixels
uint16_t caretpos; ///< the current position of the caret in the buffer, in bytes
uint16_t caretxoffs; ///< the current position of the caret in pixels
uint16_t markpos; ///< the start position of the marked area in the buffer, in bytes
uint16_t markend; ///< the end position of the marked area in the buffer, in bytes
uint16_t markxoffs; ///< the start position of the marked area in pixels
uint16_t marklength; ///< the length of the marked area in pixels
explicit Textbuf(uint16 max_bytes, uint16 max_chars = UINT16_MAX);
explicit Textbuf(uint16_t max_bytes, uint16_t max_chars = UINT16_MAX);
~Textbuf();
void Assign(StringID string);
void Assign(const char *text);
void Assign(const std::string &text);
void Assign(const std::string_view text);
void CDECL Print(const char *format, ...) WARN_FORMAT(2, 3);
void DeleteAll();
bool InsertClipboard();
bool InsertChar(WChar key);
bool InsertChar(char32_t key);
bool InsertString(const char *str, bool marked, const char *caret = nullptr, const char *insert_location = nullptr, const char *replacement_end = nullptr);
bool DeleteChar(uint16 keycode);
bool MovePos(uint16 keycode);
bool DeleteChar(uint16_t keycode);
bool MovePos(uint16_t keycode);
HandleKeyPressResult HandleKeyPress(WChar key, uint16 keycode);
HandleKeyPressResult HandleKeyPress(char32_t key, uint16_t keycode);
bool HandleCaret();
void UpdateSize();
@@ -74,7 +73,7 @@ private:
bool CanDelChar(bool backspace);
void DeleteText(uint16 from, uint16 to, bool update);
void DeleteText(uint16_t from, uint16_t to, bool update);
void UpdateStringIter();
void UpdateWidth();