From 03c87a8df0de0c41ade5064b20832bc90b63c6c8 Mon Sep 17 00:00:00 2001 From: 72-S Date: Sat, 26 Apr 2025 16:47:12 +0200 Subject: [PATCH] fix(tui): fix popup dimensions --- Cargo.lock | 378 +++++--- repomix-output.xml | 1196 ++++++++++++++++++++++++ src/tui/widgets/popups/new_instance.rs | 9 +- src/tui/widgets/profiles.rs | 8 +- 4 files changed, 1430 insertions(+), 161 deletions(-) create mode 100644 repomix-output.xml diff --git a/Cargo.lock b/Cargo.lock index e64a765..6eebe01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,18 +23,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "aligned-vec" version = "0.5.0" @@ -123,9 +111,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "arbitrary" @@ -158,9 +146,9 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "async-trait" -version = "0.1.86" +version = "0.1.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" +checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", @@ -231,9 +219,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" dependencies = [ "serde", ] @@ -300,9 +288,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.14" +version = "1.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9" +checksum = "04da6a0d40b948dfc4fa8f5bbf402b0fc1a64a28dbf7d12ffd683550f2c1b63a" dependencies = [ "jobserver", "libc", @@ -327,23 +315,23 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.39" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets", + "windows-link", ] [[package]] name = "clap" -version = "4.5.29" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acebd8ad879283633b343856142139f2da2317c96b05b4dd6181c61e2480184" +checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" dependencies = [ "clap_builder", "clap_derive", @@ -351,9 +339,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.29" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ba32cbda51c7e1dfd49acc1457ba1a7dec5b64fe360e828acb13ca8dc9c2f9" +checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" dependencies = [ "anstream", "anstyle", @@ -363,9 +351,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.28" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed" +checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" dependencies = [ "heck", "proc-macro2", @@ -443,9 +431,9 @@ dependencies = [ [[package]] name = "config" -version = "0.15.8" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf9dc8d4ef88e27a8cb23e85cb116403dedd57f7971964dc4b18ccead548901" +checksum = "595aae20e65c3be792d05818e8c63025294ac3cb7e200f11459063a352a6ef80" dependencies = [ "async-trait", "convert_case", @@ -475,7 +463,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ - "getrandom", + "getrandom 0.2.16", "once_cell", "tiny-keccak", ] @@ -544,7 +532,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "crossterm_winapi", "mio", "parking_lot", @@ -581,9 +569,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.10" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" dependencies = [ "darling_core", "darling_macro", @@ -591,9 +579,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.10" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" dependencies = [ "fnv", "ident_case", @@ -605,9 +593,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.10" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", @@ -656,9 +644,9 @@ dependencies = [ [[package]] name = "either" -version = "1.13.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "encoding_rs" @@ -677,9 +665,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", "windows-sys 0.59.0", @@ -694,7 +682,7 @@ dependencies = [ "bit_field", "half", "lebe", - "miniz_oxide 0.8.5", + "miniz_oxide 0.8.8", "rayon-core", "smallvec", "zune-inflate", @@ -721,12 +709,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc" +checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" dependencies = [ "crc32fast", - "miniz_oxide 0.8.5", + "miniz_oxide 0.8.8", ] [[package]] @@ -743,9 +731,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] name = "generic-array" @@ -759,13 +747,25 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", ] [[package]] @@ -786,9 +786,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "half" -version = "2.4.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" dependencies = [ "cfg-if", "crunchy", @@ -799,9 +799,6 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] [[package]] name = "hashbrown" @@ -816,11 +813,11 @@ dependencies = [ [[package]] name = "hashlink" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" dependencies = [ - "hashbrown 0.14.5", + "hashbrown 0.15.2", ] [[package]] @@ -831,14 +828,15 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "iana-time-zone" -version = "0.1.61" +version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", + "log", "wasm-bindgen", "windows-core", ] @@ -878,9 +876,9 @@ dependencies = [ [[package]] name = "image" -version = "0.25.5" +version = "0.25.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b" +checksum = "db35664ce6b9810857a38a906215e75a9c879f0696556a39f59c62829710251a" dependencies = [ "bytemuck", "byteorder-lite", @@ -923,9 +921,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.7.1" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", "hashbrown 0.15.2", @@ -933,9 +931,9 @@ dependencies = [ [[package]] name = "indoc" -version = "2.0.5" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" +checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd" [[package]] name = "instability" @@ -987,16 +985,17 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jobserver" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ + "getrandom 0.3.2", "libc", ] @@ -1044,9 +1043,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "libfuzzer-sys" @@ -1064,7 +1063,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "libc", ] @@ -1086,9 +1085,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.25" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "loop9" @@ -1130,7 +1129,7 @@ dependencies = [ "crossterm", "dirs-next", "fmt", - "image 0.25.5", + "image 0.25.6", "lazy_static", "once_cell", "rascii_art", @@ -1162,9 +1161,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.5" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" dependencies = [ "adler2", "simd-adler32", @@ -1178,7 +1177,7 @@ checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] @@ -1265,9 +1264,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.3" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "ordered-multimap" @@ -1322,20 +1321,20 @@ checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" [[package]] name = "pest" -version = "2.7.15" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" +checksum = "198db74531d58c70a361c42201efde7e2591e976d518caf7662a47dc5720e7b6" dependencies = [ "memchr", - "thiserror 2.0.11", + "thiserror 2.0.12", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.7.15" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816518421cfc6887a0d62bf441b6ffb4536fcc926395a69e1a85852d4363f57e" +checksum = "d725d9cfd79e87dccc9341a2ef39d1b6f6353d68c4b33c177febbe1a402c97c5" dependencies = [ "pest", "pest_generator", @@ -1343,9 +1342,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.15" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d1396fd3a870fc7838768d171b4616d5c91f6cc25e377b673d714567d99377b" +checksum = "db7d01726be8ab66ab32f9df467ae8b1148906685bbe75c82d1e65d7f5b3f841" dependencies = [ "pest", "pest_meta", @@ -1356,9 +1355,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.15" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1e58089ea25d717bfd31fb534e4f3afcc2cc569c70de3e239778991ea3b7dea" +checksum = "7f9f832470494906d1fca5329f8ab5791cc60beb230c74815dff541cbd2b5ca0" dependencies = [ "once_cell", "pest", @@ -1387,23 +1386,23 @@ dependencies = [ "crc32fast", "fdeflate", "flate2", - "miniz_oxide 0.8.5", + "miniz_oxide 0.8.8", ] [[package]] name = "ppv-lite86" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ "zerocopy", ] [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -1444,13 +1443,19 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quote" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "rand" version = "0.8.5" @@ -1478,7 +1483,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.16", ] [[package]] @@ -1499,7 +1504,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "cassowary", "compact_str", "crossterm", @@ -1551,9 +1556,9 @@ dependencies = [ [[package]] name = "ravif" -version = "0.11.11" +version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2413fd96bd0ea5cdeeb37eaf446a22e6ed7b981d792828721e74ded1980a45c6" +checksum = "d6a5f31fcf7500f9401fea858ea4ab5525c99f2322cfcee732c0e6c74208c0c6" dependencies = [ "avif-serialize", "imgref", @@ -1586,11 +1591,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.8" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] [[package]] @@ -1599,7 +1604,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom", + "getrandom 0.2.16", "libredox", "thiserror 1.0.69", ] @@ -1617,7 +1622,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ "base64", - "bitflags 2.8.0", + "bitflags 2.9.0", "serde", "serde_derive", ] @@ -1645,7 +1650,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "errno", "libc", "linux-raw-sys", @@ -1654,15 +1659,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "scopeguard" @@ -1672,18 +1677,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -1692,9 +1697,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.138" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -1760,9 +1765,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.2" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" dependencies = [ "libc", ] @@ -1784,9 +1789,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] name = "static_assertions" @@ -1824,9 +1829,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.98" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -1863,11 +1868,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.11", + "thiserror-impl 2.0.12", ] [[package]] @@ -1883,9 +1888,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", @@ -1924,9 +1929,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" +checksum = "900f6c86a685850b1bc9f6223b20125115ee3f31e01207d81655bbcc0aea9231" dependencies = [ "serde", "serde_spanned", @@ -1936,18 +1941,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.24" +version = "0.22.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" +checksum = "10558ed0bd2a1562e630926a2d1f0b98c827da99fabd3fe20920a59642504485" dependencies = [ "indexmap", "serde", @@ -2005,9 +2010,9 @@ checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc" [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "ucd-trie" @@ -2017,9 +2022,9 @@ checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-ident" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-segmentation" @@ -2091,6 +2096,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.100" @@ -2179,11 +2193,61 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-core" -version = "0.52.0" +version = "0.61.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" dependencies = [ - "windows-targets", + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" + +[[package]] +name = "windows-result" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" +dependencies = [ + "windows-link", ] [[package]] @@ -2270,18 +2334,27 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.2" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" +checksum = "6cb8234a863ea0e8cd7284fcdd4f145233eb00fee02bbdd9861aec44e6477bc5" dependencies = [ "memchr", ] [[package]] -name = "yaml-rust2" -version = "0.9.0" +name = "wit-bindgen-rt" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a1a1c0bc9823338a3bdf8c61f994f23ac004c6fa32c08cd152984499b445e8d" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.9.0", +] + +[[package]] +name = "yaml-rust2" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "818913695e83ece1f8d2a1c52d54484b7b46d0f9c06beeb2649b9da50d9b512d" dependencies = [ "arraydeque", "encoding_rs", @@ -2290,19 +2363,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.35" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" dependencies = [ - "byteorder", "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.35" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" dependencies = [ "proc-macro2", "quote", diff --git a/repomix-output.xml b/repomix-output.xml new file mode 100644 index 0000000..da81c5f --- /dev/null +++ b/repomix-output.xml @@ -0,0 +1,1196 @@ +This file is a merged representation of the entire codebase, combined into a single document by Repomix. + + +This section contains a summary of this file. + + +This file contains a packed representation of the entire repository's contents. +It is designed to be easily consumable by AI systems for analysis, code review, +or other automated processes. + + + +The content is organized as follows: +1. This summary section +2. Repository information +3. Directory structure +4. Repository files (if enabled) +4. Repository files, each consisting of: + - File path as an attribute + - Full contents of the file + + + +- This file should be treated as read-only. Any changes should be made to the + original repository files, not this packed version. +- When processing this file, use the file path to distinguish + between different files in the repository. +- Be aware that this file may contain sensitive information. Handle it with + the same level of security as you would the original repository. + + + +- Some files may have been excluded based on .gitignore rules and Repomix's configuration +- Binary files are not included in this packed representation. Please refer to the Repository Structure section for a complete list of file paths, including binary files +- Files matching patterns in .gitignore are excluded +- Files matching default ignore patterns are excluded +- Files are sorted by Git change count (files with more changes are at the bottom) + + + + + + + + + +assets/ + default.toml +src/ + config/ + mod.rs + types.rs + tui/ + widgets/ + popups/ + base.rs + mod.rs + new_instance.rs + account.rs + content.rs + details.rs + mod.rs + profiles.rs + status.rs + layout.rs + mod.rs + cli.rs + logger.rs + macros.rs + main.rs +.gitignore +Cargo.toml + + + +This section contains the contents of the repository's files. + + +use ratatui::{ + buffer::Buffer, + layout::Rect, + style::Style, + text::Line, + widgets::{Block, Borders, Clear, Widget}, +}; + +pub struct Popup<'a> { + pub title: Line<'a>, + pub border_style: Style, + pub title_style: Style, + pub style: Style, + pub content: Box, +} + +impl<'a> Widget for Popup<'a> { + fn render(self, area: Rect, buf: &mut Buffer) { + Clear.render(area, buf); + + let block = Block::new() + .title(self.title) + .title_style(self.title_style) + .borders(Borders::ALL) + .border_style(self.border_style); + + let inner_area = block.inner(area); + block.render(area, buf); + + (self.content)(inner_area, buf); + } +} + + + +pub mod base; +pub mod new_instance; + + + +use super::base::Popup; +use crate::tui::layout::FocusedArea; +use crate::tui::widgets::profiles; +use crossterm::event::KeyCode; +use ratatui::{ + Frame, + layout::{Rect, Layout, Direction, Constraint}, + text::{Line, Span}, + widgets::{Block, Borders, Paragraph, Wrap, Widget}, +}; +use once_cell::sync::Lazy; +use std::sync::Mutex; + +static INSTANCE_POPUP_STATE: Lazy> = Lazy::new(|| Mutex::new(NewInstanceState::default())); + +#[derive(Debug, Default)] +enum NewInstanceMode { + #[default] + Buttons, + Input, +} + +#[derive(Debug, Default)] +struct NewInstanceState { + mode: NewInstanceMode, + input_text: String, +} + +pub fn render(frame: &mut Frame, area: Rect, _focused: FocusedArea) { + let state = INSTANCE_POPUP_STATE.lock().unwrap(); + + let popup = Popup { + title: Line::from("New Instance"), + content: Box::new(move |area, buf| { + match state.mode { + NewInstanceMode::Buttons => { + let chunks = Layout::default() + .direction(Direction::Vertical) + .constraints([ + Constraint::Percentage(40), + Constraint::Length(3), + Constraint::Length(3), + Constraint::Percentage(40), + ]) + .split(area); + + let create_button = Paragraph::new(Line::from(vec![ + Span::styled("[C]", ratatui::style::Style::default().add_modifier(ratatui::style::Modifier::BOLD)), + Span::raw("reate New Instance"), + ])).alignment(ratatui::layout::Alignment::Center); + + let import_button = Paragraph::new(Line::from(vec![ + Span::styled("[I]", ratatui::style::Style::default().add_modifier(ratatui::style::Modifier::BOLD)), + Span::raw("mport Morinth Modpack"), + ])).alignment(ratatui::layout::Alignment::Center); + + create_button.render(chunks[1], buf); + import_button.render(chunks[2], buf); + } + NewInstanceMode::Input => { + let paragraph = Paragraph::new(state.input_text.clone()) + .block(Block::default().title("Enter URL or Path").borders(Borders::ALL)) + .wrap(Wrap { trim: true }); + + paragraph.render(area, buf); + } + } + }), + border_style: Default::default(), + title_style: Default::default(), + style: Default::default(), + }; + + frame.render_widget(popup, area); +} + +pub fn handle_key(key_event: &crossterm::event::KeyEvent, state: &mut profiles::State) { + let mut popup_state = INSTANCE_POPUP_STATE.lock().unwrap(); + + match popup_state.mode { + NewInstanceMode::Buttons => { + match key_event.code { + KeyCode::Char('q') => { + state.show_popup = false; + } + KeyCode::Char('c') => { + // Create new instance + state.show_popup = false; + } + KeyCode::Char('i') => { + // Switch to input mode + popup_state.mode = NewInstanceMode::Input; + } + _ => {} + } + } + NewInstanceMode::Input => match key_event.code { + KeyCode::Esc => { + popup_state.mode = NewInstanceMode::Buttons; + } + KeyCode::Enter => { + // Confirm input + state.show_popup = false; + } + KeyCode::Char(c) => { + popup_state.input_text.push(c); + } + KeyCode::Backspace => { + popup_state.input_text.pop(); + } + _ => {} + }, + } +} + + + +use ratatui::{ + layout::Rect, + style::{Color, Style}, + widgets::{Block, BorderType, Borders, Paragraph}, + Frame, +}; + +use crate::tui::layout::FocusedArea; + +use super::styled_title; + +pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea) { + let color = if focused == FocusedArea::Account { + Color::White + } else { + Color::DarkGray + }; + + let block = Block::default() + .title(styled_title("Account", true)) + .borders(Borders::ALL) + .border_type(BorderType::Rounded) + .border_style(Style::default().fg(color)); + + let widget = Paragraph::new("TEST CONTENT").block(block); + frame.render_widget(widget, area); +} + + + +use ratatui::{ + layout::Rect, + style::{Color, Style}, + widgets::{Block, BorderType, Borders, Paragraph}, + Frame, +}; + +use crate::tui::layout::FocusedArea; + +use super::styled_title; + +pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea) { + let color = if focused == FocusedArea::Content { + Color::White + } else { + Color::DarkGray + }; + + let block = Block::default() + .title(styled_title("Content", true)) + .borders(Borders::ALL) + .border_type(BorderType::Rounded) + .border_style(Style::default().fg(color)); + + let widget = Paragraph::new("TEST CONTENT").block(block); + frame.render_widget(widget, area); +} + +pub fn title(frame: &mut Frame, area: Rect, focused: FocusedArea) { + let color = if focused == FocusedArea::Content { + Color::White + } else { + Color::DarkGray + }; + + let block = Block::default() + .title(styled_title("Title", false)) + .borders(Borders::ALL) + .border_type(BorderType::Rounded) + .border_style(Style::default().fg(color)); + + let widget = Paragraph::new("TEST CONTENT").block(block); + frame.render_widget(widget, area); +} + + + +use ratatui::{ + layout::Rect, + style::{Color, Style}, + widgets::{Block, BorderType, Borders, Paragraph}, + Frame, +}; + +use crate::tui::layout::FocusedArea; + +use super::styled_title; + +pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea) { + let color = if focused == FocusedArea::Details { + Color::White + } else { + Color::DarkGray + }; + + let block = Block::default() + .title(styled_title("Details", true)) + .borders(Borders::ALL) + .border_type(BorderType::Rounded) + .border_style(Style::default().fg(color)); + + let widget = Paragraph::new("TEST CONTENT").block(block); + frame.render_widget(widget, area); +} + + + +use ratatui::{ + layout::Rect, + style::{Color, Style}, + widgets::{Block, BorderType, Borders, Paragraph}, + Frame, +}; + +use crate::tui::layout::FocusedArea; + +use super::styled_title; + +pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea) { + let color = if focused == FocusedArea::Status { + Color::White + } else { + Color::DarkGray + }; + + let block = Block::default() + .title(styled_title("Status", true)) + .borders(Borders::ALL) + .border_type(BorderType::Rounded) + .border_style(Style::default().fg(color)); + + let widget = Paragraph::new("TEST CONTENT").block(block); + frame.render_widget(widget, area); +} + + + +#[macro_export] +macro_rules! debug { + ($msg:expr) => { + $crate::logger::get_logger().debug($msg); + }; + ($fmt:expr, $($arg:tt)*) => { + $crate::logger::get_logger().debug(&format!($fmt, $($arg)*)); + }; +} + +#[macro_export] +macro_rules! info { + ($msg:expr) => { + $crate::logger::get_logger().info($msg); + }; + ($fmt:expr, $($arg:tt)*) => { + $crate::logger::get_logger().info(&format!($fmt, $($arg)*)); + }; +} + +#[macro_export] +macro_rules! error { + ($msg:expr) => { + $crate::logger::get_logger().error($msg); + }; + ($fmt:expr, $($arg:tt)*) => { + $crate::logger::get_logger().error(&format!($fmt, $($arg)*)); + }; +} + + + +/target + + + +use serde::{Deserialize, Deserializer}; +use ratatui::style::Color; +use crate::error; + +#[derive(Debug, Deserialize)] +pub struct General { + pub debug: bool, +} + +#[derive(Debug, Deserialize)] +pub struct Colors { + #[serde(deserialize_with = "deserialize_color")] + pub background: Color, // General background color + + #[serde(deserialize_with = "deserialize_color")] + pub foreground: Color, // General text color + + #[serde(deserialize_with = "deserialize_color")] + pub border_focused: Color, // Border color for focused areas + + #[serde(deserialize_with = "deserialize_color")] + pub border_unfocused: Color, // Border color for unfocused areas + + #[serde(deserialize_with = "deserialize_color")] + pub row_highlight: Color, // Highlighted row color + + #[serde(deserialize_with = "deserialize_color")] + pub row_background: Color, // Row background color + + #[serde(deserialize_with = "deserialize_color")] + pub row_alternate_bg: Color, // Alternate row background color +} + +#[derive(Debug, Deserialize)] +pub struct Config { + pub general: General, + pub colors: Colors, +} + + +pub fn parse_color(color: &str) -> Color { + match color.to_lowercase().as_str() { + "black" => Color::Black, + "red" => Color::Red, + "green" => Color::Green, + "yellow" => Color::Yellow, + "blue" => Color::Blue, + "magenta" => Color::Magenta, + "cyan" => Color::Cyan, + "white" => Color::White, + "gray" | "grey" => Color::Gray, + "darkgray" | "darkgrey" => Color::DarkGray, + "lightred" => Color::LightRed, + "lightgreen" => Color::LightGreen, + "lightyellow" => Color::LightYellow, + "lightblue" => Color::LightBlue, + "lightmagenta" => Color::LightMagenta, + "lightcyan" => Color::LightCyan, + "reset" => Color::Reset, + hex if hex.starts_with('#') && hex.len() == 7 => { + let r = u8::from_str_radix(&hex[1..3], 16).unwrap_or_else(|_| { + error!("Invalid hex color format: {}", color); + 255 + }); + let g = u8::from_str_radix(&hex[3..5], 16).unwrap_or_else(|_| { + error!("Invalid hex color format: {}", color); + 255 + }); + let b = u8::from_str_radix(&hex[5..7], 16).unwrap_or_else(|_| { + error!("Invalid hex color format: {}", color); + 255 + }); + Color::Rgb(r, g, b) + } + _ => { + error!("Invalid color name or hex value: {}", color); + panic!("Invalid config"); + } + } +} + + + +fn deserialize_color<'de, D>(deserializer: D) -> Result +where + D: Deserializer<'de>, +{ + let color_str: String = Deserialize::deserialize(deserializer)?; + Ok(parse_color(&color_str)) +} + + + +use crossterm::event::KeyCode; +use ratatui::{ + layout::{Constraint, Rect}, + style::{Modifier, Style}, + text::Text, + widgets::{ + Block, BorderType, Borders, Cell, Row, Scrollbar, ScrollbarOrientation, ScrollbarState, + Table, TableState, + }, + Frame, +}; + +use crate::{config::SETTINGS, tui::layout::FocusedArea}; + +use super::{popups, styled_title, WidgetKey}; + +#[derive(Debug, Default)] +pub struct State { + pub profiles: Vec, + pub table_state: TableState, + pub scrollbar_state: ScrollbarState, + pub show_popup: bool, +} + +#[derive(Debug, Default)] +pub struct Data { + pub title: String, + pub id: String, + pub running: bool, +} + +impl State { + fn next(&mut self) { + let i = match self.table_state.selected() { + Some(i) => { + if i >= self.profiles.len().saturating_sub(1) { + 0 + } else { + i + 1 + } + } + _none => 0, + }; + self.table_state.select(Some(i)); + self.update_scrollbar(); + } + + fn previous(&mut self) { + let i = match self.table_state.selected() { + Some(i) => { + if i == 0 { + self.profiles.len().saturating_sub(1) + } else { + i - 1 + } + } + _none => 0, + }; + self.table_state.select(Some(i)); + self.update_scrollbar(); + } + + fn update_scrollbar(&mut self) { + let items = self.profiles.len().saturating_sub(1); + let index = self.table_state.selected().unwrap_or(0); + + if self.profiles.is_empty() { + self.table_state.select(None); + } else if self.table_state.selected().is_none() { + self.table_state.select(Some(0)); + } else if index > items { + self.table_state.select(Some(items)); + } + + self.scrollbar_state = ScrollbarState::new(items).position(index); + } + + pub fn wants_popup(&self) -> bool { + self.show_popup + } +} + +impl WidgetKey for State { + fn handle_key(&mut self, key_event: &crossterm::event::KeyEvent) { + match key_event.code { + KeyCode::Char('a') => { + self.show_popup = true; + self.update_scrollbar(); + } + KeyCode::Char('d') => { + self.profiles.clear(); + self.update_scrollbar(); + } + KeyCode::Char('j') | KeyCode::Down => self.next(), + KeyCode::Char('k') | KeyCode::Up => self.previous(), + _ => {} + } + } +} + +pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea, state: &mut State) { + let color = if focused == FocusedArea::Profiles { + SETTINGS.colors.border_focused + } else { + SETTINGS.colors.border_unfocused + }; + + let block = Block::default() + .title(styled_title("Profiles", true)) + .borders(Borders::ALL) + .border_type(BorderType::Rounded) + .border_style(Style::default().fg(color)); + + frame.render_widget(&block, area); + + let scrollbar_area = Rect { + x: area.x + area.width.saturating_sub(1), + y: area.y + 1, + width: 1, + height: area.height.saturating_sub(2), + }; + + let table_area = block.inner(area); + + let rows = state.profiles.iter().enumerate().map(|(i, data)| { + let status = if data.running { "Running" } else { "Stopped" }; + + let background_color = if i % 2 == 0 { + SETTINGS.colors.row_background + } else { + SETTINGS.colors.row_alternate_bg + }; + + Row::new(vec![ + Cell::from(Text::from(format!("\n{}\n", data.title))), + Cell::from(Text::from(format!("\n{}\n", data.id))), + Cell::from(Text::from(format!("\n{}\n", status))), + ]) + .height(4) + .style(Style::default().bg(background_color)) + }); + + let widths = [ + Constraint::Percentage(40), + Constraint::Percentage(30), + Constraint::Percentage(30), + ]; + + let table = Table::new(rows, widths) + .row_highlight_style( + Style::default() + .add_modifier(Modifier::REVERSED) + .fg(SETTINGS.colors.row_highlight), + ) + .highlight_spacing(ratatui::widgets::HighlightSpacing::Always); + + frame.render_stateful_widget(table, table_area, &mut state.table_state); + + frame.render_stateful_widget( + Scrollbar::default() + .orientation(ScrollbarOrientation::VerticalRight) + .begin_symbol(Some("▲")) + .style( + Style::default() + .fg(SETTINGS.colors.border_focused) + .add_modifier(Modifier::BOLD), + ) + .thumb_symbol("┃") + .track_symbol(Some("")) + .end_symbol(Some("▼")), + scrollbar_area, + &mut state.scrollbar_state, + ); + + if state.show_popup { + let popup_area = Rect { + x: area.width / 4, + y: area.height / 3, + width: area.width / 2, + height: area.height / 3, + }; + popups::new_instance::render(frame, popup_area, focused); + } +} + + + +use std::sync::Mutex; +use chrono::Local; +use color_eyre::owo_colors::OwoColorize; +use lazy_static::lazy_static; + +pub struct Logger { + debug: bool, +} + +impl Logger { + pub fn init(debug: bool) { + let mut logger = LOGGER.lock().unwrap(); + logger.debug = debug; + } + + fn timestamp() -> String { + Local::now().format("%Y-%m-%d %H:%M:%S").to_string() + } + + pub fn debug(&self, message: &str) { + if self.debug { + println!( + "{} {} {}", + Self::timestamp().dimmed(), + "[DEBUG]".cyan(), + message + ); + } + } + + pub fn info(&self, message: &str) { + println!( + "{} {} {}", + Self::timestamp().dimmed(), + "[INFO]".green(), + message + ); + } + + pub fn error(&self, message: &str) { + eprintln!( + "{} {} {}", + Self::timestamp().dimmed(), + "[ERROR]".red().bold(), + message + ); + } +} + +lazy_static! { + pub static ref LOGGER: Mutex = Mutex::new(Logger { debug: false }); +} + +pub fn get_logger() -> std::sync::MutexGuard<'static, Logger> { + LOGGER.lock().unwrap() +} + + + +use crossterm::event::KeyEvent; +use ratatui::{ + style::{Color, Style}, + text::{Line, Span}, +}; + +pub mod account; +pub mod content; +pub mod details; +pub mod profiles; +pub mod status; +pub mod popups; + +pub fn styled_title(title: &str, highlight: bool) -> Line { + if !highlight || title.is_empty() { + Line::from(Span::raw(title)) + } else { + let mut chars = title.chars(); + let first = chars.next().unwrap_or_default().to_string(); + let rest: String = chars.collect(); + Line::from(vec![ + Span::styled(first, Style::default().fg(Color::Yellow)), + Span::raw(rest), + ]) + } +} + +pub trait WidgetKey { + fn handle_key(&mut self, key_event: &KeyEvent); +} + + + +[general] +debug = false + +[colors] +background = "#1e1e1e" +foreground = "white" +border_focused = "white" +border_unfocused = "darkgray" +row_highlight = "yellow" +row_background = "darkgray" +row_alternate_bg = "#282828" + + + +use config::{Config as ConfigLoader, ConfigError, File}; +use dirs_next::config_dir; +use once_cell::sync::Lazy; +use std::fs; +use std::path::PathBuf; +use types::Config; + +use crate::debug; + +pub mod types; + +pub fn get_config_path() -> PathBuf { + let base_dir = config_dir().unwrap(); + base_dir.join("mcl/") +} + +fn ensure_config_exists(default_path: &str) -> PathBuf { + let config_path = get_config_path().join("config.toml"); + + if !config_path.exists() { + if let Some(parent_dir) = config_path.parent() { + fs::create_dir_all(parent_dir).expect("Failed to create configuration directory"); + } + + fs::copy(default_path, &config_path).expect("Failed to copy default configuration file"); + debug!("Default configuration copied to '{}'", config_path.display()); + } + + config_path +} + +pub fn load_config(config_path: &PathBuf) -> Result { + ConfigLoader::builder() + .add_source(File::from(config_path.clone())) + .build()? + .try_deserialize() +} + +pub static SETTINGS: Lazy = Lazy::new(|| { + let path: PathBuf = ensure_config_exists("assets/default.toml"); + load_config(&path).expect("Failed to load configuration") +}); + + + +use clap::{Arg, ArgAction, Command}; +use crate::{debug, tui}; + +pub fn init() { + let matches = Command::new("mcl") + .about("Minecraft CLI Launcher") + .version("1.0.0") + .subcommand_required(false) + .arg_required_else_help(false) + .subcommand( + Command::new("launch") + .about("Launch Minecraft with a specific profile") + .arg_required_else_help(true) + .arg( + Arg::new("profile") + .short('p') + .long("profile") + .help("Profile to launch (e.g., main)") + .required(true) + .action(ArgAction::Set), + ) + .arg( + Arg::new("offline") + .short('o') + .long("offline") + .help("Launch Minecraft in offline mode") + .action(ArgAction::SetTrue), + ) + .arg( + Arg::new("memory") + .short('m') + .long("memory") + .help("Set memory allocation for Minecraft (e.g., 4G, 512M)") + .action(ArgAction::Set), + ) + .arg( + Arg::new("resolution") + .short('r') + .long("resolution") + .help("Set screen resolution (e.g., 1920x1080)") + .action(ArgAction::Set), + ) + .arg( + Arg::new("jvm-args") + .short('j') + .long("jvm-args") + .help("Custom JVM arguments for Minecraft (e.g., -Xmx4G)") + .action(ArgAction::Set) + .num_args(1..), + ) + .arg( + Arg::new("no-window") + .short('n') + .long("no-window") + .help("Run Minecraft in headless mode (no graphical window)") + .action(ArgAction::SetTrue), + ), + ) + .subcommand( + Command::new("profiles") + .about("Manage Minecraft profiles") + .arg_required_else_help(true) + .arg( + Arg::new("list") + .short('l') + .long("list") + .help("List all available profiles") + .conflicts_with("delete") // Ensures list and delete are mutually exclusive + .action(ArgAction::SetTrue), + ) + .arg( + Arg::new("delete") + .short('d') + .long("delete") + .help("Delete a specific profile") + .action(ArgAction::Set), + ), + ) + .get_matches(); + + if matches.subcommand().is_none() { + tui::show().unwrap() + } + + match matches.subcommand() { + Some(("launch", launch_matches)) => { + let profile = launch_matches + .get_one::("profile") + .expect("Profile is required"); + + let mem_default = String::from("Default"); + let memory = launch_matches + .get_one::("memory") + .unwrap_or(&mem_default); + + let res_default = String::from("Default"); + let resolution = launch_matches + .get_one::("resolution") + .unwrap_or(&res_default); + + let jvm_args = launch_matches + .get_many::("jvm-args") + .map(|args| args.map(|s| s.as_str()).collect::>().join(" ")) + .unwrap_or_else(|| "None".to_string()); + + if launch_matches.get_flag("offline") { + debug!("Launching profile '{}' in offline mode...", profile); + } else { + debug!("Launching profile '{}' in online mode...", profile); + } + + debug!("Memory: {}", memory); + debug!("Resolution: {}", resolution); + debug!("JVM Args: {}", jvm_args); + + if launch_matches.get_flag("no-window") { + debug!("Running in headless mode..."); + } + } + Some(("profiles", profiles_matches)) => { + if profiles_matches.get_flag("list") { + debug!("Listing all profiles..."); + } else if let Some(profile) = profiles_matches.get_one::("delete") { + debug!("Deleting profile '{}'...", profile); + } + } + _ => {}, + } + +} + + + +use config::SETTINGS; +use logger::Logger; + +mod cli; +pub mod config; +pub mod logger; +pub mod macros; +pub mod tui; + +fn main() { + Logger::init(SETTINGS.general.debug); + cli::init() +} + + + +[package] +name = "mcl" +version = "0.1.0" +authors = ["72-S"] +edition = "2021" + +[dependencies] +clap = "4.5.27" +color-eyre = "0.6.3" +config = "0.15.6" +crossterm = "0.28.1" +dirs-next = "2.0.0" +ratatui = "0.29.0" +serde = { version = "1.0.217", features = ["derive"]} +serde_derive = "1.0.217" +lazy_static = "1.5.0" +colored = "3.0.0" +chrono = "0.4.39" +image = "0.25.5" +fmt = "0.1.0" +once_cell = "1.20.3" +rascii_art = "0.4.5" + + + +use super::{ + widgets::{self, profiles, WidgetKey}, + Tui, +}; +use super::widgets::popups::new_instance; +use color_eyre::eyre::Context; +use crossterm::event::{self, Event}; +use ratatui::{ + crossterm::event::{KeyCode, KeyEvent, KeyEventKind}, + layout::{Constraint, Direction, Layout}, + Frame, +}; + +#[derive(Debug, Default)] +pub struct App { + exit: bool, + focused: FocusedArea, + profiles_state: profiles::State, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum FocusedArea { + Profiles, + Content, + Account, + Details, + Status, + Popup, +} + +impl Default for FocusedArea { + fn default() -> Self { + FocusedArea::Profiles + } +} + +impl App { + /// runs the main loop until the user quits + pub fn run(&mut self, terminal: &mut Tui) -> color_eyre::Result<()> { + while !self.exit { + terminal.draw(|frame| self.render_frame(frame))?; + self.handle_events().wrap_err("handle events failed")?; + } + Ok(()) + } + + fn render_frame(&mut self, frame: &mut Frame) { + // Divide the screen into horizontal chunks + let chunks = Layout::default() + .direction(Direction::Horizontal) + .constraints([ + Constraint::Percentage(20), // Instances + Constraint::Percentage(80), // Main content + ]) + .split(frame.area()); + + // Render Instances + widgets::profiles::render(frame, chunks[0], self.focused, &mut self.profiles_state); + + // Divide the main content into vertical chunks + let main_chunks = Layout::default() + .direction(Direction::Vertical) + .constraints([ + Constraint::Length(3), // Title + Constraint::Min(10), // Main Content + Constraint::Length(5), // Bottom panel + ]) + .split(chunks[1]); + + widgets::content::title(frame, main_chunks[0], self.focused); + widgets::content::render(frame, main_chunks[1], self.focused); + + let bottom_chunks = Layout::default() + .direction(Direction::Horizontal) + .constraints([ + Constraint::Percentage(30), + Constraint::Percentage(40), + Constraint::Percentage(30), + ]) + .split(main_chunks[2]); + + widgets::account::render(frame, bottom_chunks[0], self.focused); + widgets::details::render(frame, bottom_chunks[1], self.focused); + widgets::status::render(frame, bottom_chunks[2], self.focused); + } + + /// updates the application's state based on user input + fn handle_events(&mut self) -> color_eyre::Result<()> { + match event::read()? { + Event::Key(key_event) if key_event.kind == KeyEventKind::Press => { + self.handle_key_event(key_event) + .wrap_err_with(|| format!("handling key event failed:\n{key_event:#?}")) + } + _ => Ok(()), + } + } + + fn handle_key_event(&mut self, key_event: KeyEvent) -> color_eyre::Result<()> { + match self.focused { + FocusedArea::Popup => { + new_instance::handle_key(&key_event, &mut self.profiles_state); + } + _ => { + match key_event.code { + KeyCode::Char('q') => self.exit = true, + KeyCode::Char('P') => self.focused = FocusedArea::Profiles, + KeyCode::Char('C') => self.focused = FocusedArea::Content, + KeyCode::Char('A') => self.focused = FocusedArea::Account, + KeyCode::Char('D') => self.focused = FocusedArea::Details, + KeyCode::Char('S') => self.focused = FocusedArea::Status, + _ => {} + } + + match self.focused { + FocusedArea::Profiles => self.profiles_state.handle_key(&key_event), + _ => {} + } + } + } + + if self.profiles_state.wants_popup() { + self.focused = FocusedArea::Popup; + } else if self.focused == FocusedArea::Popup { + self.focused = FocusedArea::Profiles; + } + + Ok(()) + } +} + + + +pub mod layout; +pub mod widgets; + +use std::io::{stdout, Result, Stdout}; + +use crossterm::{ + execute, + terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, +}; +use ratatui::{prelude::CrosstermBackend, Terminal}; + +pub fn show() -> color_eyre::Result<()> { + color_eyre::install()?; + let mut terminal = init_ratatui()?; + let result = layout::App::default().run(&mut terminal); + if let Err(err) = restore_ratatui() { + eprintln!( + "failed to restore terminal. Run 'reset' or restart your terminal to recover: {}", + err + ); + } + result +} + +/// TUI Impl + +pub type Tui = Terminal>; + +fn init_ratatui() -> Result { + execute!(stdout(), EnterAlternateScreen)?; + enable_raw_mode()?; + set_panic_hook(); + Terminal::new(CrosstermBackend::new(stdout())) +} + +fn set_panic_hook() { + let hook = std::panic::take_hook(); + std::panic::set_hook(Box::new(move |panic_info| { + let _ = restore_ratatui(); + hook(panic_info); + })); +} + +fn restore_ratatui() -> Result<()> { + execute!(stdout(), LeaveAlternateScreen)?; + disable_raw_mode()?; + Ok(()) +} + + + diff --git a/src/tui/widgets/popups/new_instance.rs b/src/tui/widgets/popups/new_instance.rs index 540b365..7872599 100644 --- a/src/tui/widgets/popups/new_instance.rs +++ b/src/tui/widgets/popups/new_instance.rs @@ -4,6 +4,7 @@ use crate::tui::widgets::profiles; use crossterm::event::KeyCode; use ratatui::{ Frame, + style::{Color, Style}, layout::{Rect, Layout, Direction, Constraint}, text::{Line, Span}, widgets::{Block, Borders, Paragraph, Wrap, Widget}, @@ -45,12 +46,12 @@ pub fn render(frame: &mut Frame, area: Rect, _focused: FocusedArea) { .split(area); let create_button = Paragraph::new(Line::from(vec![ - Span::styled("[C]", ratatui::style::Style::default().add_modifier(ratatui::style::Modifier::BOLD)), + Span::styled("C", Style::default().fg(Color::Yellow)), Span::raw("reate New Instance"), ])).alignment(ratatui::layout::Alignment::Center); let import_button = Paragraph::new(Line::from(vec![ - Span::styled("[I]", ratatui::style::Style::default().add_modifier(ratatui::style::Modifier::BOLD)), + Span::styled("I", Style::default().fg(Color::Yellow)), Span::raw("mport Morinth Modpack"), ])).alignment(ratatui::layout::Alignment::Center); @@ -83,11 +84,11 @@ pub fn handle_key(key_event: &crossterm::event::KeyEvent, state: &mut profiles:: KeyCode::Char('q') => { state.show_popup = false; } - KeyCode::Char('c') => { + KeyCode::Char('c') | KeyCode::Char('C') => { // Create new instance state.show_popup = false; } - KeyCode::Char('i') => { + KeyCode::Char('i') | KeyCode::Char('I') => { // Switch to input mode popup_state.mode = NewInstanceMode::Input; } diff --git a/src/tui/widgets/profiles.rs b/src/tui/widgets/profiles.rs index fc28134..fc82355 100644 --- a/src/tui/widgets/profiles.rs +++ b/src/tui/widgets/profiles.rs @@ -174,10 +174,10 @@ pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea, state: &mut S if state.show_popup { let popup_area = Rect { - x: area.width / 4, - y: area.height / 3, - width: area.width / 2, - height: area.height / 3, + x: frame.area().width / 4, + y: frame.area().height / 3, + width: frame.area().width / 2, + height: frame.area().height / 3, }; popups::new_instance::render(frame, popup_area, focused); }