1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-20 14:45:44 +00:00

Cleanup and move char functions to the char_utils.h header.

This commit is contained in:
bruvzg
2022-02-04 10:32:20 +02:00
parent 2a3c4f00c8
commit 244db37508
41 changed files with 250 additions and 327 deletions

View File

@@ -53,11 +53,6 @@ inline void pop_back(T &container) {
container.resize(container.size() - 1);
}
// TODO: Copied from TextEdit private, would be nice to extract it in a single place.
static bool is_text_char(char32_t c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
}
static bool find_next(const String &line, String pattern, int from, bool match_case, bool whole_words, int &out_begin, int &out_end) {
int end = from;
@@ -73,10 +68,10 @@ static bool find_next(const String &line, String pattern, int from, bool match_c
out_end = end;
if (whole_words) {
if (begin > 0 && is_text_char(line[begin - 1])) {
if (begin > 0 && (is_ascii_identifier_char(line[begin - 1]))) {
continue;
}
if (end < line.size() && is_text_char(line[end])) {
if (end < line.size() && (is_ascii_identifier_char(line[end]))) {
continue;
}
}