summaryrefslogtreecommitdiff
path: root/servers/text
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2022-08-18 16:20:20 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2022-12-16 13:18:57 +0800
commit207e52c161a44869f1af022030c3129b8c38a5f7 (patch)
tree3df831f12e9ded2b734b37d61837d2a35afbf685 /servers/text
parentf18f2740da9cce7383c2aa41fe8d081d56c8b6cf (diff)
Fix String::word_wrap() for long words
- Changes `TextServer.string_get_word_breaks()` - Returns pairs of boundary start and end offsets - Accepts `chars_per_line` to return line breaks - Removes `String::word_wrap()` Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
Diffstat (limited to 'servers/text')
-rw-r--r--servers/text/text_server_extension.cpp6
-rw-r--r--servers/text/text_server_extension.h4
2 files changed, 5 insertions, 5 deletions
diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp
index c219029650..4baa1db9bf 100644
--- a/servers/text/text_server_extension.cpp
+++ b/servers/text/text_server_extension.cpp
@@ -308,7 +308,7 @@ void TextServerExtension::_bind_methods() {
GDVIRTUAL_BIND(_strip_diacritics, "string");
GDVIRTUAL_BIND(_is_valid_identifier, "string");
- GDVIRTUAL_BIND(_string_get_word_breaks, "string", "language");
+ GDVIRTUAL_BIND(_string_get_word_breaks, "string", "language", "chars_per_line");
GDVIRTUAL_BIND(_is_confusable, "string", "dict");
GDVIRTUAL_BIND(_spoof_check, "string");
@@ -1379,9 +1379,9 @@ TypedArray<Vector2i> TextServerExtension::parse_structured_text(StructuredTextPa
return ret;
}
-PackedInt32Array TextServerExtension::string_get_word_breaks(const String &p_string, const String &p_language) const {
+PackedInt32Array TextServerExtension::string_get_word_breaks(const String &p_string, const String &p_language, int p_chars_per_line) const {
PackedInt32Array ret;
- GDVIRTUAL_CALL(_string_get_word_breaks, p_string, p_language, ret);
+ GDVIRTUAL_CALL(_string_get_word_breaks, p_string, p_language, p_chars_per_line, ret);
return ret;
}
diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h
index 56ed2e41ec..551e4e9087 100644
--- a/servers/text/text_server_extension.h
+++ b/servers/text/text_server_extension.h
@@ -510,8 +510,8 @@ public:
virtual String strip_diacritics(const String &p_string) const override;
GDVIRTUAL1RC(String, _strip_diacritics, const String &);
- virtual PackedInt32Array string_get_word_breaks(const String &p_string, const String &p_language = "") const override;
- GDVIRTUAL2RC(PackedInt32Array, _string_get_word_breaks, const String &, const String &);
+ virtual PackedInt32Array string_get_word_breaks(const String &p_string, const String &p_language = "", int p_chars_per_line = 0) const override;
+ GDVIRTUAL3RC(PackedInt32Array, _string_get_word_breaks, const String &, const String &, int);
virtual bool is_valid_identifier(const String &p_string) const override;
GDVIRTUAL1RC(bool, _is_valid_identifier, const String &);