mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-01 20:31:27 +00:00
String: Add .is-empty and .character-count properties
Introduce two new properties for string in .slint: - .is-empty: Checks if a string is empty. - .character-count: Retrieves the number of grapheme clusters https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries These additions enhance functionality and improve convenience when working with string properties.
This commit is contained in:
parent
12fe2bb36d
commit
68b9dfc247
13 changed files with 200 additions and 8 deletions
|
|
@ -60,6 +60,7 @@ raw-window-handle = { version = "0.6", optional = true }
|
|||
|
||||
esp-backtrace = { version = "0.14.0", features = ["panic-handler", "println"], optional = true }
|
||||
esp-println = { version = "0.12.0", default-features = false, features = ["uart"], optional = true }
|
||||
unicode-segmentation = "1.12.0"
|
||||
|
||||
[build-dependencies]
|
||||
anyhow = "1.0"
|
||||
|
|
|
|||
|
|
@ -152,6 +152,11 @@ pub extern "C" fn slint_string_to_float(string: &SharedString, value: &mut f32)
|
|||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn slint_string_character_count(string: &SharedString) -> usize {
|
||||
unicode_segmentation::UnicodeSegmentation::graphemes(string.as_str(), true).count()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn slint_string_to_usize(string: &SharedString, value: &mut usize) -> bool {
|
||||
match string.as_str().parse::<usize>() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue