Addresses the partial ports listed in docs/rewrite/notes/review-completeness-codex.md (details in docs/rewrite/notes/gaps-X2.md): - Flatpak: the exit watcher no longer consumes the host command; a shared FlatpakSignalHandle lets closing a surface still SIGHUP the host process group. - Child environment is byte-preserving end to end (ghostty_os::EnvMap of OsStrings) and Snap paths are filtered like filterSnapPaths. - argv handling no longer panics on non-UTF-8 arguments. - URI percent-decoding keeps raw bytes; OSC 7 pwd is passed through without lossy conversion. - Keybinding comparison/hashing uses full Unicode case folding from a table generated from CaseFolding.txt (Unicode 17.0.0). - Link regexes set Oniguruma's whole-search retry limit through the new minimal ghostty-onig crate (one SAFETY-commented FFI call). - OSC 9 NUL-capacity check ordering matches Zig. - Wayland registry binds/clears globals advertised after startup. - Custom shaders may pass sampler2D to helper functions (naga adapter). - +list-themes preview renders OSC 8 links, styled underlines and follows color-scheme reports. Also includes the inspector's integration edits in shared files (renderer state hook, termio VT recording, core/apprt-gtk wiring), X1's config/input/cli additions for completion generation, and a fix for a race in the termio backpressure test (it wrote before `stty raw` applied, so the cooked line discipline dropped bytes past MAX_CANON). Test Plan: - cargo test --workspace - cargo clippy --workspace --all-targets -- -D warnings
64 lines
2.0 KiB
Rust
64 lines
2.0 KiB
Rust
//! Full Unicode case folding (`CaseFolding.txt` statuses `C` + `F`, Unicode
|
|
//! 17.0.0), equivalent to uucode's `case_folding_full` field.
|
|
//!
|
|
//! The table is generated by `build.rs` from `ucd/CaseFolding.txt`.
|
|
|
|
include!(concat!(env!("OUT_DIR"), "/case_folding_full.rs"));
|
|
|
|
/// The full case folding of `cp`, or `None` if it folds to itself.
|
|
///
|
|
/// The result has 1 to 3 codepoints (unused trailing entries are `0`); use
|
|
/// [`fold_full`] for a slice.
|
|
#[must_use]
|
|
pub fn lookup(cp: u32) -> Option<[u32; 3]> {
|
|
CASE_FOLDING_FULL
|
|
.binary_search_by_key(&cp, |e| e.0)
|
|
.ok()
|
|
.map(|i| CASE_FOLDING_FULL[i].1)
|
|
}
|
|
|
|
/// The full case folding of `cp` as a zero-padded 3-element array. Like
|
|
/// uucode's `.with(&buffer, cp)`, a codepoint without a folding folds to
|
|
/// itself.
|
|
#[must_use]
|
|
pub fn fold_full(cp: u32) -> [u32; 3] {
|
|
lookup(cp).unwrap_or([cp, 0, 0])
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn simple_and_identity() {
|
|
assert_eq!(fold_full('A' as u32), ['a' as u32, 0, 0]);
|
|
assert_eq!(fold_full('a' as u32), ['a' as u32, 0, 0]);
|
|
assert_eq!(fold_full('1' as u32), ['1' as u32, 0, 0]);
|
|
assert_eq!(fold_full(0x00B5), [0x03BC, 0, 0]);
|
|
assert_eq!(fold_full(0x017F), ['s' as u32, 0, 0]);
|
|
assert_eq!(fold_full(0x03C2), [0x03C3, 0, 0]);
|
|
assert_eq!(fold_full(0x1E9E), [0x73, 0x73, 0]);
|
|
}
|
|
|
|
#[test]
|
|
fn multi_codepoint() {
|
|
// U+00DF LATIN SMALL LETTER SHARP S -> "ss"
|
|
assert_eq!(fold_full(0x00DF), [0x73, 0x73, 0]);
|
|
// U+0390 -> 03B9 0308 0301
|
|
assert_eq!(fold_full(0x0390), [0x03B9, 0x0308, 0x0301]);
|
|
// U+FB03 LATIN SMALL LIGATURE FFI -> "ffi"
|
|
assert_eq!(fold_full(0xFB03), [0x66, 0x66, 0x69]);
|
|
}
|
|
|
|
#[test]
|
|
fn table_sorted_and_nonempty() {
|
|
assert!(CASE_FOLDING_FULL.len() > 1500);
|
|
assert!(CASE_FOLDING_FULL.windows(2).all(|w| w[0].0 < w[1].0));
|
|
}
|
|
|
|
#[test]
|
|
fn dotted_capital_i_uses_full_folding() {
|
|
assert_eq!(fold_full(0x0130), [0x69, 0x307, 0]); // F entry for dotted I
|
|
}
|
|
}
|