diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-02-04 13:06:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-04 13:06:38 +0100 |
commit | 2e320dcf8796d77b6196ef93d4ea304bf5bcb3d4 (patch) | |
tree | c8ad853c2b28149f975b2728deac960097ae3288 /editor/plugins | |
parent | d235c1bb1964b80d776a64aa2a1b198a8e52bf72 (diff) | |
parent | 244db375087440888ca5b86fd0d114a54f41489a (diff) |
Merge pull request #57617 from bruvzg/char_cleanup
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/editor_preview_plugins.cpp | 14 | ||||
-rw-r--r-- | editor/plugins/tiles/tile_map_editor.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/tiles/tile_set_editor.cpp | 2 |
3 files changed, 7 insertions, 11 deletions
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index cef505181a..7e0019faac 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -462,10 +462,6 @@ EditorMaterialPreviewPlugin::~EditorMaterialPreviewPlugin() { /////////////////////////////////////////////////////////////////////////// -static bool _is_text_char(char32_t c) { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_'; -} - bool EditorScriptPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "Script"); } @@ -538,15 +534,15 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size if (in_comment) { color = comment_color; } else { - if (c != '_' && ((c >= '!' && c <= '/') || (c >= ':' && c <= '@') || (c >= '[' && c <= '`') || (c >= '{' && c <= '~') || c == '\t')) { + if (is_symbol(c)) { //make symbol a little visible color = symbol_color; in_control_flow_keyword = false; in_keyword = false; - } else if (!prev_is_text && _is_text_char(c)) { + } else if (!prev_is_text && is_ascii_identifier_char(c)) { int pos = i; - while (_is_text_char(code[pos])) { + while (is_ascii_identifier_char(code[pos])) { pos++; } String word = code.substr(i, pos - i); @@ -556,7 +552,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size in_keyword = true; } - } else if (!_is_text_char(c)) { + } else if (!is_ascii_identifier_char(c)) { in_keyword = false; } @@ -571,7 +567,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size img->set_pixel(col, y0 + line * 2, bg_color.blend(ul)); img->set_pixel(col, y0 + line * 2 + 1, color); - prev_is_text = _is_text_char(c); + prev_is_text = is_ascii_identifier_char(c); } col++; } else { diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 89027b174d..b878494559 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -3735,7 +3735,7 @@ void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_ String str = pi.name.trim_prefix(p_array_prefix); int to_char_index = 0; while (to_char_index < str.length()) { - if (str[to_char_index] < '0' || str[to_char_index] > '9') { + if (!is_digit(str[to_char_index])) { break; } to_char_index++; diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index be261927ee..ab355d4658 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -458,7 +458,7 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_ String str = pi.name.trim_prefix(p_array_prefix); int to_char_index = 0; while (to_char_index < str.length()) { - if (str[to_char_index] < '0' || str[to_char_index] > '9') { + if (!is_digit(str[to_char_index])) { break; } to_char_index++; |