Add Store support and unsigned app releases

This commit is contained in:
Tamas Csikel
2026-10-25 14:11:49 +01:00
parent 1694cc4858
commit bcc7bc64c0
38 changed files with 12394 additions and 5 deletions

39
sf-ui/src/text.rs Normal file
View File

@@ -0,0 +1,39 @@
//! String helpers Slint lacks (wired into the `SfText` global by `glue!`).
/// Without its last character.
pub fn drop_last(s: &str) -> String {
let mut s = s.to_string();
s.pop();
s
}
/// `n` bullets (a masked password).
pub fn dots(n: usize) -> String {
"•".repeat(n)
}
/// The characters of a key event's text that can be typed: no controls, no
/// Slint special keys (arrows etc. arrive as private-use code points).
pub fn typable(s: &str) -> String {
s.chars().filter(|c| !c.is_control() && !('\u{E000}'..='\u{F8FF}').contains(c)).collect()
}
/// At most `n` characters.
pub fn truncate(s: &str, n: usize) -> String {
s.chars().take(n).collect()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn edits() {
assert_eq!(drop_last("abő"), "ab");
assert_eq!(drop_last(""), "");
assert_eq!(dots(3), "•••");
assert_eq!(truncate("árvíz", 3), "árv");
assert_eq!(typable("a\u{F700}\n"), "a");
assert_eq!(typable("Ő"), "Ő");
}
}