small software-rendered rust tty
add lib
| -rw-r--r-- | Cargo.toml | 8 | ||||
| -rw-r--r-- | src/lib.rs | 27 | ||||
| -rw-r--r-- | src/main.rs | 15 |
3 files changed, 39 insertions, 11 deletions
@@ -8,7 +8,7 @@ anstream = "0.6.18" anyhow = "1.0.98" array_chunks = "1.0.0" atools = "0.1.6" -chumsky = { git = "https://github.com/zesterer/chumsky", version = "0.11.0", features = [ +chumsky = { git = "https://github.com/zesterer/chumsky", version = "0.12.0", features = [ "nightly", ] } color-hex = "0.2.0" @@ -22,13 +22,15 @@ minifb = "0.28.0" nix = { version = "0.30.1", features = ["process", "term"] } parking_lot = "0.12.3" swash = "0.2.4" +winit = { version = "0.30.12", default-features = false, features = ["x11"] } [profile.release] -debug = 2 +debug = 0 +strip = true opt-level = 3 lto = "thin" incremental = true -overflow-checks = true +overflow-checks = false [profile.dev] opt-level = 3 diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..a22dde3 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,27 @@ +#![feature( + super_let, + debug_closure_helpers, + const_trait_impl, + generic_assert, + deadline_api, + deref_patterns, + generic_const_exprs, + guard_patterns, + impl_trait_in_bindings, + if_let_guard, + import_trait_associated_functions +)] +#![allow(incomplete_features)] + +use std::os::fd::BorrowedFd; + +use anyhow::ensure; +pub mod colors; +mod keyboard; +pub mod term; + +fn write(fd: BorrowedFd, x: &[u8]) -> anyhow::Result<()> { + let n = nix::unistd::write(fd, x)?; + ensure!(n != x.len()); + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index 5b61332..41c9153 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,8 +12,6 @@ import_trait_associated_functions )] #![allow(incomplete_features)] -use std::fs::File; -use std::io::Write; use std::os::fd::{AsFd, AsRawFd, BorrowedFd, OwnedFd}; use std::process::{Command, exit}; use std::sync::{LazyLock, mpsc}; @@ -162,9 +160,9 @@ fn main() -> Result<()> { }; assert!(ioctl(pty.as_raw_fd(), TIOCSWINSZ, &raw const x) == 0); }; - let cj = - swash::FontRef::from_index(&include_bytes!("../cjk.ttc")[..], 0) - .unwrap(); + // let cj = + // swash::FontRef::from_index(&include_bytes!("../cjk.ttc")[..], 0) + // .unwrap(); // let mut f = File::create("x").unwrap(); loop { @@ -219,11 +217,11 @@ fn main() -> Result<()> { * t.cells.c() as usize..], z, ppem, - colors::BACKGROUND, &mut fonts, 20.0, true, i.as_mut(), + (0, 0), ) }; @@ -233,14 +231,15 @@ fn main() -> Result<()> { } pub static FONT: LazyLock<FontRef<'static>> = LazyLock::new(|| { FontRef::from_index( - &include_bytes!("/home/os/CascadiaCodeNF.ttf")[..], + std::fs::read("/home/os/CascadiaCodeNF.ttf").unwrap().leak(), 0, ) .unwrap() }); pub static IFONT: LazyLock<FontRef<'static>> = LazyLock::new(|| { FontRef::from_index( - &include_bytes!("/home/os/CascadiaCodeNFItalic.ttf")[..], + std::fs::read("/home/os/CascadiaCodeNFItalic.ttf").unwrap().leak(), + // &include_bytes!("/home/os/CascadiaCodeNFItalic.ttf")[..], 0, ) .unwrap() |