mirror of
https://github.com/storytold/cadcraft.git
synced 2026-11-15 10:23:43 -06:00
Greek keyboard: a word folds only when the layout types it
`greek_fold` upper-cased the word with Unicode's rules before it read the keys. Upper-casing turns some characters the layout does not type into Greek or ASCII letters: the micro sign into Μ, the long s into S, the sharp s into SS, an alpha with an iota subscript into ΑΙ, the theta symbol into Θ. A stored name with such a character then counted as a spelling of a Greek word, although `latin_keys` does not read it. The fold is now the word's keys with the final sigma read as the letter sigma, so a word folds exactly when `latin_keys` reads it. Where the old fold and the new one both exist they are the same string. Test: five such pairs are not one word. It fails without the change.
This commit is contained in:
@@ -81,9 +81,10 @@ pub fn latin_keys(word: &str) -> Option<String> {
|
||||
}
|
||||
|
||||
/// `word` with its case, accents and final sigma folded away, when it is Greek-layout typing: every
|
||||
/// spelling of one Greek word gives the same string.
|
||||
/// spelling of one Greek word gives the same string. It is the word's keys, with the final sigma
|
||||
/// read as the letter sigma instead of the W key.
|
||||
pub fn greek_fold(word: &str) -> Option<String> {
|
||||
latin_keys(&word.to_uppercase())
|
||||
latin_keys(&word.replace('ς', "σ"))
|
||||
}
|
||||
|
||||
/// Whether `a` and `b` are one Greek word, whatever their case, accents or final sigma.
|
||||
@@ -116,6 +117,16 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// A character the layout does not type is never taken for the Greek letter Unicode upper-cases
|
||||
/// it to: the micro sign is not μ, the long s and the sharp s are not σ, an alpha with an iota
|
||||
/// subscript is not αι, the theta symbol is not θ.
|
||||
#[test]
|
||||
fn a_character_the_layout_does_not_type_is_no_spelling_of_a_greek_letter() {
|
||||
let pairs = [("\u{b5}", "μ"), ("Λ\u{17f}", "ΛΣ"), ("Λ\u{df}", "ΛΣΣ"), ("\u{1fb3}", "αι"), ("\u{3d1}", "θ")];
|
||||
let same: Vec<_> = pairs.iter().filter(|(a, b)| same_greek_word(a, b) || same_greek_word(b, a)).collect();
|
||||
assert!(same.is_empty(), "{same:?}");
|
||||
}
|
||||
|
||||
/// Greek-layout typing reads as its Latin keys: plain, accented and decomposed letters, the Q
|
||||
/// and W keys, ASCII prefixes.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user