diff --git a/Cargo.lock b/Cargo.lock index 68b4a45..8519491 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,12 +8,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" -[[package]] -name = "autocfg" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" - [[package]] name = "bitflags" version = "1.3.2" @@ -64,37 +58,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "dlib" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" -dependencies = [ - "libloading", -] - -[[package]] -name = "downcast-rs" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" - -[[package]] -name = "errno" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" -dependencies = [ - "libc", - "windows-sys", -] - -[[package]] -name = "fastrand" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" - [[package]] name = "find-msvc-tools" version = "0.1.8" @@ -190,30 +153,6 @@ dependencies = [ "slab", ] -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "libc", - "r-efi", - "wasip2", -] - -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "itoa" version = "1.0.17" @@ -242,16 +181,6 @@ version = "0.2.180" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" -[[package]] -name = "libloading" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" -dependencies = [ - "cfg-if", - "windows-link", -] - [[package]] name = "libredox" version = "0.1.12" @@ -263,68 +192,34 @@ dependencies = [ "redox_syscall", ] -[[package]] -name = "linux-raw-sys" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" - [[package]] name = "memchr" version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "minifb" version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1a093126f2ed9012fc0b146934c97eb0273e54983680a8bf5309b6b4a365b32" +source = "git+https://github.com/emoon/rust_minifb#e0cfce20df2375e7472f2e4bbf15b7cbde738655" dependencies = [ "cc", "console_error_panic_hook", - "dlib", "futures", - "instant", "js-sys", - "lazy_static", "libc", "orbclient", "raw-window-handle", "serde", "serde_derive", - "tempfile", "wasm-bindgen", "wasm-bindgen-futures", - "wayland-client", - "wayland-cursor", - "wayland-protocols", "web-sys", + "web-time", "winapi", "x11-dl", ] -[[package]] -name = "nix" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset", -] - [[package]] name = "nix" version = "0.30.1" @@ -390,12 +285,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - [[package]] name = "raw-window-handle" version = "0.6.2" @@ -411,25 +300,12 @@ dependencies = [ "bitflags 2.10.0", ] -[[package]] -name = "rustix" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" -dependencies = [ - "bitflags 2.10.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - [[package]] name = "rustty" version = "0.1.0" dependencies = [ "minifb", - "nix 0.30.1", + "nix", "ttf-parser", "vte", "zeno", @@ -441,12 +317,6 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - [[package]] name = "sdl2" version = "0.38.0" @@ -525,12 +395,6 @@ version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" -[[package]] -name = "smallvec" -version = "1.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" - [[package]] name = "syn" version = "2.0.114" @@ -542,19 +406,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tempfile" -version = "3.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" -dependencies = [ - "fastrand", - "getrandom", - "once_cell", - "rustix", - "windows-sys", -] - [[package]] name = "ttf-parser" version = "0.25.1" @@ -583,15 +434,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "wasip2" -version = "1.0.2+wasi-0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" -dependencies = [ - "wit-bindgen", -] - [[package]] name = "wasm-bindgen" version = "0.2.108" @@ -653,79 +495,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "wayland-client" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715" -dependencies = [ - "bitflags 1.3.2", - "downcast-rs", - "libc", - "nix 0.24.3", - "scoped-tls", - "wayland-commons", - "wayland-scanner", - "wayland-sys", -] - -[[package]] -name = "wayland-commons" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" -dependencies = [ - "nix 0.24.3", - "once_cell", - "smallvec", - "wayland-sys", -] - -[[package]] -name = "wayland-cursor" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6865c6b66f13d6257bef1cd40cbfe8ef2f150fb8ebbdb1e8e873455931377661" -dependencies = [ - "nix 0.24.3", - "wayland-client", - "xcursor", -] - -[[package]] -name = "wayland-protocols" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6" -dependencies = [ - "bitflags 1.3.2", - "wayland-client", - "wayland-commons", - "wayland-scanner", -] - -[[package]] -name = "wayland-scanner" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53" -dependencies = [ - "proc-macro2", - "quote", - "xml-rs", -] - -[[package]] -name = "wayland-sys" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be12ce1a3c39ec7dba25594b97b42cb3195d54953ddb9d3d95a7c3902bc6e9d4" -dependencies = [ - "dlib", - "lazy_static", - "pkg-config", -] - [[package]] name = "web-sys" version = "0.3.85" @@ -736,6 +505,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.3.9" @@ -758,27 +537,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-link" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" - -[[package]] -name = "windows-sys" -version = "0.61.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" -dependencies = [ - "windows-link", -] - -[[package]] -name = "wit-bindgen" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" - [[package]] name = "x11-dl" version = "2.21.0" @@ -790,18 +548,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "xcursor" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec9e4a500ca8864c5b47b8b482a73d62e4237670e5b5f1d6b9e3cae50f28f2b" - -[[package]] -name = "xml-rs" -version = "0.8.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f" - [[package]] name = "zeno" version = "0.3.3" @@ -810,6 +556,6 @@ checksum = "6df3dc4292935e51816d896edcd52aa30bc297907c26167fec31e2b0c6a32524" [[package]] name = "zmij" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea" +checksum = "94f63c051f4fe3c1509da62131a678643c5b6fbdc9273b2b79d4378ebda003d2" diff --git a/Cargo.toml b/Cargo.toml index edcefc9..5bc1a10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ edition = "2024" license = " GPL-3.0-or-later" [dependencies] -minifb = "0.28.0" -nix = {default-features = false, features=["term","process","fs"], version="0.30.1"} +minifb = { version = "0.28.0", default-features = false, features = ["x11"], git = "https://github.com/emoon/rust_minifb" } +nix = { version = "0.30.1", default-features = false, features = ["term", "process", "fs"] } ttf-parser = "0.25.1" vte = "0.15.0" zeno = "0.3.3" diff --git a/package.nix b/package.nix index 84aac79..d862ef7 100644 --- a/package.nix +++ b/package.nix @@ -1,28 +1,22 @@ { - fontconfig, - freetype, lib, libGL, libxkbcommon, makeWrapper, naersk, pkg-config, - wayland, + xorg, ... }: naersk.buildPackage rec { name = "rustty"; src = ./.; buildInputs = [ - # fonts - fontconfig - freetype - freetype.dev - # wayland graphics libGL libxkbcommon - wayland + xorg.libXcursor + xorg.libX11 ]; nativeBuildInputs = [ pkg-config diff --git a/src/main.rs b/src/main.rs index 0c83398..927e5ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use nix::fcntl::{fcntl, OFlag, F_GETFL, F_SETFL}; use nix::pty::{forkpty, ForkptyResult, PtyMaster}; -use nix::unistd::{execv, read, write}; +use nix::unistd::{execve, read, write}; use minifb::{Key, KeyRepeat, Window, WindowOptions}; @@ -242,11 +242,19 @@ fn main() { }; let keys = window.get_keys_pressed(KeyRepeat::No); + if !keys.is_empty() { println!("{:?}", keys); } + let shift = window.is_key_down(Key::LeftShift); + let ctrl = window.is_key_down(Key::LeftCtrl); if !keys.is_empty() { let bytes: Vec = keys .iter() // TODO apply modifiers - .map(|key| key_to_u8(*key, false, false)) + .map(|key| key_to_u8( + *key, // key + shift, + ctrl + )) + .filter(|v| *v != 0u8) .collect(); write(&pty, bytes.as_slice()); }; @@ -263,13 +271,14 @@ fn spawn_pty() -> Option { return Some(unsafe { PtyMaster::from_owned_fd(master) }); } ForkptyResult::Child => { - let _ = execv::( + let _ = execve::( &CString::new("/usr/bin/env").unwrap(), &[ CString::new("/usr/bin/env").unwrap(), CString::new("-i").unwrap(), CString::new("sh").unwrap(), CString::new("--norc").unwrap(), CString::new("--noprofile").unwrap() ], + &[ CString::new("TERM=dumb").unwrap() ], ); return None; } @@ -280,7 +289,7 @@ fn spawn_pty() -> Option { // WARNING not functional; missing some keys and also modifiers fn key_to_u8(key: Key, shift: bool, ctrl: bool) -> u8 { - let base = match key { + let mut base = match key { Key::Key0 => b'0', Key::Key1 => b'1', Key::Key2 => b'2', @@ -391,8 +400,8 @@ fn key_to_u8(key: Key, shift: bool, ctrl: bool) -> u8 { Key::Count => 0, }; - let base_shift = if shift { - match base { + if shift { + base = match base { b'0' => b')', b'1' => b'!', b'2' => b'@', @@ -416,14 +425,14 @@ fn key_to_u8(key: Key, shift: bool, ctrl: bool) -> u8 { b';' => b':', b'/' => b'?', _ => base, - } - } else { - base - }; + }; + } - let base_shift_ctrl = if ctrl { base_shift & 0x1F } else { base_shift }; + if ctrl { + base = base & 0x1F; + } - return base_shift_ctrl; + return base; } // creats a mapping from a `char` to its svg spec for a selection of characters