summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-01-17 10:54:45 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-01-17 14:23:36 +0200
commite02a097280094801659ad123e6b9ac097cc70102 (patch)
treee5291758e72cda0d31a88d88678c69fffbefd520 /servers
parent5d238468eaf579695ee16d5a4c0696c8a18c5a58 (diff)
[TextServer] Implement locale and context sensitive case conversion functions.
Diffstat (limited to 'servers')
-rw-r--r--servers/text/text_server_extension.cpp19
-rw-r--r--servers/text/text_server_extension.h5
-rw-r--r--servers/text_server.cpp4
-rw-r--r--servers/text_server.h7
4 files changed, 34 insertions, 1 deletions
diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp
index a2195d1ddf..d7e7960496 100644
--- a/servers/text/text_server_extension.cpp
+++ b/servers/text/text_server_extension.cpp
@@ -271,6 +271,9 @@ void TextServerExtension::_bind_methods() {
GDVIRTUAL_BIND(_format_number, "string", "language");
GDVIRTUAL_BIND(_parse_number, "string", "language");
GDVIRTUAL_BIND(_percent_sign, "language");
+
+ GDVIRTUAL_BIND(_string_to_upper, "string", "language");
+ GDVIRTUAL_BIND(_string_to_lower, "string", "language");
}
bool TextServerExtension::has_feature(Feature p_feature) const {
@@ -1365,6 +1368,22 @@ String TextServerExtension::percent_sign(const String &p_language) const {
return TextServer::percent_sign(p_language);
}
+String TextServerExtension::string_to_upper(const String &p_string, const String &p_language) const {
+ String ret;
+ if (GDVIRTUAL_CALL(_string_to_upper, p_string, p_language, ret)) {
+ return ret;
+ }
+ return p_string;
+}
+
+String TextServerExtension::string_to_lower(const String &p_string, const String &p_language) const {
+ String ret;
+ if (GDVIRTUAL_CALL(_string_to_lower, p_string, p_language, ret)) {
+ return ret;
+ }
+ return p_string;
+}
+
TextServerExtension::TextServerExtension() {
//NOP
}
diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h
index 77f2ced951..6e203f22ee 100644
--- a/servers/text/text_server_extension.h
+++ b/servers/text/text_server_extension.h
@@ -449,6 +449,11 @@ public:
GDVIRTUAL2RC(String, _parse_number, const String &, const String &);
GDVIRTUAL1RC(String, _percent_sign, const String &);
+ virtual String string_to_upper(const String &p_string, const String &p_language = "") const override;
+ virtual String string_to_lower(const String &p_string, const String &p_language = "") const override;
+ GDVIRTUAL2RC(String, _string_to_upper, const String &, const String &);
+ GDVIRTUAL2RC(String, _string_to_lower, const String &, const String &);
+
TextServerExtension();
~TextServerExtension();
};
diff --git a/servers/text_server.cpp b/servers/text_server.cpp
index 0cc4358785..17840584ee 100644
--- a/servers/text_server.cpp
+++ b/servers/text_server.cpp
@@ -422,6 +422,9 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("strip_diacritics", "string"), &TextServer::strip_diacritics);
+ ClassDB::bind_method(D_METHOD("string_to_upper", "string", "language"), &TextServer::string_to_upper, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("string_to_lower", "string", "language"), &TextServer::string_to_lower, DEFVAL(""));
+
/* Direction */
BIND_ENUM_CONSTANT(DIRECTION_AUTO);
BIND_ENUM_CONSTANT(DIRECTION_LTR);
@@ -480,6 +483,7 @@ void TextServer::_bind_methods() {
BIND_ENUM_CONSTANT(FEATURE_BREAK_ITERATORS);
BIND_ENUM_CONSTANT(FEATURE_FONT_SYSTEM);
BIND_ENUM_CONSTANT(FEATURE_FONT_VARIABLE);
+ BIND_ENUM_CONSTANT(FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION);
BIND_ENUM_CONSTANT(FEATURE_USE_SUPPORT_DATA);
/* FT Contour Point Types */
diff --git a/servers/text_server.h b/servers/text_server.h
index 07f0ae5045..599cc3afd0 100644
--- a/servers/text_server.h
+++ b/servers/text_server.h
@@ -109,7 +109,8 @@ public:
FEATURE_BREAK_ITERATORS = 1 << 4,
FEATURE_FONT_SYSTEM = 1 << 5,
FEATURE_FONT_VARIABLE = 1 << 6,
- FEATURE_USE_SUPPORT_DATA = 1 << 7
+ FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION = 1 << 7,
+ FEATURE_USE_SUPPORT_DATA = 1 << 8,
};
enum ContourPointTag {
@@ -457,6 +458,10 @@ public:
virtual String strip_diacritics(const String &p_string) const;
+ // Other string operations.
+ virtual String string_to_upper(const String &p_string, const String &p_language = "") const = 0;
+ virtual String string_to_lower(const String &p_string, const String &p_language = "") const = 0;
+
TextServer();
~TextServer();
};