ghostty-unicode: Ghostty computes codepoint properties with the uucode Zig package (v0.2.0, Unicode 17.0.0). There is no Rust equivalent, so a trimmed UCD set is vendored in ucd/ and build.rs re-implements uucode's derivations: cell width rules incl. Ghostty's overrides for emoji modifiers and Prepend, grapheme break classes with the compile-time grapheme_break state table, the is_symbol set, and emoji presentation. Lookups are three array indexes per codepoint. Validated against the official GraphemeBreakTest.txt. ghostty-datastruct: split_tree (used for GTK splits; f16 ratios so rounding and debug diagrams match Zig), circ_buf, lru, cache_table, blocking_queue, segmented_pool, message_data, comparison, array_list_collection. intrusive_linked_list is not needed (lru is index based). lru now reports the evicted (old) key, Zig reported the new key, which appears to be a bug. Not yet covered: case_folding_full (needed by input bindings). Test Plan: - cargo test -p ghostty-unicode (16) -p ghostty-datastruct (88) - cargo clippy for both crates with -D warnings
58 lines
1.6 KiB
Rust
58 lines
1.6 KiB
Rust
//! Generates the Unicode lookup tables (Ghostty's `props_uucode.zig` /
|
|
//! `symbols_uucode.zig` generator `main`s) from the vendored UCD files in
|
|
//! `ucd/`.
|
|
#![allow(dead_code)]
|
|
#![allow(
|
|
clippy::unwrap_used,
|
|
clippy::single_match_else,
|
|
clippy::checked_conversions,
|
|
clippy::trivially_copy_pass_by_ref,
|
|
clippy::expect_used
|
|
)]
|
|
|
|
#[path = "src/lut.rs"]
|
|
mod lut;
|
|
#[path = "src/props.rs"]
|
|
mod props;
|
|
#[path = "build_support/ucd.rs"]
|
|
mod ucd;
|
|
|
|
use std::env;
|
|
use std::fs;
|
|
use std::path::PathBuf;
|
|
|
|
fn main() {
|
|
let manifest = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
|
|
let out = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
|
let ucd_dir = manifest.join("ucd");
|
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:rerun-if-changed=build_support/ucd.rs");
|
|
println!("cargo:rerun-if-changed=src/lut.rs");
|
|
println!("cargo:rerun-if-changed=src/props.rs");
|
|
println!("cargo:rerun-if-changed=ucd");
|
|
|
|
let ucd = ucd::Ucd::load(&ucd_dir);
|
|
|
|
let props = lut::generate(|cp| ucd.get(cp)).expect("generate props tables");
|
|
fs::write(
|
|
out.join("props_tables.rs"),
|
|
props.write_rust("Properties", props::Properties::format_rust),
|
|
)
|
|
.unwrap();
|
|
|
|
let symbols = lut::generate(|cp| ucd.is_symbol(cp)).expect("generate symbols tables");
|
|
fs::write(
|
|
out.join("symbols_tables.rs"),
|
|
symbols.write_rust("bool", ToString::to_string),
|
|
)
|
|
.unwrap();
|
|
|
|
let emoji = lut::generate(|cp| ucd.is_emoji_presentation(cp)).expect("generate emoji tables");
|
|
fs::write(
|
|
out.join("emoji_tables.rs"),
|
|
emoji.write_rust("bool", ToString::to_string),
|
|
)
|
|
.unwrap();
|
|
}
|