diff --git a/Cargo.lock b/Cargo.lock index c169d4d..47cad4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -76,6 +76,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" + [[package]] name = "arbitrary" version = "1.4.2" @@ -93,7 +99,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -112,6 +118,15 @@ dependencies = [ "tungstenite", ] +[[package]] +name = "atomic" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89cbf775b137e9b968e67227ef7f775587cde3fd31b0d8599dbd0f598a48340" +dependencies = [ + "bytemuck", +] + [[package]] name = "atomic-waker" version = "1.1.2" @@ -226,6 +241,27 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e050f626429857a27ddccb31e0aca21356bfa709c04041aefddac081a8f068a" +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.10.0" @@ -253,6 +289,12 @@ version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" +[[package]] +name = "bytemuck" +version = "1.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec" + [[package]] name = "bytes" version = "1.11.0" @@ -301,6 +343,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "chrono" version = "0.4.42" @@ -409,6 +457,20 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "compact_str" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb1325a1cece981e8a296ab8f0f9b63ae357bd0784a9faaf548cc7b480707a" +dependencies = [ + "castaway", + "cfg-if", + "itoa", + "rustversion", + "ryu", + "static_assertions", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -519,7 +581,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags", + "bitflags 2.10.0", "crossterm_winapi", "libc", "mio 0.8.11", @@ -535,7 +597,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "bitflags", + "bitflags 2.10.0", "crossterm_winapi", "mio 1.1.1", "parking_lot", @@ -551,7 +613,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" dependencies = [ - "bitflags", + "bitflags 2.10.0", "crossterm_winapi", "derive_more", "document-features", @@ -583,6 +645,16 @@ dependencies = [ "typenum", ] +[[package]] +name = "csscolorparser" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb2a7d3066da2de787b7f032c736763eb7ae5d355f81a68bab2675a96008b0bf" +dependencies = [ + "lab", + "phf", +] + [[package]] name = "ctr" version = "0.9.2" @@ -613,7 +685,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.111", ] [[package]] @@ -624,7 +696,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -653,6 +725,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26bf8fc351c5ed29b5c2f0cbbac1b209b74f60ecd62e675a998df72c49af5204" +[[package]] +name = "deltae" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4" + [[package]] name = "der" version = "0.7.10" @@ -680,7 +758,7 @@ checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -702,7 +780,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 2.0.111", ] [[package]] @@ -724,7 +802,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -784,6 +862,15 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "euclid" +version = "0.22.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df61bf483e837f88d5c2291dcf55c67be7e676b3a51acc48db3a7b163b91ed63" +dependencies = [ + "num-traits", +] + [[package]] name = "eyre" version = "0.6.12" @@ -794,6 +881,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "fancy-regex" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" +dependencies = [ + "bit-set", + "regex", +] + [[package]] name = "fastrand" version = "2.3.0" @@ -806,12 +903,35 @@ version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" +[[package]] +name = "filedescriptor" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e40758ed24c9b2eeb76c35fb0aebc66c626084edd827e07e1552279814c6682d" +dependencies = [ + "libc", + "thiserror 1.0.69", + "winapi", +] + [[package]] name = "find-msvc-tools" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" +[[package]] +name = "finl_unicode" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9844ddc3a6e533d62bba727eb6c28b5d360921d5175e9ff0f1e621a5c590a4d5" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "flate2" version = "1.1.5" @@ -835,6 +955,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + [[package]] name = "foreign-types" version = "0.3.2" @@ -921,7 +1047,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -1042,7 +1168,7 @@ checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ "allocator-api2", "equivalent", - "foldhash", + "foldhash 0.1.5", ] [[package]] @@ -1050,6 +1176,11 @@ name = "hashbrown" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", +] [[package]] name = "headers" @@ -1407,7 +1538,7 @@ dependencies = [ "indoc", "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -1441,7 +1572,7 @@ dependencies = [ "pnet", "rand 0.8.5", "rand_core 0.6.4", - "ratatui 0.29.0", + "ratatui 0.30.0", "ratatui_input", "reactive-rs", "reqwest", @@ -1513,6 +1644,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.15" @@ -1545,6 +1685,23 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" +[[package]] +name = "kasuari" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fe90c1150662e858c7d5f945089b7517b0a80d8bf7ba4b1b5ffc984e7230a5b" +dependencies = [ + "hashbrown 0.16.1", + "portable-atomic", + "thiserror 2.0.17", +] + +[[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.5.0" @@ -1572,6 +1729,15 @@ dependencies = [ "zlib-rs", ] +[[package]] +name = "line-clipping" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4de44e98ddbf09375cbf4d17714d18f39195f4f4894e8524501726fd9a8a4a" +dependencies = [ + "bitflags 2.10.0", +] + [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -1620,6 +1786,15 @@ dependencies = [ "hashbrown 0.15.5", ] +[[package]] +name = "lru" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1dc47f592c06f33f8e3aea9591776ec7c9f9e4124778ff8a3c3b87159f7e593" +dependencies = [ + "hashbrown 0.16.1", +] + [[package]] name = "lzma-rust2" version = "0.13.0" @@ -1630,6 +1805,16 @@ dependencies = [ "sha2", ] +[[package]] +name = "mac_address" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0aeb26bf5e836cc1c341c8106051b573f1766dfa05aa87f0b98be5e51b02303" +dependencies = [ + "nix", + "winapi", +] + [[package]] name = "mach" version = "0.2.3" @@ -1660,6 +1845,21 @@ version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +[[package]] +name = "memmem" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15" + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + [[package]] name = "mime" version = "0.3.17" @@ -1676,6 +1876,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.8.9" @@ -1727,12 +1933,35 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.10.0", + "cfg-if", + "cfg_aliases", + "libc", + "memoffset", +] + [[package]] name = "no-std-net" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "ntapi" version = "0.4.1" @@ -1748,6 +1977,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.111", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1822,7 +2062,7 @@ version = "0.10.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" dependencies = [ - "bitflags", + "bitflags 2.10.0", "cfg-if", "foreign-types", "libc", @@ -1839,7 +2079,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -1860,6 +2100,15 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "ordered-float" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" +dependencies = [ + "num-traits", +] + [[package]] name = "owo-colors" version = "4.2.3" @@ -1911,6 +2160,101 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "pest" +version = "2.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9eb05c21a464ea704b53158d358a31e6425db2f63a1a7312268b05fe2b75f7" +dependencies = [ + "memchr", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f9dbced329c441fa79d80472764b1a2c7e57123553b8519b36663a2fb234ed" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bb96d5051a78f44f43c8f712d8e810adb0ebf923fc9ed2655a7f66f63ba8ee5" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "pest_meta" +version = "2.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "602113b5b5e8621770cfd490cfd90b9f84ab29bd2b0e49ad83eb6d186cef2365" +dependencies = [ + "pest", + "sha2", +] + +[[package]] +name = "phf" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +dependencies = [ + "phf_macros", + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +dependencies = [ + "phf_shared", + "rand 0.8.5", +] + +[[package]] +name = "phf_macros" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" version = "1.1.10" @@ -1928,7 +2272,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -2004,7 +2348,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn", + "syn 2.0.111", ] [[package]] @@ -2062,6 +2406,12 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + [[package]] name = "potential_utf" version = "0.1.4" @@ -2187,17 +2537,17 @@ version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f44c9e68fd46eda15c646fbb85e1040b657a58cdc8c98db1d97a55930d991eef" dependencies = [ - "bitflags", + "bitflags 2.10.0", "cassowary", "compact_str 0.7.1", "crossterm 0.27.0", "itertools 0.12.1", - "lru", + "lru 0.12.5", "paste", "stability", "strum 0.26.3", "unicode-segmentation", - "unicode-truncate", + "unicode-truncate 1.1.0", "unicode-width 0.1.14", ] @@ -2207,19 +2557,103 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" dependencies = [ - "bitflags", + "bitflags 2.10.0", "cassowary", "compact_str 0.8.1", "crossterm 0.28.1", "indoc", "instability", "itertools 0.13.0", - "lru", + "lru 0.12.5", "paste", "strum 0.26.3", + "unicode-segmentation", + "unicode-truncate 1.1.0", + "unicode-width 0.2.0", +] + +[[package]] +name = "ratatui" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1ce67fb8ba4446454d1c8dbaeda0557ff5e94d39d5e5ed7f10a65eb4c8266bc" +dependencies = [ + "instability", + "ratatui-core", + "ratatui-crossterm", + "ratatui-macros", + "ratatui-termwiz", + "ratatui-widgets", +] + +[[package]] +name = "ratatui-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef8dea09a92caaf73bff7adb70b76162e5937524058a7e5bff37869cbbec293" +dependencies = [ + "bitflags 2.10.0", + "compact_str 0.9.0", + "hashbrown 0.16.1", + "indoc", + "itertools 0.14.0", + "kasuari", + "lru 0.16.3", + "strum 0.27.2", + "thiserror 2.0.17", + "unicode-segmentation", + "unicode-truncate 2.0.1", + "unicode-width 0.2.0", +] + +[[package]] +name = "ratatui-crossterm" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "577c9b9f652b4c121fb25c6a391dd06406d3b092ba68827e6d2f09550edc54b3" +dependencies = [ + "cfg-if", + "crossterm 0.29.0", + "instability", + "ratatui-core", +] + +[[package]] +name = "ratatui-macros" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f1342a13e83e4bb9d0b793d0ea762be633f9582048c892ae9041ef39c936f4" +dependencies = [ + "ratatui-core", + "ratatui-widgets", +] + +[[package]] +name = "ratatui-termwiz" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f76fe0bd0ed4295f0321b1676732e2454024c15a35d01904ddb315afd3d545c" +dependencies = [ + "ratatui-core", + "termwiz", +] + +[[package]] +name = "ratatui-widgets" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7dbfa023cd4e604c2553483820c5fe8aa9d71a42eea5aa77c6e7f35756612db" +dependencies = [ + "bitflags 2.10.0", + "hashbrown 0.16.1", + "indoc", + "instability", + "itertools 0.14.0", + "line-clipping", + "ratatui-core", + "strum 0.27.2", "time", "unicode-segmentation", - "unicode-truncate", "unicode-width 0.2.0", ] @@ -2269,7 +2703,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags", + "bitflags 2.10.0", ] [[package]] @@ -2376,7 +2810,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags", + "bitflags 2.10.0", "errno", "libc", "linux-raw-sys 0.4.15", @@ -2389,7 +2823,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" dependencies = [ - "bitflags", + "bitflags 2.10.0", "errno", "libc", "linux-raw-sys 0.11.0", @@ -2489,7 +2923,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags", + "bitflags 2.10.0", "core-foundation", "core-foundation-sys", "libc", @@ -2539,7 +2973,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -2652,6 +3086,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" +[[package]] +name = "siphasher" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e" + [[package]] name = "slab" version = "0.4.11" @@ -2702,7 +3142,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -2737,6 +3177,9 @@ name = "strum" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" +dependencies = [ + "strum_macros 0.27.2", +] [[package]] name = "strum_macros" @@ -2748,7 +3191,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 2.0.111", ] [[package]] @@ -2760,7 +3203,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -2769,6 +3212,17 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.111" @@ -2797,7 +3251,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -2831,7 +3285,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags", + "bitflags 2.10.0", "core-foundation", "system-configuration-sys", ] @@ -2859,13 +3313,96 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "terminfo" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4ea810f0692f9f51b382fff5893887bb4580f5fa246fde546e0b13e7fcee662" +dependencies = [ + "fnv", + "nom", + "phf", + "phf_codegen", +] + +[[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.23.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4676b37242ccbd1aabf56edb093a4827dc49086c0ffd764a5705899e0f35f8f7" +dependencies = [ + "anyhow", + "base64", + "bitflags 2.10.0", + "fancy-regex", + "filedescriptor", + "finl_unicode", + "fixedbitset", + "hex", + "lazy_static", + "libc", + "log", + "memmem", + "nix", + "num-derive", + "num-traits", + "ordered-float", + "pest", + "pest_derive", + "phf", + "sha2", + "signal-hook", + "siphasher", + "terminfo", + "termios", + "thiserror 1.0.69", + "ucd-trie", + "unicode-segmentation", + "vtparse", + "wezterm-bidi", + "wezterm-blob-leases", + "wezterm-color-types", + "wezterm-dynamic", + "wezterm-input-types", + "winapi", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.17", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.111", ] [[package]] @@ -2876,7 +3413,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -2944,7 +3481,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -3020,7 +3557,7 @@ version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" dependencies = [ - "bitflags", + "bitflags 2.10.0", "bytes", "futures-util", "http", @@ -3127,7 +3664,7 @@ dependencies = [ "native-tls", "rand 0.9.2", "sha1", - "thiserror", + "thiserror 2.0.17", "utf-8", ] @@ -3137,6 +3674,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + [[package]] name = "unicase" version = "2.8.1" @@ -3166,6 +3709,17 @@ dependencies = [ "unicode-width 0.1.14", ] +[[package]] +name = "unicode-truncate" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b380a1238663e5f8a691f9039c73e1cdae598a30e9855f541d29b08b53e9a5" +dependencies = [ + "itertools 0.14.0", + "unicode-segmentation", + "unicode-width 0.2.0", +] + [[package]] name = "unicode-width" version = "0.1.14" @@ -3224,12 +3778,19 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" dependencies = [ + "atomic", "getrandom 0.3.4", "js-sys", "wasm-bindgen", @@ -3253,6 +3814,15 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "vtparse" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d9b2acfb050df409c972a37d3b8e08cdea3bddb0c09db9d53137e504cfabed0" +dependencies = [ + "utf8parse", +] + [[package]] name = "walkdir" version = "2.5.0" @@ -3359,7 +3929,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn", + "syn 2.0.111", "wasm-bindgen-shared", ] @@ -3382,6 +3952,78 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "wezterm-bidi" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0a6e355560527dd2d1cf7890652f4f09bb3433b6aadade4c9b5ed76de5f3ec" +dependencies = [ + "log", + "wezterm-dynamic", +] + +[[package]] +name = "wezterm-blob-leases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692daff6d93d94e29e4114544ef6d5c942a7ed998b37abdc19b17136ea428eb7" +dependencies = [ + "getrandom 0.3.4", + "mac_address", + "sha2", + "thiserror 1.0.69", + "uuid", +] + +[[package]] +name = "wezterm-color-types" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7de81ef35c9010270d63772bebef2f2d6d1f2d20a983d27505ac850b8c4b4296" +dependencies = [ + "csscolorparser", + "deltae", + "lazy_static", + "wezterm-dynamic", +] + +[[package]] +name = "wezterm-dynamic" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f2ab60e120fd6eaa68d9567f3226e876684639d22a4219b313ff69ec0ccd5ac" +dependencies = [ + "log", + "ordered-float", + "strsim", + "thiserror 1.0.69", + "wezterm-dynamic-derive", +] + +[[package]] +name = "wezterm-dynamic-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c0cf2d539c645b448eaffec9ec494b8b19bd5077d9e58cb1ae7efece8d575b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "wezterm-input-types" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7012add459f951456ec9d6c7e6fc340b1ce15d6fc9629f8c42853412c029e57e" +dependencies = [ + "bitflags 1.3.2", + "euclid", + "lazy_static", + "serde", + "wezterm-dynamic", +] + [[package]] name = "winapi" version = "0.3.9" @@ -3453,7 +4095,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -3464,7 +4106,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -3804,7 +4446,7 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", "synstructure", ] @@ -3825,7 +4467,7 @@ checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -3845,7 +4487,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", "synstructure", ] @@ -3866,7 +4508,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -3899,7 +4541,7 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 852e983..a88b8de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ once_cell = "1.21.3" pkcs8 = { version = "*", features = ["alloc"] } rand = "0.8" rand_core = { version = "0.6", features = ["getrandom", "std"] } -ratatui = { version = "*", features = ["all-widgets"]} reactive-rs = "*" aws-lc-rs = "*" reqwest = "0.12.23" @@ -51,10 +50,11 @@ async-trait = "0.1.89" sha1 = "0.10.6" async-tungstenite = "0.32.0" zip = "6.0.0" -ratatui_input = "0.1.3" tui-textarea = "0.7.0" tui-input = "0.14.0" pnet = "0.35.0" dashmap = "6.1.0" strum = "0.27.2" strum_macros = "0.27.2" +ratatui = "0.30.0" +ratatui_input = "0.1.3" diff --git a/src/eula/terms_checker.rs b/src/eula/terms_checker.rs index b17660c..3b09794 100644 --- a/src/eula/terms_checker.rs +++ b/src/eula/terms_checker.rs @@ -172,11 +172,7 @@ impl ConsentUiState { } fn run_consent_ui() -> UserChoice { - enable_raw_mode().unwrap(); - let mut stdout = io::stdout(); - execute!(stdout, EnterAlternateScreen).unwrap(); - let backend = CrosstermBackend::new(stdout); - let mut terminal = Terminal::new(backend).unwrap(); + let mut terminal = ratatui::init(); let mut state = ConsentUiState { eula: false, @@ -188,23 +184,34 @@ fn run_consent_ui() -> UserChoice { let result = loop { terminal .draw(|f| { - let size = f.area(); - let mut needed_height = 5; - let margin = if size.width > 80 && size.height > 18 { - 2 - } else if size.width > 78 && size.height > 16 { - 1 - } else { - 0 - }; + let size = f.area(); + + if size.height < 6 + || size.width < 27 { + f.render_widget(Line::from(format!("too small {}/63 by {}/12", size.width, size.height)), size); + return; + } + + let max_width = 132; + let max_height = 20; + + let content_width = if max_width < size.width { max_width } else { size.width} ; + let content_height = if max_height < size.height { max_height } else { size.height} ; + + let horizontal_margin = (size.width.saturating_sub(content_width)) / 2; + let vertical_margin = (size.height.saturating_sub(content_height)) / 2; let chunks = Layout::default() .direction(Direction::Vertical) .constraints([Constraint::Min(7), Constraint::Length(3)]) - .margin(margin) - .split(size); + .split(Rect { + x: horizontal_margin, + y: vertical_margin, + width: content_width, + height: content_height, + }); let eula_text = if size.width < 76 { "EULA ¹ (https://docs.tensamin.net/legal/eula/)" } else { @@ -222,25 +229,25 @@ fn run_consent_ui() -> UserChoice { }; let (mut optional_lines, agree_lines): (Vec, Vec<&str>) = - if size.width > 131 { + if size.width > 132 { ( vec![7, 3, 4], vec![ "", - "By selecting Continue, you confirm that you have read and agree to the End User License Agreement and applicable Terms of Service", + "By selecting Continue, you confirm that you have read and agree to the End User License Agreement and applicable Terms of Service.", "", "Tensamin services require acceptance of the Terms of Service and Privacy Policy.", ] ) - } else if size.width > 67 { + } else if size.width > 68 { ( vec![8, 3, 4], vec![ "", "By selecting Continue, you confirm that you have read and agree", - "to the End User License Agreement and applicable Terms of Service", + "to the End User License Agreement and applicable Terms of Service.", "", - "Tensamin services require acceptance of the ToS and Privacy Policy", + "Tensamin services require acceptance of the ToS and Privacy Policy.", ] ) } else { @@ -250,10 +257,10 @@ fn run_consent_ui() -> UserChoice { "", "By selecting Continue, you confirm that you have", "read and agree to the End User License Agreement", - "and applicable Terms of Service", + "and applicable Terms of Service.", "", "Tensamin services require acceptance of the", - "Terms of Service and Privacy Policy" + "Terms of Service and Privacy Policy." ] ) }; @@ -291,7 +298,7 @@ fn run_consent_ui() -> UserChoice { let height_style = if size.height < needed_height as u16 { Style::default().fg(Color::Red) - } else if size.height >= 11 { + } else if size.height < 17 { Style::default().fg(Color::Yellow) } else { Style::default().fg(Color::Green) @@ -368,10 +375,7 @@ fn run_consent_ui() -> UserChoice { } } }; - - disable_raw_mode().unwrap(); - execute!(terminal.backend_mut(), LeaveAlternateScreen).unwrap(); - terminal.show_cursor().unwrap(); + ratatui::restore(); result } diff --git a/src/gui/input_handler.rs b/src/gui/input_handler.rs index 5a59837..c46a19f 100644 --- a/src/gui/input_handler.rs +++ b/src/gui/input_handler.rs @@ -2,7 +2,6 @@ use std::time::Duration; use crate::ACTIVE_TASKS; use crate::{RELOAD, SHUTDOWN, gui::tui::UNIQUE, util::config_util::CONFIG}; -// Switched to poll/read which are available by default in crossterm use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers, poll, read}; use json::JsonValue; @@ -48,6 +47,9 @@ pub fn setup_input_handler() { pub async fn handle_input(key: KeyEvent) { match (key.code, key.modifiers) { + (KeyCode::Char('q'), KeyModifiers::CONTROL) => { + *SHUTDOWN.write().await = true; + } (KeyCode::Char('c'), KeyModifiers::CONTROL) => { *SHUTDOWN.write().await = true; } @@ -67,7 +69,7 @@ pub async fn handle_input(key: KeyEvent) { let password: &str = &password; let password = match password.char_indices().next_back() { Some((i, _)) => &password[..i], - None => password, + _ => password, }; CONFIG diff --git a/src/gui/settings_panel.rs b/src/gui/settings_panel.rs index 1555b7e..2838adc 100644 --- a/src/gui/settings_panel.rs +++ b/src/gui/settings_panel.rs @@ -6,6 +6,7 @@ use ratatui::{ }; use crate::gui::app_state::AppState; + pub fn draw(frame: &mut Frame, area: Rect, block: Block, password: String, _state: AppState) { frame.render_widget(block, area); @@ -14,16 +15,29 @@ pub fn draw(frame: &mut Frame, area: Rect, block: Block, password: String, _stat vertical: 1, }); + let info = vec![ + "This is the technical end of your Iota", + "Press Ctrl+Q to quit", + "Press Ctrl+R to reload", + "Select a password for the WebUI", + ]; + let mut constraints: Vec = Vec::new(); + + for _ in 0..info.len() { + constraints.push(Constraint::Length(1)); + } + + constraints.push(Constraint::Length(3)); + let chunks = Layout::default() .direction(Direction::Vertical) - .constraints([ - Constraint::Length(3), - Constraint::Length(3), - Constraint::Length(3), - ]) + .constraints(constraints) .split(padded); - let prefix = Span::raw(format!("select password : {}", password)); + for i in 0..info.len() { + frame.render_widget(Paragraph::new(info[i]), chunks[i]); + } - frame.render_widget(Paragraph::new(prefix), chunks[0]); + let prefix = Span::raw(format!("select password : {}", password)); + frame.render_widget(Paragraph::new(prefix), chunks[info.len()]); } diff --git a/src/gui/tui.rs b/src/gui/tui.rs index 064b63b..c021e57 100644 --- a/src/gui/tui.rs +++ b/src/gui/tui.rs @@ -1,7 +1,6 @@ use std::{ - io::{Stdout, stdout}, + io::{Stdout, Write, stdout}, sync::Arc, - thread, time::Duration, }; @@ -11,12 +10,14 @@ use crate::{ util::config_util::CONFIG, }; use crossterm::{ + cursor::Show, execute, - terminal::{EnterAlternateScreen, enable_raw_mode}, + terminal::{EnterAlternateScreen, LeaveAlternateScreen, enable_raw_mode}, }; use once_cell::sync::Lazy; use ratatui::{ Frame, Terminal, + crossterm::terminal::disable_raw_mode, layout::{Constraint, Direction, Layout, Rect}, prelude::CrosstermBackend, style::Color, @@ -30,46 +31,27 @@ use tokio::{ sync::{Mutex, RwLock}, }; -// ****** UTIL ****** -fn init_terminal() { - let mut stdout = stdout(); - execute!(stdout, EnterAlternateScreen).unwrap(); - enable_raw_mode().unwrap(); -} - -// ****** MAIN ****** pub static UNIQUE: Lazy> = Lazy::new(|| RwLock::new(true)); -pub static TERMINAL: Lazy>>>> = Lazy::new(|| { - Arc::new(Mutex::new( - Terminal::new(CrosstermBackend::new(stdout())).unwrap(), - )) -}); +pub static TERMINAL: Lazy>>>> = + Lazy::new(|| Arc::new(Mutex::new(ratatui::init()))); pub fn start_tui() { tokio::spawn(async move { - init_terminal(); - - { - ACTIVE_TASKS.lock().unwrap().push("UI".to_string()); - } loop { if *SHUTDOWN.read().await { break; } + if *UNIQUE.read().await { render_tui().await; } else { - thread::sleep(Duration::from_millis(50)); + tokio::time::sleep(Duration::from_millis(50)).await; } } - { - ACTIVE_TASKS - .lock() - .unwrap() - .retain(|t| !t.eq(&"UI".to_string())); - } + ratatui::restore(); }); } + pub async fn render_tui() { let password = CONFIG .read() @@ -78,123 +60,116 @@ pub async fn render_tui() { .as_str() .unwrap_or("") .to_string(); - TERMINAL - .lock() - .await - .draw(|f| { - let area = f.area(); - let chunks = Layout::default() - .direction(Direction::Horizontal) + + let mut terminal = TERMINAL.lock().await; + let _ = terminal.draw(|f| { + let area = f.area(); + let chunks = Layout::default() + .direction(Direction::Horizontal) + .constraints([ + Constraint::Percentage(40), + Constraint::Percentage(60), + Constraint::Min(40), + ]) + .split(area); + + let state = APP_STATE.lock().unwrap().clone(); + + // LOGS PANEL + { + let items: Vec = state + .logs + .iter() + .rev() + .map(|s| ListItem::new(s.clone())) + .collect(); + let list = List::new(items).block( + Block::default() + .title("Logs") + .borders(Borders::LEFT.union(Borders::TOP).union(Borders::BOTTOM)), + ); + f.render_widget(list, chunks[0]); + } + // SETTINGS PANEL + { + settings_panel::draw( + f, + chunks[1], + Block::default() + .title("Settings") + .borders(Borders::LEFT.union(Borders::TOP).union(Borders::BOTTOM)), + password, + state.clone(), + ); + draw_block_joins( + f, + chunks[1], + Borders::TOP.union(Borders::LEFT).union(Borders::BOTTOM), + Borders::LEFT, + ); + } + // PERFORMANCE GRAPHS + { + let stack = Layout::default() + .direction(Direction::Vertical) .constraints([ - Constraint::Percentage(40), - Constraint::Percentage(60), - Constraint::Max(40), + Constraint::Ratio(1, 3), + Constraint::Ratio(1, 3), + Constraint::Ratio(1, 3), ]) - .constraints([ - Constraint::Percentage(40), - Constraint::Percentage(60), - Constraint::Min(40), - ]) - .split(area); - let state; - { - state = APP_STATE.lock().unwrap().clone(); - } - // LOGS - { - let items: Vec = state - .logs - .iter() - .rev() - .map(|s| ListItem::new(s.clone())) - .collect(); - let list = List::new(items).block( - Block::default() - .title("Logs") - .borders(Borders::LEFT.union(Borders::TOP).union(Borders::BOTTOM)), - ); - f.render_widget(list, chunks[0]); - } - // SETTINGS - { - settings_panel::draw( - f, - chunks[1], - Block::default() - .title("Settings") - .borders(Borders::LEFT.union(Borders::TOP).union(Borders::BOTTOM)), - password, - state.clone(), - ); - draw_block_joins( - f, - chunks[1], - Borders::TOP.union(Borders::LEFT).union(Borders::BOTTOM), - Borders::LEFT, - ); - } - // GRAPHS - { - let stack = Layout::default() - .direction(Direction::Vertical) - .constraints( - [ - Constraint::Ratio(1, 3), - Constraint::Ratio(1, 3), - Constraint::Ratio(1, 3), - ] - .as_ref(), - ) - .split(chunks[2]); - render_graphs( - f, - stack[0], - "CPU".to_string(), - "%".to_string(), - state.with_width(38).cpu, - Borders::TOP.union(Borders::LEFT).union(Borders::RIGHT), - Color::Cyan, - ); - draw_block_joins( - f, - stack[0], - Borders::TOP.union(Borders::LEFT), - Borders::LEFT, - ); - render_graphs( - f, - stack[1], - "RAM".to_string(), - "%".to_string(), - state.with_width(38).ram, - Borders::TOP.union(Borders::LEFT).union(Borders::RIGHT), - Color::Green, - ); - draw_block_joins( - f, - stack[1], - Borders::TOP.union(Borders::LEFT).union(Borders::RIGHT), - Borders::TOP, - ); - render_graphs( - f, - stack[2], - "PING".to_string(), - "ms".to_string(), - state.with_width(38).ping, - Borders::ALL, - Color::Magenta, - ); - draw_block_joins(f, stack[2], Borders::ALL, Borders::TOP); - draw_block_joins( - f, - stack[2], - Borders::BOTTOM.union(Borders::LEFT), - Borders::LEFT, - ); - } - }) - .unwrap(); + .split(chunks[2]); + + render_graphs( + f, + stack[0], + "CPU".into(), + "%".into(), + state.with_width(38).cpu, + Borders::TOP.union(Borders::LEFT).union(Borders::RIGHT), + Color::Cyan, + ); + draw_block_joins( + f, + stack[0], + Borders::TOP.union(Borders::LEFT), + Borders::LEFT, + ); + + render_graphs( + f, + stack[1], + "RAM".into(), + "%".into(), + state.with_width(38).ram, + Borders::TOP.union(Borders::LEFT).union(Borders::RIGHT), + Color::Green, + ); + draw_block_joins( + f, + stack[1], + Borders::TOP.union(Borders::LEFT).union(Borders::RIGHT), + Borders::TOP, + ); + + render_graphs( + f, + stack[2], + "PING".into(), + "ms".into(), + state.with_width(38).ping, + Borders::ALL, + Color::Magenta, + ); + draw_block_joins(f, stack[2], Borders::ALL, Borders::TOP); + draw_block_joins( + f, + stack[2], + Borders::BOTTOM.union(Borders::LEFT), + Borders::LEFT, + ); + } + }); + *UNIQUE.write().await = false; } @@ -216,16 +191,18 @@ pub fn render_graphs( .min_by(|a, b| a.total_cmp(b)) .unwrap_or(0.0); let max_y = graph.iter().map(|(_, y)| *y).fold(f64::MIN, f64::max); + let block = Block::default() .title(format!( "─{}:─{}{}──{}/{}─MIN/MAX", title, - graph.last().unwrap_or(&(0.0 as f64, 0.0 as f64)).1 as i64, + graph.last().unwrap_or(&(0.0, 0.0)).1 as i64, unit, min_y as i64, max_y as i64 )) .borders(borders); + let canvas = Canvas::default() .block(block) .x_bounds([min_x, max_x])