Lukas Tenbrink
e1c42392c2
Improve string copy_from and copy_from_unchecked implementations, by making use of caller contracts and language spec (NULL termination and casts).
2024-12-07 01:41:25 +01:00
Lukas Tenbrink
b5c31ebb41
Add contains_char() for single-character 'contains' calls.
2024-12-06 20:23:35 +01:00
demolke
964e2b3a9e
Fix handling of leading `..` in simplify_path
...
Prior to this `..\..\texture.png` was incorrectly simplified to `texture.png`
2024-12-06 07:53:55 +01:00
Thaddeus Crews
45734bd451
Merge pull request #99817 from Ivorforce/strlen-char32_t
...
Use `strlen()` 3 times instead of custom length check implementations in ustring
2024-12-05 14:12:21 -06:00
Thaddeus Crews
06cce0e81a
Merge pull request #100016 from Ivorforce/camelcase-to-underscore-rolling-cache
...
Optimize `_camelcase_to_underscore` (and thus `String.capitalize`)
2024-12-05 14:11:59 -06:00
Lukas Tenbrink
8d82933c7c
Optimize _camelcase_to_underscore (and thus String.capitalize) by using a rolling cache of character attributes, instead of re-computing each iteration.
2024-12-04 18:39:38 +01:00
Lukas Tenbrink
0d2e13bcb8
Optimize is_valid_filename and validate_filename by caching invalid filename characters, instead of re-splitting each call.
2024-12-04 17:54:11 +01:00
Rémi Verschelde
d7515dddaa
Merge pull request #99815 from Ivorforce/string-name-not-equal-inline
...
Move StringName `!=` operator to the header file to make it inlineable.
2024-12-02 15:51:43 +01:00
Lukas Tenbrink
2b39314461
Abstract the implementation of 3 ustring string length checks with strlen, adding an implementation for char32_t.
2024-12-02 15:19:20 +01:00
Lukas Tenbrink
a47d29cf11
Move StringName != to the header file to make it inlineable.
2024-12-01 19:50:34 +01:00
Rémi Verschelde
56a7dba10b
Merge pull request #99799 from akien-mga/fix-typos
...
Fix various typos and code style issues
2024-11-29 22:02:53 +01:00
Rémi Verschelde
88e81ee730
Fix various typos and code style issues
2024-11-28 17:40:42 +01:00
Lukas Tenbrink
884cbb5333
Don't repeat calls to strlen in split, and make splitter_length const in get_slice.
2024-11-28 01:55:48 +01:00
Thaddeus Crews
e7b11d1c99
Merge pull request #99527 from RandomShaper/fix_threaded_trans
...
Make loading translations from threads safe
2024-11-22 14:54:26 -06:00
Pedro J. Estébanez
7a25173ff4
Make loading translations from threads safe
2024-11-22 09:44:07 +01:00
Dan Nicholson
6f4fadf65d
Expose standardize_locale add_default param publicly
...
Comparing locales can have surprising outcomes since it standardizes
locales with defaults. For example, zh and zh_CN result in an exact
match since the defaults change them both to zh_Hans_CN. Expose the
add_default parameter publicly with a default of false so the fully
standardized locale can be inspected.
2024-11-21 16:50:31 -07:00
A Thousand Ships
68f638cf02
Use `(r)find_char` instead of `(r)find` for single characters
2024-11-17 10:02:18 +01:00
Thaddeus Crews
ebf49317a2
Merge pull request #97923 from kisg/translation_server_siof_fix
...
Make TranslationServer singleton variable inline.
2024-11-12 12:13:01 -06:00
Thaddeus Crews
27b394c52a
Merge pull request #98743 from dbnicholson/improve-compare-locales
...
Improve locale comparison
2024-11-12 09:27:54 -06:00
Dan Nicholson
2dd409fd70
Improve locale comparison
...
Since 9456454109 , country specific locales are always preferred over
country-less locales even when the OS locale country doesn't match. For
example, running the Godot editor with locale es_ES will result in the
es_AR locale being chosen even though the es locale would be better.
The change happened because the score of the es_AR locale and the es
locale are the same when comparing to es_ES. Change this by parsing
locale strings into a Locale structure and decreasing the score when
script, country or variant are set in both but not matched. For the
es_ES case, this causes the es_AR score to be decreased since the
countries don't match. On the other hand, the es locale is not decreased
since it doesn't specify a country.
2024-11-12 06:06:50 -07:00
Thaddeus Crews
6c4c61f1b2
Merge pull request #98547 from timothyqiu/loaded-locales-set
...
Fix duplicated entries in `TranslationServer::get_loaded_locales()`
2024-11-11 14:18:40 -06:00
Marcus Paulsson
4db07a19d0
fixed empty hex bug
...
formatting
2024-11-11 12:42:12 +01:00
Thaddeus Crews
63838c936c
Merge pull request #98278 from a-johnston/fuzzy-search-rebase
...
Add fuzzy string matching to quick open search
2024-11-10 12:12:56 -06:00
Thaddeus Crews
363c0b5fec
Merge pull request #47502 from KoBeWi/add_0
...
Always add decimal when converting float to string
2024-10-31 20:14:39 -05:00
A Thousand Ships
38f9769bc6
[Core] Improve error messages with `vformat`
2024-10-30 15:55:51 +01:00
Thaddeus Crews
b8f626a0e1
Merge pull request #65962 from 4d49/format-object
...
Add `Object` support for `String.format`
2024-10-29 19:25:45 -05:00
Thaddeus Crews
b7a0971ad2
Merge pull request #97934 from adamscott/give-AThousandShips-a-break
...
[Codestyle] Set clang-format `RemoveSemicolon` rule to `true`
2024-10-29 19:25:36 -05:00
Mansur Isaev
98c89f17c4
Add `Object` support for `String.format`
2024-10-29 22:27:33 +01:00
Adam Johnston
3ac043c508
Add fuzzy string matching to quick open search
...
Co-authored-by: sam <samsface@gmail.com>
2024-10-28 11:24:36 -07:00
Haoyu Qiu
f451997666
Fix duplicated entries in `TranslationServer::get_loaded_locales()`
2024-10-26 15:10:43 +08:00
Thaddeus Crews
d3298fe738
Merge pull request #98395 from Repiteo/core/char-range-utils-update
...
Core: Update `char_range.inc` to Unicode 16
2024-10-25 13:04:07 -05:00
Adam Scott
0d350e7108
Set clang-format `RemoveSemicolon` rule to `true`
...
- Set clang-format `Standard` rule to `c++20`
2024-10-25 13:49:43 -04:00
Clay John
33db590947
Merge pull request #98357 from yeojunh/valid-base-check-num-int64-uint64
...
Core: Fix String::num_int64(), uint64 for valid base check
2024-10-24 19:41:43 -07:00
kobewi
5c0f2414cd
Always add decimal when printing float
2024-10-23 15:00:21 +02:00
Thaddeus Crews
b6547b0d06
Merge pull request #98236 from timothyqiu/locale-compare-cache-4.x
...
Cache results for `TranslationServer.compare_locales()`
2024-10-21 16:39:14 -05:00
Thaddeus Crews
ab72082fa2
Core: Update `char_range.inc` to Unicode 16
2024-10-21 14:54:19 -05:00
yeojunh
b3b24ded19
Add checks for valid base in String::num_int64, uint64().
...
- Ensure String::num_int64, uint64 returns an empty string for bases less than 2 or greater than 36.
- Added corresponding test cases to verify the behavior.
- Error messages are printed when invalid bases are encountered. These messages are suppressed in the test output.
2024-10-20 00:22:08 -07:00
Haoyu Qiu
f61fe2799c
Don't pseudolocalize empty strings
2024-10-17 10:30:17 +08:00
Haoyu Qiu
acab2d6c1c
Cache results for `TranslationServer.compare_locales()`
2024-10-16 20:54:56 +08:00
bruvzg
0d7027ea4c
Add support for 24-bit color escape sequences, simplify `print_rich` BBCode parsing.
2024-10-13 22:31:57 +03:00
Gergely Kis
257633c354
Make TranslationServer singleton variable inline.
...
This change avoids the problem known as 'Static Initialization Order Fiasco' (SIOF).
See the following PR for more explanation: https://github.com/godotengine/godot/pull/94683
Co-authored-by: Gabor Koncz <gabor.koncz@migeran.com>
2024-10-07 13:47:42 +02:00
Rémi Verschelde
05b519fafb
Merge pull request #96230 from timothyqiu/per-domain-pseudolocalization
...
Move pseudolocalization into `TranslationDomain`
2024-10-04 11:21:18 +02:00
Haoyu Qiu
6516ca6b11
Parse fragment from URL
2024-09-27 19:42:30 +08:00
Thaddeus Crews
9f9ee0c813
SCons: Add unobtrusive type hints in SCons files
2024-09-25 09:34:35 -05:00
Haoyu Qiu
a751c05b15
Fix script editor wrongly replaces and quotes non-ASCII letters
2024-09-23 00:05:16 +08:00
Haoyu Qiu
cca54ba4db
Move pseudolocalization into TranslationDomain
...
Also adds command-line option `--editor-pseudolocalization`
2024-09-21 18:28:12 +08:00
Haoyu Qiu
818acb4290
Make editor use translation domains
...
How editor plugins use this feature:
1. Pick a unique translation domain name.
2. `_enter_tree()`: load translations into that translation domain.
3. Call `set_translation_domain()` for its root UI node.
4. `_exit_tree()`: remove that translation domain.
Plugins can also set the translation domain to `godot.editor` for
nested nodes that should use editor translations. `EditorFileDialog`
automatically does this.
2024-09-17 13:09:44 +08:00
Haoyu Qiu
68d494e24e
Add translation domain
2024-09-17 13:09:44 +08:00
rune-scape
0dde931bc9
StringName: Fix empty hash
...
+Fixed compat hashes
2024-09-09 13:30:02 -07:00
Rémi Verschelde
69ca549ef9
Merge pull request #92570 from rune-scape/rune-stringname-bits
...
StringName: `operator==` compares in-place
2024-09-04 11:16:32 +02:00
rune-scape
6abd17265b
StringName: operator== compares in-place
2024-09-03 17:31:08 -07:00
Rémi Verschelde
88197d4a51
Merge pull request #96462 from RandomShaper/opt_comp_loc
...
TranslationServer: Add fast path for comparison of equal locales
2024-09-02 12:14:01 +02:00
Pedro J. Estébanez
cfb7443e26
TranslationServer: Add fast path for comparison of equal locales
2024-09-02 10:50:14 +02:00
A Thousand Ships
e33fdb4296
Use `MutexLock` in more places
2024-08-29 14:12:59 +02:00
Haoyu Qiu
8bf4ecc026
Add `String.is_valid_unicode_identifier()`
...
- Adds `is_valid_unicode_identifier()`
- Adds `is_valid_ascii_identifier()`
- Deprecates `is_valid_identifier()`
- Renames `validate_identifier()` to `validate_ascii_identifier()`
2024-08-27 11:34:08 +08:00
Rémi Verschelde
c7702b350a
Merge pull request #92548 from AThousandShips/string_cleaning
...
[Core] Optimize some `String` methods
2024-08-26 23:28:24 +02:00
Rémi Verschelde
8dad1ba482
Merge pull request #92933 from TokageItLab/match-concatenating
...
Match the coding style for concatenating String
2024-08-26 22:44:59 +02:00
Rémi Verschelde
af919a845f
Merge pull request #94683 from kisg/string_name_fix
...
StringName: Use inline static field definitions
2024-08-19 16:05:16 +02:00
Rémi Verschelde
4afcbb1c8b
Merge pull request #92546 from AThousandShips/faster_replace
...
[Core] Optimize `String::replace` methods
2024-08-19 12:08:45 +02:00
Rémi Verschelde
49e5fbfbd2
Merge pull request #95184 from jsjtxietian/shader-include-relative
...
Fix `String::simplify_path` handling of relative paths to parent dir (`../`), fixes relative shader includes
2024-08-17 00:46:11 +02:00
Rémi Verschelde
803dfcc3cb
Merge pull request #95613 from timothyqiu/split-empty
...
Fix `split_floats` behavior when spaces are used as separators
2024-08-16 14:36:40 +02:00
Rémi Verschelde
f01e052162
Merge pull request #95549 from timothyqiu/split-translation-server
...
Split `TranslationServer` into its own file
2024-08-16 14:36:16 +02:00
Haoyu Qiu
f483c3aafa
Fix split_floats behavior when spaces are used as separators
2024-08-16 17:30:44 +08:00
Rémi Verschelde
70096c0e6a
Merge pull request #94558 from stuartcarnie/sgc/sprintf_allocations
...
Reduce allocations in `String::sprintf`
2024-08-16 10:34:28 +02:00
Rémi Verschelde
71ca5aa5ec
Merge pull request #92555 from AThousandShips/insert_improve
...
[Core] Optimize `String::insert`
2024-08-16 10:33:47 +02:00
A Thousand Ships
ee19a092d9
[Core] Optimize some `String` methods
...
Avoids unnecessary COW checks by using pointers directly.
2024-08-15 17:17:11 +02:00
A Thousand Ships
e211d08c92
[Core] Optimize `String::join`
...
Avoid reallocation by pre-computing size
2024-08-15 16:19:07 +02:00
A Thousand Ships
746c6b87eb
[Core] Optimize `String::insert`
2024-08-15 16:18:47 +02:00
A Thousand Ships
cbaec62b03
[Core] Optimize `String::replace` methods
...
Performs a single allocation, only when any instances are found, and
avoids concatenations and other unnecessary conversions.
2024-08-15 16:15:58 +02:00
Haoyu Qiu
7343dc3a5d
Split TranslationServer into its own file
2024-08-15 15:00:47 +08:00
jsjtxietian
6cf9af2817
Fix error when use relative #include in .gdshader / .gdshaderinc file
2024-08-08 11:59:14 +08:00
Stuart Carnie
67eb6bed2b
use operator += (char32_t)
...
This prevents an allocation of a new string for every character.
Additionally, use some static constants for padding and sign characters
2024-07-25 09:17:58 +10:00
Gergely Kis
723878bbab
StringName: Use inline static field definitions
...
Before this change StringName used regular static field
definitions for its mutex, _table, configured and debug_stringname
fields.
Since in the general case the ordering of the static variable and field
initialization and destruction is undefined, it was possible that
the destruction of StringName's static fields happened prior to
the destruction of statically allocated StringName instances.
By changing the static field definitions to inline in string_name.h,
the C++17 standard guarantees the correct initialization and destruction
ordering.
2024-07-24 02:40:36 +02:00
Rémi Verschelde
f11e8d033d
Remove editor pseudolocalization debug feature
...
We've seen multiple users enable it by mistake and get utterly confused,
reporting as a bug that the interface text is garbled.
On the other hand we haven't really seen much use of the feature by editor
UI developers, so we can likely simply remove it.
If there's a need eventually, we can re-add it as a command line option
(which is also better than an editor setting as one would typically want
to toggle it during development).
2024-06-24 17:08:26 +02:00
bruvzg
dd883bebd4
Improve PR plural translation rules handling.
2024-06-18 19:04:00 +03:00
Silc Lizard (Tokage) Renew
12571a1e95
Match the coding style for concatenating String
2024-06-09 18:35:23 +09:00
Rémi Verschelde
a9a1d0a162
Merge pull request #91619 from AThousandShips/find_improve
...
Replace `find` with `contains/has` where applicable
2024-05-08 14:35:44 +02:00
A Thousand Ships
b4c6cc7d82
[Core] Add case-insensitive `String::containsn`
2024-05-08 12:48:01 +02:00
A Thousand Ships
a0dbdcc3ab
Replace `find` with `contains/has` where applicable
...
* Replaces `find(...) != -1` with `contains` for `String`
* Replaces `find(...) == -1` with `!contains` for `String`
* Replaces `find(...) != -1` with `has` for containers
* Replaces `find(...) == -1` with `!has` for containers
2024-05-08 12:37:42 +02:00
Wilson E. Alvarez
d4154dbc55
Add const char * overloads to String class
...
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
2024-05-07 10:53:00 -04:00
Rémi Verschelde
25fe3d4b46
Merge pull request #81639 from MJacred/is_letter
...
Add `is_valid_letter()` to `TextServer`
2024-05-03 01:21:34 +02:00
MJacred
717513a62d
Add is_valid_letter() to TextServer
2024-05-02 21:32:20 +02:00
Aaron Franke
b1f5e9fe3a
Rename internal is_ascii_char to is_ascii_alphabet_char
2024-04-20 02:36:41 -07:00
Haoyu Qiu
9bcda8f94c
Prefer family name in fonts' names table
2024-04-06 16:08:59 +08:00
Haoyu Qiu
479b7afa8e
Add context support for editor property name i18n
2024-03-31 18:40:14 +08:00
A Thousand Ships
bb6305d1c4
[Core] Fix incorrect file sort method
2024-03-24 17:54:57 +01:00
Rémi Verschelde
8f9136963d
Merge pull request #89671 from alesliehughes/string_underrun
...
Stop possible underrun when processing a string
2024-03-24 01:21:12 +01:00
A Thousand Ships
2cbf469912
Fix sorting of files/dirs in dialogs
...
Sorts leading `_` before other characters except `.`.
2024-03-20 13:45:47 +01:00
Alistair Leslie-Hughes
87fe71f52f
Stop possible underrun when processing a string
...
Calling String::utf8("Unicode String", -1) assumes that the string will be NULL terminated.
However, the length parameter is always used to find the end of the string. So there is the
chance the character before th start of the string is read.
Making the pointer NULL in the case where it's out of range, still allows the following
to work as expected
while (ptrtmp != ptrtmp_limit && *ptrtmp)
....
2024-03-19 20:17:11 +11:00
Thaddeus Crews
9903e6779b
Enforce template syntax `typename` over `class`
2024-03-07 22:39:09 -06:00
Mika Viskari
3026b566b0
Fix String::begins_with when both strings are empty
2024-03-05 20:46:10 +02:00
Rémi Verschelde
0a089e284b
Merge pull request #87191 from Mickeon/autocompletion-TranslationServer
...
Add autocompletion for TranslationServer
2024-03-01 14:56:18 +01:00
Micky
ffd498c57d
Add autocompletion for TranslationServer
2024-02-29 20:43:19 +01:00
Rémi Verschelde
846428e0c6
Merge pull request #86222 from YeldhamDev/give_me_those_strings_baby
...
Add option to add built-in strings in the POT generation
2024-02-29 13:53:38 +01:00
Rémi Verschelde
1cc9190c70
Merge pull request #81822 from nlupugla/nodepath-slice
...
Add `NodePath::slice` method
2024-02-29 13:53:34 +01:00
Michael Alexsander
d70c45b5c8
Add option to add built-in strings in the POT generation
2024-02-28 11:34:26 -03:00
Robert Yevdokimov
13e82094ee
Remove word duplicates in comments and strings, and fix casing and punctuation
2024-02-23 17:28:28 -05:00
Rémi Verschelde
3ce9ae71fc
Merge pull request #84906 from /fix-some-defvals
2024-02-23 11:29:22 +01:00
Raul Santos
5ba92e5a57
Fix some DEFVALs to use the right type
...
- Use `StringName()` in DEFVAL for StringNames.
- Use `Variant()` in DEFVAL for Variants.
2024-02-23 01:50:18 +01:00
Danil Alexeev
c0aa88ae4f
Add Unicode support to `String.to_*_case()` methods
2024-02-22 13:58:46 +03:00