feat(unicode,datastruct): port Unicode tables and data structures
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
This commit is contained in:
1 parent
b96984b020
commit
5b8c92b98c
31 files changed
+18468
-3
No files matched your search
@@ -0,0 +1,47 @@
|
||||
//! A collection of Vecs with methods for bulk operations
|
||||
//! (`array_list_collection.zig`).
|
||||
|
||||
/// A collection of Vecs with methods for bulk operations.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ArrayListCollection<T> {
|
||||
/// The lists that belong to this collection.
|
||||
pub lists: Vec<Vec<T>>,
|
||||
}
|
||||
|
||||
impl<T> ArrayListCollection<T> {
|
||||
/// The collection will be initialized with empty lists.
|
||||
#[must_use]
|
||||
pub fn new(list_count: usize, initial_capacity: usize) -> Self {
|
||||
Self {
|
||||
lists: (0..list_count)
|
||||
.map(|_| Vec::with_capacity(initial_capacity))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Clear all lists in the collection, retaining capacity.
|
||||
pub fn reset(&mut self) {
|
||||
for list in &mut self.lists {
|
||||
list.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn init_and_reset() {
|
||||
let mut c: ArrayListCollection<u32> = ArrayListCollection::new(3, 8);
|
||||
assert_eq!(c.lists.len(), 3);
|
||||
for l in &c.lists {
|
||||
assert!(l.is_empty());
|
||||
assert!(l.capacity() >= 8);
|
||||
}
|
||||
c.lists[1].extend([1, 2, 3]);
|
||||
c.reset();
|
||||
assert!(c.lists.iter().all(Vec::is_empty));
|
||||
assert!(c.lists[1].capacity() >= 8);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user