From 5bc45055f362c29478444d7c0437a2e5bd2c2853 Mon Sep 17 00:00:00 2001 From: Speak2Erase Date: Sat, 20 Jan 2024 13:10:12 -0800 Subject: [PATCH] Hacky terminal drawing with wrong colors --- Cargo.lock | 751 ++++--------------------------- crates/term/Cargo.toml | 4 +- crates/term/src/_impl/into.rs | 132 ++---- crates/term/src/_impl/mod.rs | 515 +++++---------------- crates/ui/src/windows/console.rs | 20 +- src/app/mod.rs | 38 +- src/app/top_bar.rs | 53 ++- src/main.rs | 124 ++--- 8 files changed, 368 insertions(+), 1269 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 284f3415..b095ea1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -120,17 +120,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.6" @@ -153,6 +142,30 @@ dependencies = [ "memchr", ] +[[package]] +name = "alacritty_terminal" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35229555d7cc7e83392dfc27c96bec560b1076d756184893296cd60125f4a264" +dependencies = [ + "base64 0.21.5", + "bitflags 2.4.1", + "home", + "libc", + "log", + "miow", + "parking_lot", + "piper", + "polling 3.3.1", + "regex-automata 0.4.3", + "rustix-openpty", + "serde", + "signal-hook", + "unicode-width", + "vte", + "windows-sys 0.48.0", +] + [[package]] name = "allocator-api2" version = "0.2.16" @@ -540,12 +553,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "atomic" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" - [[package]] name = "atomic-waker" version = "1.1.2" @@ -616,7 +623,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide 0.7.1", + "miniz_oxide", "object", "rustc-demangle", ] @@ -704,15 +711,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -1221,14 +1219,10 @@ dependencies = [ ] [[package]] -name = "csscolorparser" -version = "0.6.2" +name = "cursor-icon" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb2a7d3066da2de787b7f032c736763eb7ae5d355f81a68bab2675a96008b0bf" -dependencies = [ - "lab", - "phf 0.11.2", -] +checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" [[package]] name = "d3d12" @@ -1248,7 +1242,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.3", + "hashbrown", "lock_api", "once_cell", "parking_lot_core", @@ -1284,12 +1278,6 @@ dependencies = [ "syn 2.0.39", ] -[[package]] -name = "deltae" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4" - [[package]] name = "deranged" version = "0.3.10" @@ -1310,22 +1298,13 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "crypto-common", ] @@ -1339,26 +1318,6 @@ dependencies = [ "dirs-sys-next", ] -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1436,7 +1395,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c55bcb864b764eb889515a38b8924757657a250738ad15126637ee2df291ee6b" dependencies = [ "accesskit", - "ahash 0.8.6", + "ahash", "epaint", "log", "nohash-hasher", @@ -1501,7 +1460,7 @@ checksum = "97624eaf17a16058265d3a3e712e167798655baf7c8f693de25be75cdd6c57b5" dependencies = [ "egui", "enum-map", - "image 0.24.7", + "image", "log", "mime_guess2", "resvg", @@ -1624,7 +1583,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d1b9e000d21bab9b535ce78f9f7745be28b3f777f6c7223936561c5c7fefab8" dependencies = [ "ab_glyph", - "ahash 0.8.6", + "ahash", "bytemuck", "ecolor", "emath", @@ -1708,7 +1667,7 @@ dependencies = [ "flume", "half", "lebe", - "miniz_oxide 0.7.1", + "miniz_oxide", "rayon-core", "smallvec", "zune-inflate", @@ -1770,22 +1729,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "filedescriptor" -version = "0.8.3" -source = "git+https://github.com/wez/wezterm?rev=3666303c7b26c6c966b3f136dbb954686d334cc3#3666303c7b26c6c966b3f136dbb954686d334cc3" -dependencies = [ - "libc", - "thiserror", - "winapi", -] - -[[package]] -name = "finl_unicode" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" - [[package]] name = "fixedbitset" version = "0.4.2" @@ -1799,7 +1742,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -2330,7 +2273,7 @@ checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c" dependencies = [ "bitflags 2.4.1", "gpu-descriptor-types", - "hashbrown 0.14.3", + "hashbrown", ] [[package]] @@ -2388,22 +2331,13 @@ dependencies = [ "crunchy", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.7", -] - [[package]] name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.6", + "ahash", "allocator-api2", ] @@ -2495,15 +2429,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humansize" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7" -dependencies = [ - "libm", -] - [[package]] name = "hyper" version = "0.14.27" @@ -2551,24 +2476,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "image" -version = "0.24.5" -source = "git+https://github.com/image-rs/image.git?rev=fe069785ae245a2c510fd724ef96da283b05a236#fe069785ae245a2c510fd724ef96da283b05a236" -dependencies = [ - "bytemuck", - "byteorder", - "color_quant", - "exr", - "gif", - "jpeg-decoder", - "num-rational", - "num-traits", - "png", - "qoi", - "tiff 0.8.1", -] - [[package]] name = "image" version = "0.24.7" @@ -2585,7 +2492,7 @@ dependencies = [ "num-traits", "png", "qoi", - "tiff 0.9.0", + "tiff", ] [[package]] @@ -2624,7 +2531,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown", "serde", ] @@ -2657,15 +2564,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "ioctl-rs" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7970510895cee30b3e9128319f2cefd4bde883a39f38baa279567ba3a7eb97d" -dependencies = [ - "libc", -] - [[package]] name = "ipnet" version = "2.9.0" @@ -2805,12 +2703,6 @@ dependencies = [ "log", ] -[[package]] -name = "lab" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf36173d4167ed999940f804952e6b08197cae5ad5d572eb4db150ce8ad5d58f" - [[package]] name = "lazy_static" version = "1.4.0" @@ -2875,12 +2767,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - [[package]] name = "libredox" version = "0.0.1" @@ -2969,15 +2855,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "lru" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" -dependencies = [ - "hashbrown 0.12.3", -] - [[package]] name = "luminol" version = "0.4.0" @@ -2990,7 +2867,7 @@ dependencies = [ "flume", "futures-lite 2.1.0", "git-version", - "image 0.24.7", + "image", "js-sys", "luminol-audio", "luminol-config", @@ -3133,7 +3010,7 @@ dependencies = [ "glow 0.12.3", "glutin", "glutin-winit", - "image 0.24.7", + "image", "js-sys", "log", "luminol-egui-wgpu", @@ -3226,7 +3103,7 @@ dependencies = [ "egui", "fragile", "glam", - "image 0.24.7", + "image", "itertools", "luminol-data", "luminol-egui-wgpu", @@ -3255,13 +3132,11 @@ dependencies = [ name = "luminol-term" version = "0.4.0" dependencies = [ + "alacritty_terminal", "color-eyre", "crossbeam-channel", "egui", "luminol-core", - "portable-pty", - "termwiz", - "wezterm-term", ] [[package]] @@ -3303,16 +3178,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "mac_address" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4863ee94f19ed315bf3bc00299338d857d4b5bc856af375cc97d237382ad3856" -dependencies = [ - "nix 0.23.2", - "winapi", -] - [[package]] name = "mach2" version = "0.4.1" @@ -3402,12 +3267,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memmem" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15" - [[package]] name = "memoffset" version = "0.6.5" @@ -3495,16 +3354,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -3527,6 +3376,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "miow" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "359f76430b20a79f9e20e115b3428614e654f04fab314482fc0fda0ebd3c6044" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "naga" version = "0.14.1" @@ -3630,19 +3488,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" -[[package]] -name = "nix" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" -dependencies = [ - "bitflags 1.3.2", - "cc", - "cfg-if", - "libc", - "memoffset 0.6.5", -] - [[package]] name = "nix" version = "0.24.3" @@ -3666,7 +3511,6 @@ dependencies = [ "cfg-if", "libc", "memoffset 0.6.5", - "pin-utils", ] [[package]] @@ -3942,12 +3786,6 @@ dependencies = [ "loom", ] -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "openssl" version = "0.10.60" @@ -4001,15 +3839,6 @@ dependencies = [ "libredox 0.0.2", ] -[[package]] -name = "ordered-float" -version = "3.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" -dependencies = [ - "num-traits", -] - [[package]] name = "ordered-multimap" version = "0.7.1" @@ -4017,7 +3846,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4d6a8c22fc714f0c2373e6091bf6f5e9b37b1bc0b1184874b7e0a4e303d318f" dependencies = [ "dlv-list", - "hashbrown 0.14.3", + "hashbrown", ] [[package]] @@ -4113,51 +3942,6 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" -[[package]] -name = "pest" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" -dependencies = [ - "memchr", - "thiserror", - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "pest_meta" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" -dependencies = [ - "once_cell", - "pest", - "sha2 0.10.8", -] - [[package]] name = "petgraph" version = "0.6.4" @@ -4168,76 +3952,6 @@ dependencies = [ "indexmap", ] -[[package]] -name = "phf" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" -dependencies = [ - "phf_shared 0.10.0", -] - -[[package]] -name = "phf" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" -dependencies = [ - "phf_macros", - "phf_shared 0.11.2", -] - -[[package]] -name = "phf_codegen" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" -dependencies = [ - "phf_generator", - "phf_shared 0.11.2", -] - -[[package]] -name = "phf_generator" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" -dependencies = [ - "phf_shared 0.11.2", - "rand", -] - -[[package]] -name = "phf_macros" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" -dependencies = [ - "phf_generator", - "phf_shared 0.11.2", - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "phf_shared" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" -dependencies = [ - "siphasher", -] - -[[package]] -name = "phf_shared" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" -dependencies = [ - "siphasher", -] - [[package]] name = "pico-args" version = "0.5.0" @@ -4317,7 +4031,7 @@ dependencies = [ "crc32fast", "fdeflate", "flate2", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -4375,26 +4089,6 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b" -[[package]] -name = "portable-pty" -version = "0.8.1" -source = "git+https://github.com/wez/wezterm?rev=3666303c7b26c6c966b3f136dbb954686d334cc3#3666303c7b26c6c966b3f136dbb954686d334cc3" -dependencies = [ - "anyhow", - "bitflags 1.3.2", - "downcast-rs", - "filedescriptor", - "lazy_static", - "libc", - "log", - "nix 0.25.1", - "serial", - "shared_library", - "shell-words", - "winapi", - "winreg 0.10.1", -] - [[package]] name = "powerfmt" version = "0.2.0" @@ -4828,7 +4522,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.20", + "semver", ] [[package]] @@ -4853,11 +4547,23 @@ checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" dependencies = [ "bitflags 2.4.1", "errno", + "itoa", "libc", "linux-raw-sys 0.4.12", "windows-sys 0.52.0", ] +[[package]] +name = "rustix-openpty" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a25c3aad9fc1424eb82c88087789a7d938e1829724f3e4043163baf0d13cfc12" +dependencies = [ + "errno", + "libc", + "rustix 0.38.26", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -4948,30 +4654,12 @@ dependencies = [ "libc", ] -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", -] - [[package]] name = "semver" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - [[package]] name = "serde" version = "1.0.193" @@ -5035,48 +4723,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serial" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1237a96570fc377c13baa1b88c7589ab66edced652e43ffb17088f003db3e86" -dependencies = [ - "serial-core", - "serial-unix", - "serial-windows", -] - -[[package]] -name = "serial-core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f46209b345401737ae2125fe5b19a77acce90cd53e1658cda928e4fe9a64581" -dependencies = [ - "libc", -] - -[[package]] -name = "serial-unix" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f03fbca4c9d866e24a459cbca71283f545a37f8e3e002ad8c70593871453cab7" -dependencies = [ - "ioctl-rs", - "libc", - "serial-core", - "termios 0.2.2", -] - -[[package]] -name = "serial-windows" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c6d3b776267a75d31bbdfd5d36c0ca051251caafc285827052bc53bcdc8162" -dependencies = [ - "libc", - "serial-core", -] - [[package]] name = "sha1" version = "0.10.6" @@ -5085,31 +4731,7 @@ checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] @@ -5121,22 +4743,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shared_library" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" -dependencies = [ - "lazy_static", - "libc", -] - -[[package]] -name = "shell-words" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" - [[package]] name = "shlex" version = "1.2.0" @@ -5145,9 +4751,9 @@ checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" [[package]] name = "signal-hook" -version = "0.1.17" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" dependencies = [ "libc", "signal-hook-registry", @@ -5315,12 +4921,6 @@ dependencies = [ "float-cmp", ] -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "strum" version = "0.25.0" @@ -5507,80 +5107,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "terminfo" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "666cd3a6681775d22b200409aad3b089c5b99fb11ecdd8a204d9d62f8148498f" -dependencies = [ - "dirs", - "fnv", - "nom", - "phf 0.11.2", - "phf_codegen", -] - -[[package]] -name = "termios" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d9cf598a6d7ce700a4e6a9199da127e6819a61e64b68609683cc9a01b5683a" -dependencies = [ - "libc", -] - -[[package]] -name = "termios" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b" -dependencies = [ - "libc", -] - -[[package]] -name = "termwiz" -version = "0.22.0" -source = "git+https://github.com/wez/wezterm?rev=3666303c7b26c6c966b3f136dbb954686d334cc3#3666303c7b26c6c966b3f136dbb954686d334cc3" -dependencies = [ - "anyhow", - "base64 0.21.5", - "bitflags 1.3.2", - "filedescriptor", - "finl_unicode", - "fixedbitset", - "hex", - "image 0.24.5", - "lazy_static", - "libc", - "log", - "memmem", - "nix 0.24.3", - "num-derive", - "num-traits", - "ordered-float", - "pest", - "pest_derive", - "phf 0.10.1", - "regex", - "semver 0.11.0", - "sha2 0.9.9", - "signal-hook", - "siphasher", - "tempfile", - "terminfo", - "termios 0.3.3", - "thiserror", - "ucd-trie", - "unicode-segmentation", - "vtparse", - "wezterm-bidi", - "wezterm-blob-leases", - "wezterm-color-types", - "wezterm-dynamic", - "winapi", -] - [[package]] name = "thiserror" version = "1.0.50" @@ -5621,17 +5147,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "tiff" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7449334f9ff2baf290d55d73983a7d6fa15e01198faef72af07e2a8db851e471" -dependencies = [ - "flate2", - "jpeg-decoder", - "weezl", -] - [[package]] name = "tiff" version = "0.9.0" @@ -5965,12 +5480,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "ucd-trie" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" - [[package]] name = "uds_windows" version = "1.0.2" @@ -6011,12 +5520,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - [[package]] name = "unicode-width" version = "0.1.11" @@ -6081,7 +5584,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" dependencies = [ - "atomic", "getrandom", "wasm-bindgen", ] @@ -6129,11 +5631,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] -name = "vtparse" -version = "0.6.2" -source = "git+https://github.com/wez/wezterm?rev=3666303c7b26c6c966b3f136dbb954686d334cc3#3666303c7b26c6c966b3f136dbb954686d334cc3" +name = "vte" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40eb22ae96f050e0c0d6f7ce43feeae26c348fc4dea56928ca81537cfaa6188b" dependencies = [ + "bitflags 2.4.1", + "cursor-icon", + "log", + "serde", "utf8parse", + "vte_generate_state_changes", +] + +[[package]] +name = "vte_generate_state_changes" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff" +dependencies = [ + "proc-macro2", + "quote", ] [[package]] @@ -6361,88 +5879,6 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" -[[package]] -name = "wezterm-bidi" -version = "0.2.2" -source = "git+https://github.com/wez/wezterm?rev=3666303c7b26c6c966b3f136dbb954686d334cc3#3666303c7b26c6c966b3f136dbb954686d334cc3" -dependencies = [ - "log", - "wezterm-dynamic", -] - -[[package]] -name = "wezterm-blob-leases" -version = "0.1.0" -source = "git+https://github.com/wez/wezterm?rev=3666303c7b26c6c966b3f136dbb954686d334cc3#3666303c7b26c6c966b3f136dbb954686d334cc3" -dependencies = [ - "getrandom", - "mac_address", - "once_cell", - "sha2 0.9.9", - "thiserror", - "uuid", -] - -[[package]] -name = "wezterm-color-types" -version = "0.2.0" -source = "git+https://github.com/wez/wezterm?rev=3666303c7b26c6c966b3f136dbb954686d334cc3#3666303c7b26c6c966b3f136dbb954686d334cc3" -dependencies = [ - "csscolorparser", - "deltae", - "lazy_static", - "wezterm-dynamic", -] - -[[package]] -name = "wezterm-dynamic" -version = "0.1.0" -source = "git+https://github.com/wez/wezterm?rev=3666303c7b26c6c966b3f136dbb954686d334cc3#3666303c7b26c6c966b3f136dbb954686d334cc3" -dependencies = [ - "log", - "ordered-float", - "strsim", - "thiserror", - "wezterm-dynamic-derive", -] - -[[package]] -name = "wezterm-dynamic-derive" -version = "0.1.0" -source = "git+https://github.com/wez/wezterm?rev=3666303c7b26c6c966b3f136dbb954686d334cc3#3666303c7b26c6c966b3f136dbb954686d334cc3" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "wezterm-term" -version = "0.1.0" -source = "git+https://github.com/wez/wezterm?rev=3666303c7b26c6c966b3f136dbb954686d334cc3#3666303c7b26c6c966b3f136dbb954686d334cc3" -dependencies = [ - "anyhow", - "bitflags 1.3.2", - "csscolorparser", - "finl_unicode", - "hex", - "humansize", - "image 0.24.5", - "lazy_static", - "log", - "lru", - "miniz_oxide 0.4.4", - "num-traits", - "ordered-float", - "serde", - "terminfo", - "termwiz", - "unicode-normalization", - "url", - "wezterm-bidi", - "wezterm-dynamic", -] - [[package]] name = "wgpu" version = "0.18.0" @@ -6894,15 +6330,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" -dependencies = [ - "winapi", -] - [[package]] name = "winreg" version = "0.50.0" diff --git a/crates/term/Cargo.toml b/crates/term/Cargo.toml index 27e7316f..a1a35270 100644 --- a/crates/term/Cargo.toml +++ b/crates/term/Cargo.toml @@ -25,6 +25,4 @@ color-eyre.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies] crossbeam-channel = "0.5" -wezterm-term = { version = "0.1.0", git = "https://github.com/wez/wezterm", rev = "3666303c7b26c6c966b3f136dbb954686d334cc3" } -portable-pty = { version = "0.8.1", git = "https://github.com/wez/wezterm", rev = "3666303c7b26c6c966b3f136dbb954686d334cc3" } -termwiz = { version = "0.22.0", git = "https://github.com/wez/wezterm", rev = "3666303c7b26c6c966b3f136dbb954686d334cc3" } +alacritty_terminal = "0.21.0" diff --git a/crates/term/src/_impl/into.rs b/crates/term/src/_impl/into.rs index dd0125e7..f4e3503c 100644 --- a/crates/term/src/_impl/into.rs +++ b/crates/term/src/_impl/into.rs @@ -22,99 +22,45 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -pub trait IntoEgui { - fn into_egui(self) -> T; -} - -impl IntoEgui for wezterm_term::color::SrgbaTuple { - fn into_egui(self) -> egui::Color32 { - let (r, g, b, a) = self.to_srgb_u8(); - egui::Color32::from_rgba_unmultiplied(r, g, b, a) - } -} - -pub trait IntoWez { - fn into_wez(self) -> T; -} - -pub trait TryIntoWez -where - Self: Sized, -{ - fn try_into_wez(self) -> Result; -} - -impl TryIntoWez for egui::Key { - fn try_into_wez(self) -> Result { - Ok(match self { - egui::Key::ArrowDown => wezterm_term::KeyCode::DownArrow, - egui::Key::ArrowLeft => wezterm_term::KeyCode::LeftArrow, - egui::Key::ArrowRight => wezterm_term::KeyCode::RightArrow, - egui::Key::ArrowUp => wezterm_term::KeyCode::UpArrow, - egui::Key::Escape => wezterm_term::KeyCode::Escape, - egui::Key::Tab => wezterm_term::KeyCode::Tab, - egui::Key::Backspace => wezterm_term::KeyCode::Backspace, - egui::Key::Enter => wezterm_term::KeyCode::Enter, - egui::Key::Insert => wezterm_term::KeyCode::Insert, - egui::Key::Delete => wezterm_term::KeyCode::Delete, - egui::Key::Home => wezterm_term::KeyCode::Home, - egui::Key::End => wezterm_term::KeyCode::End, - egui::Key::PageUp => wezterm_term::KeyCode::PageUp, - egui::Key::PageDown => wezterm_term::KeyCode::PageDown, - egui::Key::Num0 => wezterm_term::KeyCode::Numpad0, - egui::Key::Num1 => wezterm_term::KeyCode::Numpad1, - egui::Key::Num2 => wezterm_term::KeyCode::Numpad2, - egui::Key::Num3 => wezterm_term::KeyCode::Numpad3, - egui::Key::Num4 => wezterm_term::KeyCode::Numpad4, - egui::Key::Num5 => wezterm_term::KeyCode::Numpad5, - egui::Key::Num6 => wezterm_term::KeyCode::Numpad6, - egui::Key::Num7 => wezterm_term::KeyCode::Numpad7, - egui::Key::Num8 => wezterm_term::KeyCode::Numpad8, - egui::Key::Num9 => wezterm_term::KeyCode::Numpad9, - egui::Key::F1 => wezterm_term::KeyCode::Function(1), - egui::Key::F2 => wezterm_term::KeyCode::Function(2), - egui::Key::F3 => wezterm_term::KeyCode::Function(3), - egui::Key::F4 => wezterm_term::KeyCode::Function(4), - egui::Key::F5 => wezterm_term::KeyCode::Function(5), - egui::Key::F6 => wezterm_term::KeyCode::Function(6), - egui::Key::F7 => wezterm_term::KeyCode::Function(7), - egui::Key::F8 => wezterm_term::KeyCode::Function(8), - egui::Key::F9 => wezterm_term::KeyCode::Function(9), - egui::Key::F10 => wezterm_term::KeyCode::Function(10), - egui::Key::F11 => wezterm_term::KeyCode::Function(11), - egui::Key::F12 => wezterm_term::KeyCode::Function(12), - egui::Key::F13 => wezterm_term::KeyCode::Function(13), - egui::Key::F14 => wezterm_term::KeyCode::Function(14), - egui::Key::F15 => wezterm_term::KeyCode::Function(15), - egui::Key::F16 => wezterm_term::KeyCode::Function(16), - egui::Key::F17 => wezterm_term::KeyCode::Function(17), - egui::Key::F18 => wezterm_term::KeyCode::Function(18), - egui::Key::F19 => wezterm_term::KeyCode::Function(19), - egui::Key::F20 => wezterm_term::KeyCode::Function(20), - _ => return Err(self), - }) - } -} - -impl IntoWez for egui::Modifiers { - fn into_wez(self) -> wezterm_term::KeyModifiers { - let mut keymod = wezterm_term::KeyModifiers::NONE; - keymod.set(wezterm_term::KeyModifiers::ALT, self.alt); - keymod.set(wezterm_term::KeyModifiers::CTRL, self.ctrl); - keymod.set(wezterm_term::KeyModifiers::SHIFT, self.shift); - // keymod.set(wezterm_term::KeyModifiers::SUPER, self.command); - - keymod - } -} +use alacritty_terminal::{ + term::color::Colors, + vte::ansi::{Color, NamedColor}, +}; -impl IntoWez for egui::PointerButton { - fn into_wez(self) -> wezterm_term::MouseButton { - match self { - egui::PointerButton::Primary => wezterm_term::MouseButton::Left, - egui::PointerButton::Secondary => wezterm_term::MouseButton::Right, - egui::PointerButton::Middle => wezterm_term::MouseButton::Middle, - _ => wezterm_term::MouseButton::None, - } +pub fn color_to_egui(color: Color) -> egui::Color32 { + match color { + Color::Named(named) => match named { + NamedColor::Black => egui::Color32::from_rgb(26, 26, 26), + NamedColor::Red => egui::Color32::from_rgb(128, 0, 0), + NamedColor::Green => egui::Color32::from_rgb(0, 128, 0), + NamedColor::Yellow => egui::Color32::from_rgb(128, 128, 0), + NamedColor::Blue => egui::Color32::from_rgb(0, 0, 128), + NamedColor::Magenta => egui::Color32::from_rgb(128, 0, 128), + NamedColor::Cyan => egui::Color32::from_rgb(0, 128, 128), + NamedColor::White => egui::Color32::from_rgb(128, 128, 128), + NamedColor::BrightBlack => egui::Color32::from_rgb(48, 48, 48), + NamedColor::BrightRed => egui::Color32::from_rgb(255, 0, 0), + NamedColor::BrightGreen => egui::Color32::from_rgb(0, 255, 0), + NamedColor::BrightYellow => egui::Color32::from_rgb(255, 255, 0), + NamedColor::BrightBlue => egui::Color32::from_rgb(0, 0, 255), + NamedColor::BrightMagenta => egui::Color32::from_rgb(255, 0, 255), + NamedColor::BrightCyan => egui::Color32::from_rgb(0, 255, 255), + NamedColor::BrightWhite => egui::Color32::from_rgb(255, 255, 255), + NamedColor::Foreground => egui::Color32::from_rgb(0, 0, 0), + NamedColor::Background => egui::Color32::from_rgb(0, 0, 0), + NamedColor::Cursor => egui::Color32::from_rgb(128, 128, 128), + NamedColor::DimBlack => egui::Color32::from_rgb(0, 0, 0), + NamedColor::DimRed => egui::Color32::from_rgb(96, 0, 0), + NamedColor::DimGreen => egui::Color32::from_rgb(0, 96, 0), + NamedColor::DimYellow => egui::Color32::from_rgb(96, 96, 0), + NamedColor::DimBlue => egui::Color32::from_rgb(0, 0, 96), + NamedColor::DimMagenta => egui::Color32::from_rgb(96, 0, 96), + NamedColor::DimCyan => egui::Color32::from_rgb(0, 96, 96), + NamedColor::DimWhite => egui::Color32::from_rgb(96, 96, 96), + NamedColor::BrightForeground => egui::Color32::from_rgb(0, 0, 0), + NamedColor::DimForeground => egui::Color32::from_rgb(0, 0, 0), + }, + Color::Spec(rgb) => egui::Color32::from_rgb(rgb.r, rgb.g, rgb.b), + Color::Indexed(index) => egui::Color32::from_rgb(index, 0, 0), } } diff --git a/crates/term/src/_impl/mod.rs b/crates/term/src/_impl/mod.rs index 5f6c66a1..9db5e100 100644 --- a/crates/term/src/_impl/mod.rs +++ b/crates/term/src/_impl/mod.rs @@ -22,91 +22,97 @@ // terms of the Steamworks API by Valve Corporation, the licensors of this // Program grant you additional permission to convey the resulting work. -use color_eyre::eyre::WrapErr; -pub use crossbeam_channel::unbounded; -use crossbeam_channel::{Receiver, Sender}; -use std::io::prelude::*; use std::sync::Arc; -pub use termwiz; -mod into; -use into::{IntoEgui, IntoWez, TryIntoWez}; - -pub type TermSender = Sender>; -pub type TermReceiver = Receiver>; -pub type ByteSender = Sender>; -pub type ByteReceiver = Receiver>; +use alacritty_terminal::{ + event::Event, + event_loop::{EventLoop, EventLoopSender}, + sync::FairMutex, + term::{ + cell::{Cell, Flags}, + Config, + }, + Grid, Term, +}; -pub use portable_pty::CommandBuilder; +type ArcMutex = Arc>; -pub use termwiz::Error; +mod into; pub struct Terminal { - terminal: wezterm_term::Terminal, - reader: TermReceiver, - process: Option, - id: Option, - title: Option, - first_render: bool, + state: ArcMutex, + term: ArcMutex>, + event_loop_sender: EventLoopSender, } -struct Process { - child: Box, - pair: portable_pty::PtyPair, +#[derive(Debug)] +struct TerminalState { + title: String, } -impl Drop for Terminal { - fn drop(&mut self) { - let _ = self.kill(); +#[derive(Clone)] +struct EventListener { + state: ArcMutex, +} + +#[allow(clippy::single_match)] +impl alacritty_terminal::event::EventListener for EventListener { + fn send_event(&self, event: Event) { + let mut state = self.state.lock(); + println!("{event:#?}"); + match event { + Event::Title(title) => state.title = title, + _ => {} + } } } impl Terminal { - pub fn new( - ctx: &egui::Context, - command: portable_pty::CommandBuilder, - ) -> Result { - let pty_system = portable_pty::native_pty_system(); - let pair = pty_system.openpty(portable_pty::PtySize::default())?; - let child = pair.slave.spawn_command(command)?; - - let reader = pair.master.try_clone_reader()?; - let writer = pair.master.take_writer()?; - - let terminal = wezterm_term::Terminal::new( - wezterm_term::TerminalSize::default(), - Arc::new(Config), - "luminol-term", - "1.0", - writer, + pub fn new(ctx: &egui::Context) -> std::io::Result { + let pty = alacritty_terminal::tty::new( + &alacritty_terminal::tty::Options::default(), + // todo what do these do + alacritty_terminal::event::WindowSize { + num_cols: 80, + num_lines: 24, + // dummy values for now + cell_width: 12, + cell_height: 12, + }, + 0, + )?; + + let state = Arc::new(FairMutex::new(TerminalState { + title: "Terminal".to_string(), + })); + + // ??? + let grid = Grid::::new(24, 80, 100); + let term = Term::new( + Config::default(), + &grid, + EventListener { + state: state.clone(), + }, ); - - let ctx = ctx.clone(); - let (sender, reciever) = unbounded(); - std::thread::spawn(move || { - let mut buf = [0; 2usize.pow(10)]; - let mut reader = std::io::BufReader::new(reader); - let mut parser = termwiz::escape::parser::Parser::new(); - - loop { - let Ok(len) = reader.read(&mut buf) else { - return; - }; - let actions = parser.parse_as_vec(&buf[0..len]); - if !actions.is_empty() { - ctx.request_repaint(); - } - let Ok(_) = sender.send(actions) else { return }; - } - }); + let term = Arc::new(FairMutex::new(term)); + + let event_loop = EventLoop::new( + term.clone(), + EventListener { + state: state.clone(), + }, + pty, + false, + false, + ); + let event_loop_sender = event_loop.channel(); + event_loop.spawn(); // todo: do we need to keep this join handle around? Ok(Self { - terminal, - reader: reciever, - process: Some(Process { pair, child }), - id: None, - title: None, - first_render: true, + state, + term, + event_loop_sender, }) } @@ -114,48 +120,21 @@ impl Terminal { ctx: &egui::Context, id: egui::Id, title: impl Into, - receiver: Receiver>, default_cols: usize, default_rows: usize, ) -> Self { - let (cols, rows) = ctx.memory_mut(|m| { - *m.data - .get_persisted_mut_or_insert_with(id, move || (default_cols, default_rows)) - }); - Self { - terminal: wezterm_term::Terminal::new( - wezterm_term::TerminalSize { - cols, - rows, - ..Default::default() - }, - Arc::new(Config), - "luminol-term", - "1.0", - Box::new(std::io::sink()), - ), - reader: receiver, - process: None, - id: Some(id), - title: Some(title.into()), - first_render: true, - } + todo!() } pub fn title(&self) -> String { - self.title - .clone() - .unwrap_or_else(|| self.terminal.get_title().replace("wezterm", "luminol-term")) + // todo!() + let state = self.state.lock(); + state.title.clone() } pub fn id(&self) -> egui::Id { - if let Some(id) = self.id { - id - } else if let Some(id) = self.process.as_ref().and_then(|p| p.child.process_id()) { - egui::Id::new(id) - } else { - egui::Id::new(self.title()) - } + // todo!() + egui::Id::new("luminol_term_terminal") } pub fn set_size( @@ -164,330 +143,82 @@ impl Terminal { cols: usize, rows: usize, ) { - let mut size = self.terminal.get_size(); - size.cols = cols; - size.rows = rows; - self.terminal.resize(size); - update_state - .ctx - .memory_mut(|m| m.data.insert_persisted(self.id(), (size.cols, size.rows))); - if let Some(process) = &mut self.process { - if let Err(e) = process.pair.master.resize(portable_pty::PtySize { - rows: size.rows as u16, - cols: size.cols as u16, - ..Default::default() - }) { - luminol_core::error!( - update_state.toasts, - color_eyre::eyre::eyre!(e).wrap_err("Error resizing terminal") - ); - } - } + todo!() } pub fn set_cols(&mut self, update_state: &mut luminol_core::UpdateState<'_>, cols: usize) { - self.set_size(update_state, cols, self.terminal.get_size().rows); + todo!() } pub fn set_rows(&mut self, update_state: &mut luminol_core::UpdateState<'_>, rows: usize) { - self.set_size(update_state, self.terminal.get_size().cols, rows); + todo!() } pub fn size(&self) -> (usize, usize) { - let size = self.terminal.get_size(); - (size.cols, size.rows) + // todo!() + (80, 24) } pub fn cols(&self) -> usize { - self.terminal.get_size().cols + todo!() } pub fn rows(&self) -> usize { - self.terminal.get_size().rows + todo!() } pub fn erase_scrollback(&mut self) { - self.terminal.erase_scrollback(); + todo!() } pub fn erase_scrollback_and_viewport(&mut self) { - self.terminal.erase_scrollback_and_viewport(); - self.terminal - .perform_actions(vec![termwiz::escape::Action::CSI( - termwiz::escape::CSI::Edit(termwiz::escape::csi::Edit::EraseInDisplay( - termwiz::escape::csi::EraseInDisplay::EraseDisplay, - )), - )]) + todo!() } pub fn update(&mut self) { - for actions in self.reader.try_iter() { - self.terminal.perform_actions(actions); - } + todo!() } pub fn ui(&mut self, ui: &mut egui::Ui) -> color_eyre::Result<()> { - // Forget the scroll position from the last time the user opened the application so that - // the terminal immediately scrolls to the bottom - let scroll_area_id_source = "scroll_area"; - if self.first_render { - self.first_render = false; - let scroll_area_id = ui.make_persistent_id(egui::Id::new(scroll_area_id_source)); - egui::scroll_area::State::default().store(ui.ctx(), scroll_area_id); - } + // todo!() + let term = self.term.lock(); + let content = term.renderable_content(); + + let mut job = egui::text::LayoutJob::default(); + for cell in content.display_iter { + let mut buf = [0; 4]; + let text = cell.c.encode_utf8(&mut buf); + + let format = egui::TextFormat { + font_id: egui::FontId::monospace(12.), + color: into::color_to_egui(cell.fg), + background: into::color_to_egui(cell.bg), + ..Default::default() + }; - self.update(); - - let size = self.terminal.get_size(); - let cursor_pos = self.terminal.cursor_pos(); - let palette = self.terminal.get_config().color_palette(); - - let prev_spacing = ui.spacing().item_spacing; - ui.spacing_mut().item_spacing = egui::Vec2::ZERO; - - let text_width = ui.fonts(|f| f.glyph_width(&egui::FontId::monospace(12.0), '?')); - let text_height = ui.text_style_height(&egui::TextStyle::Monospace); - - let scroll_area_height = (size.rows + 1) as f32 * text_height; - let mut inner_result = Ok(()); - egui::ScrollArea::vertical() - .id_source(scroll_area_id_source) - .max_height(scroll_area_height) - .min_scrolled_height(scroll_area_height) - .stick_to_bottom(true) - .show_rows( - ui, - text_height, - self.terminal.screen().scrollback_rows(), - |ui, rows| { - let mut job = egui::text::LayoutJob::default(); - let mut iter = self - .terminal - .screen() - .lines_in_phys_range(rows) - .into_iter() - .peekable(); - while let Some(line) = iter.next() { - for cluster in line.cluster(None) { - let fg_color = - palette.resolve_fg(cluster.attrs.foreground()).into_egui(); - let bg_color = - palette.resolve_bg(cluster.attrs.background()).into_egui(); - let underline = if !matches!( - cluster.attrs.underline(), - wezterm_term::Underline::None - ) { - egui::Stroke::new( - 1.0, - palette - .resolve_fg(cluster.attrs.underline_color()) - .into_egui(), - ) - } else { - egui::Stroke::NONE - }; - let strikethrough = if cluster.attrs.strikethrough() { - egui::Stroke::new( - 1.0, - palette.resolve_fg(cluster.attrs.foreground()).into_egui(), - ) - } else { - egui::Stroke::NONE - }; - job.append( - &cluster.text, - 0.0, - egui::TextFormat { - font_id: egui::FontId::monospace(12.0), - color: fg_color, - background: bg_color, - italics: cluster.attrs.italic(), - underline, - strikethrough, - ..Default::default() - }, - ); - } - if iter.peek().is_some() { - job.append( - "\n", - 0.0, - egui::TextFormat { - font_id: egui::FontId::monospace(12.0), - ..Default::default() - }, - ); - } - } - - let galley = ui.fonts(|f| f.layout_job(job)); - let mut galley_rect = galley.rect; - galley_rect.set_width(text_width * size.cols as f32); - - let cursor = galley - .cursor_from_pos(egui::vec2(cursor_pos.x as f32, cursor_pos.y as f32)); - let cursor_pos = galley.pos_from_cursor(&cursor); - - let (response, painter) = - ui.allocate_painter(galley_rect.size(), egui::Sense::click_and_drag()); - - if response.clicked() && !response.has_focus() { - ui.memory_mut(|mem| mem.request_focus(response.id)); - } - - painter.rect_filled( - galley_rect.translate(response.rect.min.to_vec2()), - 0.0, - palette.background.into_egui(), - ); - - painter.galley(response.rect.min, galley); - - painter.rect_stroke( - egui::Rect::from_min_size( - cursor_pos.min, - egui::vec2(text_width, text_height), - ), - egui::Rounding::ZERO, - egui::Stroke::new(1.0, egui::Color32::WHITE), - ); - - if response.hovered() { - ui.output_mut(|o| o.mutable_text_under_cursor = true); - ui.ctx().set_cursor_icon(egui::CursorIcon::Text); - } - - let focused = response.has_focus(); - ui.input(|i| { - if !focused { - return; - } - - for e in i.events.iter() { - let result = match e { - egui::Event::PointerMoved(pos) => { - let relative_pos = *pos - response.rect.min; - let char_x = (relative_pos.x / 12.0) as usize; - let char_y = (relative_pos.y / 12.0) as i64; - self.terminal.mouse_event(wezterm_term::MouseEvent { - kind: wezterm_term::MouseEventKind::Move, - x: char_x, - y: char_y, - x_pixel_offset: 0, - y_pixel_offset: 0, - button: wezterm_term::MouseButton::None, - modifiers: i.modifiers.into_wez(), - }) - } - egui::Event::PointerButton { - pos, - button, - pressed, - modifiers, - } => { - let relative_pos = *pos - response.rect.min; - let char_x = (relative_pos.x / text_width) as usize; - let char_y = (relative_pos.y / text_height) as i64; - self.terminal.mouse_event(wezterm_term::MouseEvent { - kind: if *pressed { - wezterm_term::MouseEventKind::Press - } else { - wezterm_term::MouseEventKind::Release - }, - x: char_x, - y: char_y, - x_pixel_offset: 0, - y_pixel_offset: 0, - button: button.into_wez(), - modifiers: modifiers.into_wez(), - }) - } - egui::Event::Scroll(pos) => { - let relative_pos = - i.pointer.interact_pos().unwrap() - response.rect.min; - let char_x = (relative_pos.x / text_width) as usize; - let char_y = (relative_pos.y / text_height) as i64; - self.terminal.mouse_event(wezterm_term::MouseEvent { - kind: wezterm_term::MouseEventKind::Press, - x: char_x, - y: char_y, - x_pixel_offset: 0, - y_pixel_offset: 0, - button: if pos.y.is_sign_positive() { - wezterm_term::MouseButton::WheelUp(pos.y as usize) - } else { - wezterm_term::MouseButton::WheelDown(-pos.y as usize) - }, - modifiers: i.modifiers.into_wez(), - }) - } - egui::Event::Key { - key, - modifiers, - pressed, - .. - } => { - if let Ok(key) = key.try_into_wez() { - if *pressed { - self.terminal.key_down(key, modifiers.into_wez()) - } else { - self.terminal.key_up(key, modifiers.into_wez()) - } - } else { - Ok(()) - } - } - egui::Event::Text(t) => t - .chars() - .try_for_each(|c| { - self.terminal.key_down( - wezterm_term::KeyCode::Char(c), - i.modifiers.into_wez(), - ) - }) - .and_then(|_| { - t.chars().try_for_each(|c| { - self.terminal.key_up( - wezterm_term::KeyCode::Char(c), - i.modifiers.into_wez(), - ) - }) - }), - _ => Ok(()), - }; - if let Err(e) = result { - inner_result = Err(color_eyre::eyre::eyre!(e)) - .wrap_err("Terminal input error"); - break; - }; - } - }); - }, - ); - - ui.spacing_mut().item_spacing = prev_spacing; - inner_result - } + job.append(text, 0.0, format); - #[inline(never)] - pub fn kill(&mut self) -> color_eyre::Result<()> { - if let Some(process) = &mut self.process { - process.child.kill().map_err(|e| e.into()) - } else { - Ok(()) + if cell.point.column >= 79 { + job.append("\n", 0.0, Default::default()); + } } - } -} + let galley = ui.fonts(|f| f.layout_job(job)); + let (response, painter) = + ui.allocate_painter(galley.rect.size(), egui::Sense::click_and_drag()); + + painter.rect_filled( + galley.rect.translate(response.rect.min.to_vec2()), + 0.0, + egui::Color32::BLACK, + ); -#[derive(Debug)] -struct Config; + painter.galley(response.rect.min, galley); -impl wezterm_term::TerminalConfiguration for Config { - fn color_palette(&self) -> wezterm_term::color::ColorPalette { - wezterm_term::color::ColorPalette::default() + Ok(()) } - fn enable_title_reporting(&self) -> bool { - true + pub fn kill(&mut self) { + // todo!() + self.term.lock().exit() } } diff --git a/crates/ui/src/windows/console.rs b/crates/ui/src/windows/console.rs index 13e96dce..818e57ce 100644 --- a/crates/ui/src/windows/console.rs +++ b/crates/ui/src/windows/console.rs @@ -27,12 +27,9 @@ pub struct Window { } impl Window { - pub fn new( - ctx: &egui::Context, - command: luminol_term::CommandBuilder, - ) -> Result { + pub fn new(ctx: &egui::Context) -> std::io::Result { Ok(Self { - term: luminol_term::Terminal::new(ctx, command)?, + term: luminol_term::Terminal::new(ctx)?, }) } } @@ -66,12 +63,13 @@ impl luminol_core::Window for Window { .button(egui::RichText::new("KILL").color(egui::Color32::RED)) .clicked() { - if let Err(e) = self.term.kill() { - luminol_core::error!( - update_state.toasts, - e.wrap_err("Error killing child"), - ); - } + // if let Err(e) = self.term.kill() { + // luminol_core::error!( + // update_state.toasts, + // e.wrap_err("Error killing child"), + // ); + // } + self.term.kill() } let mut resize = false; diff --git a/src/app/mod.rs b/src/app/mod.rs index a937f44b..29922043 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -28,15 +28,15 @@ use crate::lumi::Lumi; #[cfg(feature = "steamworks")] use crate::steam::Steamworks; -#[cfg(not(target_arch = "wasm32"))] -mod log_window; +// #[cfg(not(target_arch = "wasm32"))] +// mod log_window; mod top_bar; /// The main Luminol struct. Handles rendering, GUI state, that sort of thing. pub struct App { top_bar: top_bar::TopBar, - #[cfg(not(target_arch = "wasm32"))] - log: log_window::LogWindow, + // #[cfg(not(target_arch = "wasm32"))] + // log: log_window::LogWindow, lumi: Lumi, #[cfg(not(target_arch = "wasm32"))] @@ -84,8 +84,8 @@ impl App { pub fn new( cc: &luminol_eframe::CreationContext<'_>, modified: luminol_core::ModifiedState, - #[cfg(not(target_arch = "wasm32"))] log_term_rx: luminol_term::TermReceiver, - #[cfg(not(target_arch = "wasm32"))] log_byte_rx: luminol_term::ByteReceiver, + // #[cfg(not(target_arch = "wasm32"))] log_term_rx: luminol_term::TermReceiver, + // #[cfg(not(target_arch = "wasm32"))] log_byte_rx: luminol_term::ByteReceiver, #[cfg(not(target_arch = "wasm32"))] try_load_path: Option, #[cfg(target_arch = "wasm32")] audio: luminol_audio::AudioWrapper, #[cfg(feature = "steamworks")] steamworks: Steamworks, @@ -218,17 +218,17 @@ impl App { Self { top_bar: top_bar::TopBar::default(), #[cfg(not(target_arch = "wasm32"))] - log: log_window::LogWindow::new( - luminol_term::Terminal::new_readonly( - &cc.egui_ctx, - "luminol_log".into(), - "Log", - log_term_rx, - 132, - 43, - ), - log_byte_rx, - ), + // log: log_window::LogWindow::new( + // luminol_term::Terminal::new_readonly( + // &cc.egui_ctx, + // "luminol_log".into(), + // "Log", + // log_term_rx, + // 132, + // 43, + // ), + // log_byte_rx, + // ), lumi, audio, @@ -353,9 +353,9 @@ impl luminol_eframe::App for App { { if self.top_bar.show_log { self.top_bar.show_log = false; - self.log.term_shown = true; + // self.log.term_shown = true; } - self.log.ui(ui, &mut update_state); + // self.log.ui(ui, &mut update_state); } }); diff --git a/src/app/top_bar.rs b/src/app/top_bar.rs index 8a996fb8..958a7396 100644 --- a/src/app/top_bar.rs +++ b/src/app/top_bar.rs @@ -279,25 +279,25 @@ impl TopBar { ui.add_enabled_ui(update_state.filesystem.project_loaded(), |ui| { if ui.button("Playtest").clicked() { - let mut cmd = luminol_term::CommandBuilder::new("steamshim"); - cmd.cwd( - update_state - .filesystem - .project_path() - .expect("project not loaded"), - ); + // let mut cmd = luminol_term::CommandBuilder::new("steamshim"); + // cmd.cwd( + // update_state + // .filesystem + // .project_path() + // .expect("project not loaded"), + // ); let result = - luminol_ui::windows::console::Window::new(ui.ctx(), cmd).or_else(|_| { - let mut cmd = luminol_term::CommandBuilder::new("game"); - cmd.cwd( - update_state - .filesystem - .project_path() - .expect("project not loaded"), - ); - - luminol_ui::windows::console::Window::new(ui.ctx(), cmd) + luminol_ui::windows::console::Window::new(ui.ctx()).or_else(|_| { + // let mut cmd = luminol_term::CommandBuilder::new("game"); + // cmd.cwd( + // update_state + // .filesystem + // .project_path() + // .expect("project not loaded"), + // ); + + luminol_ui::windows::console::Window::new(ui.ctx()) }); match result { @@ -315,16 +315,15 @@ impl TopBar { #[cfg(windows)] let shell = "powershell"; #[cfg(unix)] - let shell = std::env::var("SHELL").unwrap_or_else(|_| "bash".to_string()); - let mut cmd = luminol_term::CommandBuilder::new(shell); - cmd.cwd( - update_state - .filesystem - .project_path() - .expect("project not loaded"), - ); - - match luminol_ui::windows::console::Window::new(ui.ctx(), cmd) { + // let shell = std::env::var("SHELL").unwrap_or_else(|_| "bash".to_string()); + // let mut cmd = luminol_term::CommandBuilder::new(shell); + // cmd.cwd( + // update_state + // .filesystem + // .project_path() + // .expect("project not loaded"), + // ); + match luminol_ui::windows::console::Window::new(ui.ctx()) { Ok(w) => update_state.edit_windows.add_window(w), Err(e) => luminol_core::error!( update_state.toasts, diff --git a/src/main.rs b/src/main.rs index b0e2b024..8e8250d5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,64 +62,61 @@ where } #[cfg(not(target_arch = "wasm32"))] -static LOG_TERM_SENDER: once_cell::sync::OnceCell = - once_cell::sync::OnceCell::new(); - +// static LOG_TERM_SENDER: once_cell::sync::OnceCell = +// once_cell::sync::OnceCell::new(); #[cfg(not(target_arch = "wasm32"))] -static LOG_BYTE_SENDER: once_cell::sync::OnceCell = - once_cell::sync::OnceCell::new(); - +// static LOG_BYTE_SENDER: once_cell::sync::OnceCell = +// once_cell::sync::OnceCell::new(); #[cfg(not(target_arch = "wasm32"))] static CONTEXT: once_cell::sync::OnceCell = once_cell::sync::OnceCell::new(); #[cfg(not(target_arch = "wasm32"))] /// A writer that writes to Luminol's log window. -struct LogWriter(luminol_term::termwiz::escape::parser::Parser); +// struct LogWriter(luminol_term::termwiz::escape::parser::Parser); #[cfg(not(target_arch = "wasm32"))] -impl std::io::Write for LogWriter { - fn write(&mut self, buf: &[u8]) -> std::io::Result { - LOG_BYTE_SENDER - .get() - .unwrap() - .try_send(buf.into()) - .map_err(std::io::Error::other)?; - - let parsed = self.0.parse_as_vec(buf); - - // Convert from LF line endings to CRLF so that wezterm will display them properly - let mut vec = Vec::with_capacity(2 * parsed.len()); - for action in parsed { - if action - == luminol_term::termwiz::escape::Action::Control( - luminol_term::termwiz::escape::ControlCode::LineFeed, - ) - { - vec.push(luminol_term::termwiz::escape::Action::Control( - luminol_term::termwiz::escape::ControlCode::CarriageReturn, - )); - } - vec.push(action); - } - - LOG_TERM_SENDER - .get() - .unwrap() - .try_send(vec) - .map_err(std::io::Error::other)?; - - if let Some(ctx) = CONTEXT.get() { - ctx.request_repaint(); - } - - Ok(buf.len()) - } - - fn flush(&mut self) -> std::io::Result<()> { - Ok(()) - } -} - +// impl std::io::Write for LogWriter { +// fn write(&mut self, buf: &[u8]) -> std::io::Result { +// LOG_BYTE_SENDER +// .get() +// .unwrap() +// .try_send(buf.into()) +// .map_err(std::io::Error::other)?; + +// let parsed = self.0.parse_as_vec(buf); + +// // Convert from LF line endings to CRLF so that wezterm will display them properly +// let mut vec = Vec::with_capacity(2 * parsed.len()); +// for action in parsed { +// if action +// == luminol_term::termwiz::escape::Action::Control( +// luminol_term::termwiz::escape::ControlCode::LineFeed, +// ) +// { +// vec.push(luminol_term::termwiz::escape::Action::Control( +// luminol_term::termwiz::escape::ControlCode::CarriageReturn, +// )); +// } +// vec.push(action); +// } + +// LOG_TERM_SENDER +// .get() +// .unwrap() +// .try_send(vec) +// .map_err(std::io::Error::other)?; + +// if let Some(ctx) = CONTEXT.get() { +// ctx.request_repaint(); +// } + +// Ok(buf.len()) +// } + +// fn flush(&mut self) -> std::io::Result<()> { +// Ok(()) +// } +// } #[cfg(not(target_arch = "wasm32"))] fn main() { #[cfg(feature = "steamworks")] @@ -213,17 +210,20 @@ fn main() { .expect("failed to install color-eyre hooks"); // Log to stderr as well as Luminol's log. - let (log_term_tx, log_term_rx) = luminol_term::unbounded(); - let (log_byte_tx, log_byte_rx) = luminol_term::unbounded(); - LOG_TERM_SENDER.set(log_term_tx).unwrap(); - LOG_BYTE_SENDER.set(log_byte_tx).unwrap(); + // let (log_term_tx, log_term_rx) = luminol_term::unbounded(); + // let (log_byte_tx, log_byte_rx) = luminol_term::unbounded(); + // LOG_TERM_SENDER.set(log_term_tx).unwrap(); + // LOG_BYTE_SENDER.set(log_byte_tx).unwrap(); + // tracing_subscriber::fmt() + // .with_writer(|| { + // CopyWriter( + // std::io::stderr(), + // LogWriter(luminol_term::termwiz::escape::parser::Parser::new()), + // ) + // }) + // .init(); tracing_subscriber::fmt() - .with_writer(|| { - CopyWriter( - std::io::stderr(), - LogWriter(luminol_term::termwiz::escape::parser::Parser::new()), - ) - }) + .with_writer(std::io::stdout) .init(); let image = image::load_from_memory(ICON).expect("Failed to load Icon data."); @@ -263,8 +263,8 @@ fn main() { Box::new(app::App::new( cc, Default::default(), - log_term_rx, - log_byte_rx, + // log_term_rx, + // log_byte_rx, std::env::args_os().nth(1), #[cfg(feature = "steamworks")] steamworks,