Compare commits

...

8 Commits

6 changed files with 1767 additions and 3 deletions

896
Cargo.lock generated
View File

@@ -2,6 +2,902 @@
# It is not intended for manual editing.
version = 4
[[package]]
name = "allocator-api2"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "android_system_properties"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
dependencies = [
"libc",
]
[[package]]
name = "anyhow"
version = "1.0.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
[[package]]
name = "autocfg"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
[[package]]
name = "bitflags"
version = "2.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
[[package]]
name = "bumpalo"
version = "3.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb"
[[package]]
name = "cassowary"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
[[package]]
name = "castaway"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a"
dependencies = [
"rustversion",
]
[[package]]
name = "cc"
version = "1.2.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2"
dependencies = [
"find-msvc-tools",
"shlex",
]
[[package]]
name = "cfg-if"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "chrono"
version = "0.4.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0"
dependencies = [
"iana-time-zone",
"js-sys",
"num-traits",
"wasm-bindgen",
"windows-link",
]
[[package]]
name = "compact_str"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b79c4069c6cad78e2e0cdfcbd26275770669fb39fd308a752dc110e83b9af32"
dependencies = [
"castaway",
"cfg-if",
"itoa",
"rustversion",
"ryu",
"static_assertions",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "crossterm"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
dependencies = [
"bitflags",
"crossterm_winapi",
"mio",
"parking_lot",
"rustix",
"signal-hook",
"signal-hook-mio",
"winapi",
]
[[package]]
name = "crossterm_winapi"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
dependencies = [
"winapi",
]
[[package]]
name = "darling"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d"
dependencies = [
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0"
dependencies = [
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn",
]
[[package]]
name = "darling_macro"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d"
dependencies = [
"darling_core",
"quote",
"syn",
]
[[package]]
name = "either"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "errno"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.61.2",
]
[[package]]
name = "find-msvc-tools"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "getrandom"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
"cfg-if",
"libc",
"r-efi",
"wasip2",
]
[[package]]
name = "hashbrown"
version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [
"allocator-api2",
"equivalent",
"foldhash",
]
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "iana-time-zone"
version = "0.1.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"log",
"wasm-bindgen",
"windows-core",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cc",
]
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "indoc"
version = "2.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
dependencies = [
"rustversion",
]
[[package]]
name = "instability"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "357b7205c6cd18dd2c86ed312d1e70add149aea98e7ef72b9fdf0270e555c11d"
dependencies = [
"darling",
"indoc",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "itertools"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
[[package]]
name = "js-sys"
version = "0.3.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c"
dependencies = [
"once_cell",
"wasm-bindgen",
]
[[package]]
name = "libc"
version = "0.2.182"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112"
[[package]]
name = "linux-raw-sys"
version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
[[package]]
name = "lock_api"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
[[package]]
name = "lru"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38"
dependencies = [
"hashbrown",
]
[[package]]
name = "mio"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc"
dependencies = [
"libc",
"log",
"wasi",
"windows-sys 0.61.2",
]
[[package]]
name = "mmtui"
version = "0.1.0"
dependencies = [
"anyhow",
"chrono",
"crossterm",
"rand",
"ratatui",
]
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]]
name = "once_cell"
version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "parking_lot"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-link",
]
[[package]]
name = "paste"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "ppv-lite86"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
dependencies = [
"zerocopy",
]
[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
dependencies = [
"proc-macro2",
]
[[package]]
name = "r-efi"
version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]]
name = "rand"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
dependencies = [
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
dependencies = [
"getrandom",
]
[[package]]
name = "ratatui"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b"
dependencies = [
"bitflags",
"cassowary",
"compact_str",
"crossterm",
"indoc",
"instability",
"itertools",
"lru",
"paste",
"strum",
"unicode-segmentation",
"unicode-truncate",
"unicode-width 0.2.0",
]
[[package]]
name = "redox_syscall"
version = "0.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
dependencies = [
"bitflags",
]
[[package]]
name = "rustix"
version = "0.38.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.59.0",
]
[[package]]
name = "rustversion"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
[[package]]
name = "ryu"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "signal-hook"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"
dependencies = [
"libc",
"signal-hook-registry",
]
[[package]]
name = "signal-hook-mio"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc"
dependencies = [
"libc",
"mio",
"signal-hook",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
dependencies = [
"errno",
"libc",
]
[[package]]
name = "smallvec"
version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "strum"
version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
dependencies = [
"strum_macros",
]
[[package]]
name = "strum_macros"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
dependencies = [
"heck",
"proc-macro2",
"quote",
"rustversion",
"syn",
]
[[package]]
name = "syn"
version = "2.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "unicode-segmentation"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
[[package]]
name = "unicode-truncate"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf"
dependencies = [
"itertools",
"unicode-segmentation",
"unicode-width 0.1.14",
]
[[package]]
name = "unicode-width"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
[[package]]
name = "unicode-width"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
[[package]]
name = "wasi"
version = "0.11.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]]
name = "wasip2"
version = "1.0.2+wasi-0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5"
dependencies = [
"wit-bindgen",
]
[[package]]
name = "wasm-bindgen"
version = "0.2.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e"
dependencies = [
"cfg-if",
"once_cell",
"rustversion",
"wasm-bindgen-macro",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3"
dependencies = [
"bumpalo",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16"
dependencies = [
"unicode-ident",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-core"
version = "0.62.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
dependencies = [
"windows-implement",
"windows-interface",
"windows-link",
"windows-result",
"windows-strings",
]
[[package]]
name = "windows-implement"
version = "0.60.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "windows-interface"
version = "0.59.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-result"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
dependencies = [
"windows-link",
]
[[package]]
name = "windows-strings"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
dependencies = [
"windows-link",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "wit-bindgen"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
[[package]]
name = "zerocopy"
version = "0.8.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a789c6e490b576db9f7e6b6d661bcc9799f7c0ac8352f56ea20193b2681532e5"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f65c489a7071a749c849713807783f70672b28094011623e200cb86dcb835953"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

View File

@@ -1,6 +1,15 @@
[package]
name = "mmtui"
version = "0.1.0"
edition = "2024"
edition = "2021"
[[bin]]
name = "mmtui"
path = "src/main.rs"
[dependencies]
ratatui = "0.29"
crossterm = "0.28"
chrono = "0.4"
rand = "0.9"
anyhow = "1"

338
src/app.rs Normal file
View File

@@ -0,0 +1,338 @@
use crate::row::{make_checksum, Row};
// ── Field indices for global inputs ──────────────────────────────────────────
pub const GLOBAL_HUT_ID: usize = 0;
pub const GLOBAL_CHECKSUM: usize = 1;
pub const GLOBAL_TARE: usize = 2;
pub const GLOBAL_LOT_STATUS: usize = 3;
pub const GLOBAL_PATH: usize = 4;
pub const GLOBAL_HUT_TYPE: usize = 5;
pub const GLOBAL_COUNT: usize = 6;
pub const LOT_STATUS_OPTIONS: &[&str] = &["Unrestricted", "Blocked", "Quality"];
// Field indices for per-row inputs
pub const ROW_MAT_ID: usize = 0;
pub const ROW_QUANTITY: usize = 1;
pub const ROW_UOM: usize = 2;
pub const ROW_COUNT: usize = 3;
/// Which section of the UI the cursor is in
#[derive(Clone, PartialEq)]
pub enum Focus {
GlobalField(usize),
LotRow(usize), // focused on the row itself (for deletion etc.)
LotField(usize, usize), // (row_index, field_index)
}
#[derive(Clone, PartialEq)]
pub enum ModalKind {
ConfirmClose,
ConfirmQuit,
}
pub struct LotEntry {
/// raw string buffers for each field
pub fields: [String; ROW_COUNT],
}
impl LotEntry {
pub fn new() -> Self {
Self {
fields: [
String::new(), // mat_id
String::new(), // quantity
String::new(), // uom
],
}
}
pub fn mat_id(&self) -> &str {
&self.fields[ROW_MAT_ID]
}
pub fn quantity(&self) -> f64 {
self.fields[ROW_QUANTITY].parse().unwrap_or(0.0)
}
pub fn uom(&self) -> &str {
&self.fields[ROW_UOM]
}
}
pub struct App {
/// Global field string buffers
pub global: [String; GLOBAL_COUNT],
pub lots: Vec<LotEntry>,
pub focus: Focus,
pub modal: Option<ModalKind>,
/// Custom user-defined properties: (header, type, value)
pub custom_props: Vec<(String, String, String)>,
}
impl App {
pub fn new() -> Self {
let mut global: [String; GLOBAL_COUNT] = Default::default();
// sensible defaults
global[GLOBAL_LOT_STATUS] = LOT_STATUS_OPTIONS[0].to_string();
Self {
global,
lots: Vec::new(),
focus: Focus::GlobalField(0),
modal: None,
custom_props: Vec::new(),
}
}
// ── navigation ────────────────────────────────────────────────────────────
pub fn focus_next(&mut self) {
self.focus = match &self.focus {
Focus::GlobalField(i) => {
let next = i + 1;
if next < GLOBAL_COUNT {
Focus::GlobalField(next)
} else if !self.lots.is_empty() {
Focus::LotField(0, 0)
} else {
Focus::GlobalField(0)
}
}
Focus::LotField(row, field) => {
let next_field = field + 1;
if next_field < ROW_COUNT {
Focus::LotField(*row, next_field)
} else {
let next_row = row + 1;
if next_row < self.lots.len() {
Focus::LotField(next_row, 0)
} else {
Focus::GlobalField(0)
}
}
}
Focus::LotRow(row) => {
let next = row + 1;
if next < self.lots.len() {
Focus::LotRow(next)
} else {
Focus::LotRow(*row)
}
}
};
}
pub fn focus_prev(&mut self) {
self.focus = match &self.focus {
Focus::GlobalField(i) => {
if *i == 0 {
// wrap to last lot field or stay
if !self.lots.is_empty() {
let last_row = self.lots.len() - 1;
Focus::LotField(last_row, ROW_COUNT - 1)
} else {
Focus::GlobalField(GLOBAL_COUNT - 1)
}
} else {
Focus::GlobalField(i - 1)
}
}
Focus::LotField(row, field) => {
if *field == 0 {
if *row == 0 {
Focus::GlobalField(GLOBAL_COUNT - 1)
} else {
Focus::LotField(row - 1, ROW_COUNT - 1)
}
} else {
Focus::LotField(*row, field - 1)
}
}
Focus::LotRow(row) => {
if *row == 0 {
Focus::LotRow(0)
} else {
Focus::LotRow(row - 1)
}
}
};
}
/// Move focus to the same field in the next lot row (Down arrow)
pub fn focus_next_row(&mut self) {
match &self.focus {
Focus::LotField(row, field) => {
let next = row + 1;
if next < self.lots.len() {
let f = *field;
self.focus = Focus::LotField(next, f);
}
}
Focus::LotRow(row) => {
let next = row + 1;
if next < self.lots.len() {
self.focus = Focus::LotRow(next);
}
}
_ => {}
}
}
/// Move focus to the same field in the previous lot row (Up arrow)
pub fn focus_prev_row(&mut self) {
match self.focus.clone() {
Focus::LotField(row, field) => {
if row == 0 {
self.focus = Focus::GlobalField(0);
} else {
self.focus = Focus::LotField(row - 1, field);
}
}
Focus::LotRow(row) => {
if row == 0 {
self.focus = Focus::GlobalField(0);
} else {
self.focus = Focus::LotRow(row - 1);
}
}
_ => {}
}
}
// ── editing ───────────────────────────────────────────────────────────────
pub fn type_char(&mut self, c: char) {
match self.focus.clone() {
// GLOBAL_CHECKSUM is toggled via Space, not typed
// GLOBAL_LOT_STATUS is cycled via Space/←/→, not typed
Focus::GlobalField(i) if i == GLOBAL_CHECKSUM || i == GLOBAL_LOT_STATUS => {}
Focus::GlobalField(i) => {
self.global[i].push(c);
}
Focus::LotField(row, field) => {
self.lots[row].fields[field].push(c);
}
_ => {}
}
}
pub fn backspace(&mut self) {
match self.focus.clone() {
Focus::GlobalField(i) if i == GLOBAL_CHECKSUM || i == GLOBAL_LOT_STATUS => {}
Focus::GlobalField(i) => {
self.global[i].pop();
}
Focus::LotField(row, field) => {
self.lots[row].fields[field].pop();
}
_ => {}
}
}
pub fn toggle_checksum(&mut self) {
let val = &self.global[GLOBAL_CHECKSUM];
self.global[GLOBAL_CHECKSUM] = if val == "true" {
"false".into()
} else {
"true".into()
};
}
// ── lot management ────────────────────────────────────────────────────────
pub fn add_lot(&mut self) {
self.lots.push(LotEntry::new());
let new_row = self.lots.len() - 1;
self.focus = Focus::LotField(new_row, 0);
}
pub fn remove_focused_lot(&mut self) {
let row = match &self.focus {
Focus::LotRow(r) | Focus::LotField(r, _) => *r,
_ => return,
};
if row < self.lots.len() {
self.lots.remove(row);
if self.lots.is_empty() {
self.focus = Focus::GlobalField(0);
} else {
let new_row = row.min(self.lots.len() - 1);
self.focus = Focus::LotField(new_row, 0);
}
}
}
// ── CSV generation ────────────────────────────────────────────────────────
pub fn generate_csv(&self) -> String {
let checksum = self.global[GLOBAL_CHECKSUM] == "true";
let hut_id = &self.global[GLOBAL_HUT_ID];
let tare: f64 = self.global[GLOBAL_TARE].parse().unwrap_or(0.0);
let lot_status = &self.global[GLOBAL_LOT_STATUS];
let path = &self.global[GLOBAL_PATH];
let hut_type = &self.global[GLOBAL_HUT_TYPE];
// Build header rows
let custom_headers: Vec<String> = self
.custom_props
.iter()
.map(|(h, _, _)| h.clone())
.collect();
let custom_types: Vec<String> = self
.custom_props
.iter()
.map(|(_, t, _)| t.clone())
.collect();
let header_row = format!(
",,,,,,,,,,,LOTdtCreationDate,LOTdtBornOnDate,LOTdtExpiryDate{}",
if custom_headers.is_empty() {
String::new()
} else {
format!(",{}", custom_headers.join(","))
}
);
let type_row = format!(
",,,,,,,,,,,DATETIME,DATETIME,DATETIME{}",
if custom_types.is_empty() {
String::new()
} else {
format!(",{}", custom_types.join(","))
}
);
let mut lines = vec![header_row, type_row];
for entry in &self.lots {
let name = if checksum {
make_checksum()
} else {
hut_id.to_ascii_uppercase()
};
let row = Row::new(
&name,
hut_type,
path,
tare,
entry.mat_id(),
entry.quantity(),
entry.uom(),
lot_status,
false, // checksum already applied to name above
);
let custom_values: Vec<String> = self
.custom_props
.iter()
.map(|(_, _, v)| v.clone())
.collect();
let line = if custom_values.is_empty() {
format!("{}", row)
} else {
format!("{},{}", row, custom_values.join(","))
};
lines.push(line);
}
lines.join("\n")
}
}

View File

@@ -1,3 +1,142 @@
fn main() {
println!("Hello, world!");
mod app;
mod row;
mod ui;
use app::{App, Focus, ModalKind, GLOBAL_CHECKSUM};
use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyModifiers},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use ratatui::{backend::CrosstermBackend, Terminal};
use std::io;
fn main() -> anyhow::Result<()> {
// ── terminal setup ───────────────────────────────────────────────────────
enable_raw_mode()?;
let mut stdout = io::stdout();
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
let backend = CrosstermBackend::new(stdout);
let mut terminal = Terminal::new(backend)?;
let result = run(&mut terminal);
// ── restore terminal ─────────────────────────────────────────────────────
disable_raw_mode()?;
execute!(
terminal.backend_mut(),
LeaveAlternateScreen,
DisableMouseCapture
)?;
terminal.show_cursor()?;
// Output CSV to stdout AFTER restoring terminal so it's clean
match result {
Ok(Some(csv)) => {
print!("{}", csv);
}
Ok(None) => {}
Err(e) => {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}
Ok(())
}
/// Returns `Some(csv)` when the user confirms close, `None` on quit.
fn run<B: ratatui::backend::Backend>(terminal: &mut Terminal<B>) -> anyhow::Result<Option<String>> {
let mut app = App::new();
loop {
terminal.draw(|f| ui::draw(f, &app))?;
if let Event::Key(key) = event::read()? {
// ── modal active ─────────────────────────────────────────────────
if app.modal.is_some() {
match key.code {
KeyCode::Char('y') | KeyCode::Char('Y') => {
let kind = app.modal.take().unwrap();
match kind {
ModalKind::ConfirmClose => {
return Ok(Some(app.generate_csv()));
}
ModalKind::ConfirmQuit => {
return Ok(None);
}
}
}
KeyCode::Char('n') | KeyCode::Char('N') | KeyCode::Esc => {
app.modal = None;
}
_ => {}
}
continue;
}
// ── global shortcuts ─────────────────────────────────────────────
match key.code {
KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL) => {
// Ctrl-C hard quit without modal
return Ok(None);
}
KeyCode::Char('c') => {
app.modal = Some(ModalKind::ConfirmClose);
continue;
}
KeyCode::Char('q') => {
app.modal = Some(ModalKind::ConfirmQuit);
continue;
}
KeyCode::Char('+') | KeyCode::Char('=') => {
app.add_lot();
continue;
}
KeyCode::Char('-') => {
app.remove_focused_lot();
continue;
}
KeyCode::Tab => {
app.focus_next();
continue;
}
KeyCode::BackTab => {
app.focus_prev();
continue;
}
KeyCode::Up => {
if matches!(app.focus, Focus::LotField(_, _) | Focus::LotRow(_)) {
app.focus_prev_row();
} else {
app.focus_prev();
}
continue;
}
KeyCode::Down => {
if matches!(app.focus, Focus::LotField(_, _) | Focus::LotRow(_)) {
app.focus_next_row();
} else {
app.focus_next();
}
continue;
}
_ => {}
}
// ── field-specific input ─────────────────────────────────────────
match app.focus.clone() {
Focus::GlobalField(i) if i == GLOBAL_CHECKSUM => {
if key.code == KeyCode::Char(' ') {
app.toggle_checksum();
}
}
_ => match key.code {
KeyCode::Backspace => app.backspace(),
KeyCode::Char(c) => app.type_char(c),
_ => {}
},
}
}
}
}

94
src/row.rs Normal file
View File

@@ -0,0 +1,94 @@
pub struct Row {
pub name: String,
pub hut_type: String,
pub path: String,
pub tare: f64,
pub mat_id: String,
pub quantity: f64,
pub lot_id: String,
pub uom: String,
pub lot_status: String,
pub born: chrono::DateTime<chrono::Local>,
pub expire: chrono::DateTime<chrono::Local>,
}
impl Row {
pub const DF: &'static str = "%Y-%m-%d %H:%M";
pub fn new(
name: &str,
hut_type: &str,
path: &str,
tare: f64,
mat_id: &str,
quantity: f64,
uom: &str,
lot_status: &str,
checksum: bool,
) -> Self {
let born = chrono::Local::now();
let expire = born
.checked_add_days(chrono::Days::new(365))
.expect("A valid date time");
let name = if checksum {
make_checksum()
} else {
name.to_ascii_uppercase()
};
Self {
name: name.clone(),
hut_type: hut_type.to_ascii_uppercase(),
path: path.to_ascii_uppercase(),
tare,
mat_id: mat_id.to_ascii_uppercase(),
quantity,
lot_id: format!("{}-{}", name, mat_id).to_ascii_uppercase(),
uom: uom.to_ascii_uppercase(),
lot_status: lot_status.to_ascii_uppercase(),
born,
expire,
}
}
}
pub fn make_checksum() -> String {
let base = rand::random_range(10000..99999u32).to_string();
let split_expect = "a valid character in the base checksum";
let split = format!(
"{}{}{}{}{}",
base.chars().next().expect(split_expect),
base.chars().nth(2).expect(split_expect),
base.chars().nth(4).expect(split_expect),
base.chars().nth(1).expect(split_expect),
base.chars().nth(3).expect(split_expect)
)
.repeat(2);
let sum: u32 = split
.chars()
.map(|c| c.to_digit(10).expect("a valid integer value"))
.sum();
let last = (10 - (sum % 10)) % 10;
format!("{}{}", base, last)
}
impl std::fmt::Display for Row {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{},{},{},{},{},N,{},{},{},{},{},{},{},{}",
self.name,
self.name,
self.hut_type,
self.path,
self.tare,
self.mat_id,
self.quantity,
self.lot_id,
self.uom,
self.lot_status,
self.born.format(Self::DF),
self.born.format(Self::DF),
self.expire.format(Self::DF),
)
}
}

288
src/ui.rs Normal file
View File

@@ -0,0 +1,288 @@
use ratatui::{
layout::{Constraint, Direction, Layout, Rect},
style::{Color, Modifier, Style},
text::{Line, Span},
widgets::{Block, Borders, Cell, Clear, Paragraph, Row, Table, TableState},
Frame,
};
use crate::app::{
App, Focus, ModalKind, GLOBAL_CHECKSUM, GLOBAL_COUNT, GLOBAL_HUT_ID, GLOBAL_HUT_TYPE,
GLOBAL_PATH, GLOBAL_TARE, ROW_COUNT, ROW_MAT_ID, ROW_QUANTITY, ROW_UOM,
};
const GLOBAL_LABELS: &[&str] = &[
"Hut ID",
"Checksum",
"Tare",
"Lot Status",
"Path",
"Hut Type",
];
const ROW_LABELS: &[&str] = &["Material ID", "Quantity", "UOM"];
// ── colour palette ────────────────────────────────────────────────────────────
const C_FOCUSED: Color = Color::Cyan;
const C_UNFOCUSED: Color = Color::DarkGray;
const C_ACCENT: Color = Color::Yellow;
const C_ROW_SEL: Color = Color::Blue;
const C_BORDER: Color = Color::Gray;
const C_HEADER: Color = Color::White;
fn focused_style(is_focused: bool) -> Style {
if is_focused {
Style::default().fg(C_FOCUSED).add_modifier(Modifier::BOLD)
} else {
Style::default().fg(C_UNFOCUSED)
}
}
fn focused_block<'a>(title: &'a str, is_focused: bool) -> Block<'a> {
Block::default()
.title(title)
.borders(Borders::ALL)
.border_style(if is_focused {
Style::default().fg(C_FOCUSED)
} else {
Style::default().fg(C_BORDER)
})
}
// ── main draw ────────────────────────────────────────────────────────────────
pub fn draw(f: &mut Frame, app: &App) {
let area = f.area();
// Overall vertical split: globals | lots | help bar
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([
Constraint::Length(10), // global fields
Constraint::Min(6), // lot rows
Constraint::Length(3), // help bar
])
.split(area);
draw_globals(f, app, chunks[0]);
draw_lots(f, app, chunks[1]);
draw_help(f, chunks[2]);
if let Some(modal) = &app.modal {
draw_modal(f, modal, area);
}
}
// ── globals panel ─────────────────────────────────────────────────────────────
fn draw_globals(f: &mut Frame, app: &App, area: Rect) {
let outer = Block::default()
.title(" Global Settings ")
.borders(Borders::ALL)
.border_style(Style::default().fg(C_ACCENT));
let inner = outer.inner(area);
f.render_widget(outer, area);
// Two rows of three fields each
let rows = Layout::default()
.direction(Direction::Vertical)
.constraints([
Constraint::Length(3),
Constraint::Length(3),
Constraint::Length(3),
])
.split(inner);
// Row 0: Hut ID | Checksum | Tare
let row0 = Layout::default()
.direction(Direction::Horizontal)
.constraints([
Constraint::Ratio(2, 5),
Constraint::Ratio(1, 5),
Constraint::Ratio(2, 5),
])
.split(rows[0]);
// Row 1: Lot Status | Path | Hut Type
let row1 = Layout::default()
.direction(Direction::Horizontal)
.constraints([
Constraint::Ratio(1, 3),
Constraint::Ratio(1, 3),
Constraint::Ratio(1, 3),
])
.split(rows[1]);
let field_areas = [
row0[0], // GLOBAL_HUT_ID
row0[1], // GLOBAL_CHECKSUM
row0[2], // GLOBAL_TARE
row1[0], // GLOBAL_LOT_STATUS
row1[1], // GLOBAL_PATH
row1[2], // GLOBAL_HUT_TYPE
];
for i in 0..GLOBAL_COUNT {
let is_focused = app.focus == Focus::GlobalField(i);
let label = GLOBAL_LABELS[i];
let value: String = if i == GLOBAL_CHECKSUM {
let checked = app.global[i] == "true";
format!("[{}] (Space)", if checked { "x" } else { " " })
} else {
app.global[i].clone()
};
let display = if is_focused {
format!("{}", value)
} else {
value
};
let p = Paragraph::new(display)
.block(focused_block(label, is_focused))
.style(focused_style(is_focused));
f.render_widget(p, field_areas[i]);
}
}
// ── lots table ────────────────────────────────────────────────────────────────
fn draw_lots(f: &mut Frame, app: &App, area: Rect) {
let outer = Block::default()
.title(" Lot Rows (+) Add (-) Remove ")
.borders(Borders::ALL)
.border_style(Style::default().fg(C_ACCENT));
let inner = outer.inner(area);
f.render_widget(outer, area);
if app.lots.is_empty() {
let hint = Paragraph::new("No lots yet — press + to add one")
.style(Style::default().fg(C_UNFOCUSED));
f.render_widget(hint, inner);
return;
}
// Column widths
let col_constraints = [
Constraint::Length(4), // #
Constraint::Min(18), // Material ID
Constraint::Length(12), // Quantity
Constraint::Length(8), // UOM
];
let header_cells = ["#", "Material ID", "Quantity", "UOM"]
.iter()
.map(|h| Cell::from(*h).style(Style::default().fg(C_HEADER).add_modifier(Modifier::BOLD)));
let header = Row::new(header_cells).height(1).bottom_margin(0);
let rows: Vec<Row> = app
.lots
.iter()
.enumerate()
.map(|(row_idx, entry)| {
let cells: Vec<Cell> = (0..ROW_COUNT + 1)
.map(|col| {
if col == 0 {
// row number
Cell::from(format!("{:>2}", row_idx + 1))
.style(Style::default().fg(C_UNFOCUSED))
} else {
let field_idx = col - 1;
let is_focused = app.focus == Focus::LotField(row_idx, field_idx);
let text = if is_focused {
format!("{}", entry.fields[field_idx])
} else {
entry.fields[field_idx].clone()
};
Cell::from(text).style(focused_style(is_focused))
}
})
.collect();
let row_selected =
matches!(&app.focus, Focus::LotRow(r) | Focus::LotField(r, _) if *r == row_idx);
let row_style = if row_selected {
Style::default().bg(Color::Rgb(20, 30, 50))
} else {
Style::default()
};
Row::new(cells).style(row_style).height(1)
})
.collect();
let table = Table::new(rows, col_constraints)
.header(header)
.block(Block::default())
.row_highlight_style(Style::default().bg(C_ROW_SEL));
let mut state = TableState::default();
f.render_stateful_widget(table, inner, &mut state);
}
// ── help bar ──────────────────────────────────────────────────────────────────
fn draw_help(f: &mut Frame, area: Rect) {
let spans = vec![
Span::styled(" Tab ", Style::default().fg(Color::Black).bg(C_ACCENT)),
Span::raw(" Next field "),
Span::styled(" + ", Style::default().fg(Color::Black).bg(Color::Green)),
Span::raw(" Add lot "),
Span::styled(" - ", Style::default().fg(Color::Black).bg(Color::Red)),
Span::raw(" Remove lot "),
Span::styled(" c ", Style::default().fg(Color::Black).bg(Color::Cyan)),
Span::raw(" Output CSV "),
Span::styled(" q ", Style::default().fg(Color::Black).bg(Color::Magenta)),
Span::raw(" Quit "),
];
let help = Paragraph::new(Line::from(spans)).block(
Block::default()
.borders(Borders::ALL)
.border_style(Style::default().fg(C_BORDER)),
);
f.render_widget(help, area);
}
// ── modal overlay ─────────────────────────────────────────────────────────────
fn draw_modal(f: &mut Frame, kind: &ModalKind, area: Rect) {
let (title, body) = match kind {
ModalKind::ConfirmClose => (
" Output CSV and Close ",
"Output generated CSV to stdout and exit?\n\n [y] Yes [n] Cancel",
),
ModalKind::ConfirmQuit => (
" Quit Without Output ",
"Quit without outputting anything?\n\n [y] Yes [n] Cancel",
),
};
let popup_width = 50u16;
let popup_height = 7u16;
let x = area.x + area.width.saturating_sub(popup_width) / 2;
let y = area.y + area.height.saturating_sub(popup_height) / 2;
let popup_area = Rect::new(
x,
y,
popup_width.min(area.width),
popup_height.min(area.height),
);
f.render_widget(Clear, popup_area);
let color = match kind {
ModalKind::ConfirmClose => Color::Cyan,
ModalKind::ConfirmQuit => Color::Magenta,
};
let p = Paragraph::new(body)
.block(
Block::default()
.title(title)
.borders(Borders::ALL)
.border_style(Style::default().fg(color).add_modifier(Modifier::BOLD)),
)
.style(Style::default().fg(C_HEADER));
f.render_widget(p, popup_area);
}