repo initialized
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
||||
629
Cargo.lock
generated
Normal file
629
Cargo.lock
generated
Normal file
@ -0,0 +1,629 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# 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 = "anyhow"
|
||||
version = "1.0.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
||||
|
||||
[[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 = "cfg-if"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
|
||||
[[package]]
|
||||
name = "compact_str"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f"
|
||||
dependencies = [
|
||||
"castaway",
|
||||
"cfg-if",
|
||||
"itoa",
|
||||
"ryu",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"crossterm_winapi",
|
||||
"libc",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"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 = "dirs"
|
||||
version = "5.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[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 = "foldhash"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[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 = "itertools"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[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.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.178"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[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 = "memchr"
|
||||
version = "2.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.8.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "option-ext"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[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 = "proc-macro2"
|
||||
version = "1.0.103"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ratatui"
|
||||
version = "0.26.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f44c9e68fd46eda15c646fbb85e1040b657a58cdc8c98db1d97a55930d991eef"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cassowary",
|
||||
"compact_str",
|
||||
"crossterm",
|
||||
"itertools 0.12.1",
|
||||
"lru",
|
||||
"paste",
|
||||
"stability",
|
||||
"strum",
|
||||
"unicode-segmentation",
|
||||
"unicode-truncate",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"libredox",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[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.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.145"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[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.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7664a098b8e616bdfcc2dc0e9ac44eb231eedf41db4e9fe95d8d32ec728dedad"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
||||
|
||||
[[package]]
|
||||
name = "sshx"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"crossterm",
|
||||
"dirs",
|
||||
"ratatui",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stability"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[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.111"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||
|
||||
[[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 0.13.0",
|
||||
"unicode-segmentation",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.1+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[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-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
12
Cargo.toml
Normal file
12
Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "sshx"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
ratatui = "0.26"
|
||||
crossterm = "0.27"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
dirs = "5.0"
|
||||
anyhow = "1.0"
|
||||
144
src/app.rs
Normal file
144
src/app.rs
Normal file
@ -0,0 +1,144 @@
|
||||
use anyhow::Result;
|
||||
use ratatui::widgets::ListState;
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
use crate::server::Server;
|
||||
|
||||
pub enum InputMode {
|
||||
Normal,
|
||||
Adding(AddingState),
|
||||
Editing(EditingState),
|
||||
}
|
||||
|
||||
pub struct AddingState {
|
||||
pub field_idx: usize,
|
||||
pub name: String,
|
||||
pub user: String,
|
||||
pub host: String,
|
||||
pub port: String,
|
||||
}
|
||||
|
||||
impl AddingState {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
field_idx: 0,
|
||||
name: String::new(),
|
||||
user: String::new(),
|
||||
host: String::new(),
|
||||
port: "22".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct EditingState {
|
||||
pub server_index: usize,
|
||||
pub field_idx: usize,
|
||||
pub name: String,
|
||||
pub user: String,
|
||||
pub host: String,
|
||||
pub port: String,
|
||||
}
|
||||
|
||||
impl EditingState {
|
||||
pub fn new(server: &Server, index: usize) -> Self {
|
||||
Self {
|
||||
server_index: index,
|
||||
field_idx: 0,
|
||||
name: server.name.clone(),
|
||||
user: server.user.clone(),
|
||||
host: server.host.clone(),
|
||||
port: server.port.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct App {
|
||||
pub servers: Vec<Server>,
|
||||
pub state: ListState,
|
||||
pub input_mode: InputMode,
|
||||
config_path: PathBuf,
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub fn new() -> Result<Self> {
|
||||
let config_dir = dirs::config_dir().unwrap_or_else(|| PathBuf::from("."));
|
||||
let app_config_dir = config_dir.join("sshx");
|
||||
if !app_config_dir.exists() {
|
||||
fs::create_dir_all(&app_config_dir)?;
|
||||
}
|
||||
let config_path = app_config_dir.join("servers.json");
|
||||
|
||||
let servers = if config_path.exists() {
|
||||
let data = fs::read_to_string(&config_path)?;
|
||||
serde_json::from_str(&data).unwrap_or_else(|_| Vec::new())
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
|
||||
let mut state = ListState::default();
|
||||
if !servers.is_empty() {
|
||||
state.select(Some(0));
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
servers,
|
||||
state,
|
||||
input_mode: InputMode::Normal,
|
||||
config_path,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn save(&self) -> Result<()> {
|
||||
let data = serde_json::to_string_pretty(&self.servers)?;
|
||||
fs::write(&self.config_path, data)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn next(&mut self) {
|
||||
if self.servers.is_empty() {
|
||||
return;
|
||||
}
|
||||
let i = match self.state.selected() {
|
||||
Some(i) => {
|
||||
if i >= self.servers.len() - 1 {
|
||||
0
|
||||
} else {
|
||||
i + 1
|
||||
}
|
||||
}
|
||||
None => 0,
|
||||
};
|
||||
self.state.select(Some(i));
|
||||
}
|
||||
|
||||
pub fn previous(&mut self) {
|
||||
if self.servers.is_empty() {
|
||||
return;
|
||||
}
|
||||
let i = match self.state.selected() {
|
||||
Some(i) => {
|
||||
if i == 0 {
|
||||
self.servers.len() - 1
|
||||
} else {
|
||||
i - 1
|
||||
}
|
||||
}
|
||||
None => 0,
|
||||
};
|
||||
self.state.select(Some(i));
|
||||
}
|
||||
|
||||
pub fn delete_current(&mut self) {
|
||||
if let Some(i) = self.state.selected() {
|
||||
if i < self.servers.len() {
|
||||
self.servers.remove(i);
|
||||
if self.servers.is_empty() {
|
||||
self.state.select(None);
|
||||
} else if i >= self.servers.len() {
|
||||
self.state.select(Some(self.servers.len() - 1));
|
||||
}
|
||||
let _ = self.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
50
src/command.rs
Normal file
50
src/command.rs
Normal file
@ -0,0 +1,50 @@
|
||||
use crossterm::{
|
||||
event::{DisableMouseCapture, EnableMouseCapture},
|
||||
execute,
|
||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||
};
|
||||
use ratatui::{backend::Backend, Terminal};
|
||||
use std::{
|
||||
io,
|
||||
process::Command,
|
||||
};
|
||||
|
||||
pub fn run_external_command<B: Backend + std::io::Write>(
|
||||
terminal: &mut Terminal<B>,
|
||||
program: &str,
|
||||
args: &[String],
|
||||
) -> io::Result<()> {
|
||||
// Drop TUI state
|
||||
disable_raw_mode()?;
|
||||
execute!(terminal.backend_mut(), LeaveAlternateScreen, DisableMouseCapture)?;
|
||||
terminal.show_cursor()?;
|
||||
|
||||
// Run command
|
||||
println!("Running {} {}...", program, args.join(" "));
|
||||
let status = Command::new(program)
|
||||
.args(args)
|
||||
.status();
|
||||
|
||||
match status {
|
||||
Ok(s) => {
|
||||
if !s.success() {
|
||||
println!("Command exited with status: {}", s);
|
||||
println!("Press Enter to continue...");
|
||||
let mut line = String::new();
|
||||
std::io::stdin().read_line(&mut line)?;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
println!("Failed to execute {}: {}", program, e);
|
||||
println!("Press Enter to continue...");
|
||||
let mut line = String::new();
|
||||
std::io::stdin().read_line(&mut line)?;
|
||||
}
|
||||
}
|
||||
|
||||
// Restore TUI state
|
||||
enable_raw_mode()?;
|
||||
execute!(terminal.backend_mut(), EnterAlternateScreen, EnableMouseCapture)?;
|
||||
terminal.clear()?;
|
||||
Ok(())
|
||||
}
|
||||
216
src/main.rs
Normal file
216
src/main.rs
Normal file
@ -0,0 +1,216 @@
|
||||
mod app;
|
||||
mod server;
|
||||
mod ui;
|
||||
mod command;
|
||||
|
||||
use anyhow::Result;
|
||||
use crossterm::{
|
||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyModifiers},
|
||||
execute,
|
||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||
};
|
||||
use ratatui::{
|
||||
backend::{Backend, CrosstermBackend},
|
||||
Terminal,
|
||||
};
|
||||
use std::{
|
||||
error::Error,
|
||||
io,
|
||||
};
|
||||
|
||||
use app::{App, InputMode, AddingState, EditingState};
|
||||
use command::run_external_command;
|
||||
use ui::ui;
|
||||
use server::Server;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
// Setup terminal
|
||||
enable_raw_mode()?;
|
||||
let mut stdout = io::stdout();
|
||||
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
|
||||
let backend = CrosstermBackend::new(stdout);
|
||||
let mut terminal = Terminal::new(backend)?;
|
||||
|
||||
// Create app
|
||||
let mut app = App::new()?;
|
||||
|
||||
let res = run_app(&mut terminal, &mut app);
|
||||
|
||||
// Restore terminal
|
||||
disable_raw_mode()?;
|
||||
execute!(
|
||||
terminal.backend_mut(),
|
||||
LeaveAlternateScreen,
|
||||
DisableMouseCapture
|
||||
)?;
|
||||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_app<B: Backend + std::io::Write>(terminal: &mut Terminal<B>, app: &mut App) -> io::Result<()> {
|
||||
loop {
|
||||
// Hide cursor in normal mode, show in input/edit mode
|
||||
match app.input_mode {
|
||||
InputMode::Normal => terminal.hide_cursor()?,
|
||||
InputMode::Adding(_) | InputMode::Editing(_) => terminal.show_cursor()?,
|
||||
}
|
||||
|
||||
terminal.draw(|f| ui(f, app))?;
|
||||
|
||||
if let Event::Key(key) = event::read()? {
|
||||
match &mut app.input_mode {
|
||||
InputMode::Normal => match key.code {
|
||||
KeyCode::Char('q') | KeyCode::Esc => return Ok(()),
|
||||
KeyCode::Down | KeyCode::Tab | KeyCode::Char('j') => app.next(),
|
||||
KeyCode::Up | KeyCode::BackTab | KeyCode::Char('k') => app.previous(),
|
||||
KeyCode::Char('n') => {
|
||||
if key.modifiers.contains(KeyModifiers::SHIFT) {
|
||||
// SSH Copy ID
|
||||
if let Some(idx) = app.state.selected() {
|
||||
let server = &app.servers[idx];
|
||||
let args = server.to_copy_id_args();
|
||||
run_external_command(terminal, "ssh-copy-id", &args)?;
|
||||
}
|
||||
} else {
|
||||
// Add new server
|
||||
app.input_mode = InputMode::Adding(AddingState::new());
|
||||
}
|
||||
}
|
||||
KeyCode::Char('d') => {
|
||||
app.delete_current();
|
||||
}
|
||||
KeyCode::Char('i') => {
|
||||
// Edit server
|
||||
if let Some(idx) = app.state.selected() {
|
||||
let server = &app.servers[idx].clone();
|
||||
app.input_mode = InputMode::Editing(EditingState::new(server, idx));
|
||||
}
|
||||
}
|
||||
KeyCode::Char('m') => {
|
||||
// Mosh
|
||||
if let Some(idx) = app.state.selected() {
|
||||
let server = &app.servers[idx];
|
||||
let args = server.to_mosh_args();
|
||||
run_external_command(terminal, "mosh", &args)?;
|
||||
}
|
||||
}
|
||||
KeyCode::Enter => {
|
||||
// SSH
|
||||
if let Some(idx) = app.state.selected() {
|
||||
let server = &app.servers[idx];
|
||||
let args = server.to_ssh_args();
|
||||
run_external_command(terminal, "ssh", &args)?;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
InputMode::Editing(state) => match key.code {
|
||||
KeyCode::Esc => app.input_mode = InputMode::Normal,
|
||||
KeyCode::Char(c) => {
|
||||
match state.field_idx {
|
||||
0 => state.name.push(c),
|
||||
1 => state.user.push(c),
|
||||
2 => state.host.push(c),
|
||||
3 => state.port.push(c),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
KeyCode::Backspace => {
|
||||
match state.field_idx {
|
||||
0 => { state.name.pop(); },
|
||||
1 => { state.user.pop(); },
|
||||
2 => { state.host.pop(); },
|
||||
3 => { state.port.pop(); },
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
KeyCode::Tab | KeyCode::Down => {
|
||||
if state.field_idx < 3 {
|
||||
state.field_idx += 1;
|
||||
} else {
|
||||
state.field_idx = 0;
|
||||
}
|
||||
}
|
||||
KeyCode::BackTab | KeyCode::Up => {
|
||||
if state.field_idx > 0 {
|
||||
state.field_idx -= 1;
|
||||
} else {
|
||||
state.field_idx = 3;
|
||||
}
|
||||
}
|
||||
KeyCode::Enter => {
|
||||
// Validate and save
|
||||
if !state.name.is_empty() && !state.host.is_empty() {
|
||||
let updated_server = Server {
|
||||
name: state.name.clone(),
|
||||
user: if state.user.is_empty() { "root".to_string() } else { state.user.clone() },
|
||||
host: state.host.clone(),
|
||||
port: if state.port.is_empty() { "22".to_string() } else { state.port.clone() },
|
||||
};
|
||||
app.servers[state.server_index] = updated_server;
|
||||
let _ = app.save();
|
||||
app.input_mode = InputMode::Normal;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
InputMode::Adding(state) => match key.code {
|
||||
KeyCode::Esc => app.input_mode = InputMode::Normal,
|
||||
KeyCode::Char(c) => {
|
||||
match state.field_idx {
|
||||
0 => state.name.push(c),
|
||||
1 => state.user.push(c),
|
||||
2 => state.host.push(c),
|
||||
3 => state.port.push(c),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
KeyCode::Backspace => {
|
||||
match state.field_idx {
|
||||
0 => { state.name.pop(); },
|
||||
1 => { state.user.pop(); },
|
||||
2 => { state.host.pop(); },
|
||||
3 => { state.port.pop(); },
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
KeyCode::Tab | KeyCode::Down => {
|
||||
if state.field_idx < 3 {
|
||||
state.field_idx += 1;
|
||||
} else {
|
||||
state.field_idx = 0;
|
||||
}
|
||||
}
|
||||
KeyCode::BackTab | KeyCode::Up => {
|
||||
if state.field_idx > 0 {
|
||||
state.field_idx -= 1;
|
||||
} else {
|
||||
state.field_idx = 3;
|
||||
}
|
||||
}
|
||||
KeyCode::Enter => {
|
||||
// Validate and save
|
||||
if !state.name.is_empty() && !state.host.is_empty() {
|
||||
let new_server = Server {
|
||||
name: state.name.clone(),
|
||||
user: if state.user.is_empty() { "root".to_string() } else { state.user.clone() },
|
||||
host: state.host.clone(),
|
||||
port: if state.port.is_empty() { "22".to_string() } else { state.port.clone() },
|
||||
};
|
||||
app.servers.push(new_server);
|
||||
let _ = app.save();
|
||||
app.state.select(Some(app.servers.len() - 1));
|
||||
app.input_mode = InputMode::Normal;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
src/server.rs
Normal file
45
src/server.rs
Normal file
@ -0,0 +1,45 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct Server {
|
||||
pub name: String,
|
||||
pub user: String,
|
||||
pub host: String,
|
||||
pub port: String,
|
||||
}
|
||||
|
||||
impl Server {
|
||||
pub fn address(&self) -> String {
|
||||
format!("{}@{}", self.user, self.host)
|
||||
}
|
||||
|
||||
pub fn to_ssh_args(&self) -> Vec<String> {
|
||||
let mut args = vec![self.address()];
|
||||
if !self.port.is_empty() {
|
||||
args.push("-p".to_string());
|
||||
args.push(self.port.clone());
|
||||
}
|
||||
args
|
||||
}
|
||||
|
||||
pub fn to_mosh_args(&self) -> Vec<String> {
|
||||
let mut args = vec![];
|
||||
if !self.port.is_empty() {
|
||||
args.push("--ssh".to_string());
|
||||
args.push(format!("ssh -p {}", self.port));
|
||||
}
|
||||
args.push(self.address());
|
||||
args
|
||||
}
|
||||
|
||||
pub fn to_copy_id_args(&self) -> Vec<String> {
|
||||
let mut args = vec![];
|
||||
if !self.port.is_empty() {
|
||||
args.push("-p".to_string());
|
||||
args.push(self.port.clone());
|
||||
}
|
||||
args.push(self.address());
|
||||
args
|
||||
}
|
||||
}
|
||||
|
||||
168
src/ui.rs
Normal file
168
src/ui.rs
Normal file
@ -0,0 +1,168 @@
|
||||
use ratatui::{
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
style::{Color, Modifier, Style},
|
||||
widgets::{Block, Borders, List, ListItem, Paragraph, Clear},
|
||||
Frame,
|
||||
};
|
||||
|
||||
use crate::app::{App, InputMode};
|
||||
|
||||
pub fn ui(f: &mut Frame, app: &mut App) {
|
||||
let size = f.size();
|
||||
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([Constraint::Min(0), Constraint::Length(3)].as_ref())
|
||||
.split(size);
|
||||
|
||||
let items: Vec<ListItem> = app
|
||||
.servers
|
||||
.iter()
|
||||
.map(|s| {
|
||||
let content = format!("{} ({}) - {}:{}", s.name, s.user, s.host, s.port);
|
||||
ListItem::new(content).style(Style::default())
|
||||
})
|
||||
.collect();
|
||||
|
||||
let list = List::new(items)
|
||||
.block(Block::default().borders(Borders::ALL).title(" SSHX - Servers "))
|
||||
.highlight_style(Style::default().add_modifier(Modifier::BOLD).fg(Color::Yellow))
|
||||
.highlight_symbol("> ");
|
||||
|
||||
f.render_stateful_widget(list, chunks[0], &mut app.state);
|
||||
|
||||
// Help text
|
||||
let help_text = match app.input_mode {
|
||||
InputMode::Normal => "Enter: Connect | m: Mosh | n: New | Shift+n: Copy ID | i: Edit | d: Delete | q: Quit | j/k: Up/Down",
|
||||
InputMode::Adding(_) => "Enter: Save | Esc: Cancel | Tab: Next Field",
|
||||
InputMode::Editing(_) => "Enter: Save | Esc: Cancel | Tab: Next Field",
|
||||
};
|
||||
let help = Paragraph::new(help_text)
|
||||
.style(Style::default().fg(Color::Gray))
|
||||
.block(Block::default().borders(Borders::ALL).title(" Help "));
|
||||
f.render_widget(help, chunks[1]);
|
||||
|
||||
// Popup for Adding Server
|
||||
if let InputMode::Adding(state) = &app.input_mode {
|
||||
let block = Block::default().borders(Borders::ALL).title(" Add New Connection ");
|
||||
let area = centered_rect(60, 40, size);
|
||||
f.render_widget(Clear, area); // Clear the background
|
||||
f.render_widget(block, area);
|
||||
|
||||
let input_layout = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.margin(2)
|
||||
.constraints(
|
||||
[
|
||||
Constraint::Length(3), // Name
|
||||
Constraint::Length(3), // User
|
||||
Constraint::Length(3), // Host
|
||||
Constraint::Length(3), // Port
|
||||
Constraint::Min(1),
|
||||
]
|
||||
.as_ref(),
|
||||
)
|
||||
.split(area);
|
||||
|
||||
let fields = [
|
||||
("Name", &state.name),
|
||||
("User (default: root)", &state.user),
|
||||
("Host/IP", &state.host),
|
||||
("Port (default: 22)", &state.port),
|
||||
];
|
||||
|
||||
for (i, (label, value)) in fields.iter().enumerate() {
|
||||
let mut style = Style::default();
|
||||
if state.field_idx == i {
|
||||
style = style.fg(Color::Yellow);
|
||||
}
|
||||
let input = Paragraph::new(value.as_str())
|
||||
.style(style)
|
||||
.block(Block::default().borders(Borders::ALL).title(*label));
|
||||
f.render_widget(input, input_layout[i]);
|
||||
|
||||
// Show cursor in the active input field
|
||||
if state.field_idx == i {
|
||||
f.set_cursor(
|
||||
input_layout[i].x + value.len() as u16 + 1, // Position after the text
|
||||
input_layout[i].y + 1, // Middle of the input area
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Popup for Editing Server
|
||||
if let InputMode::Editing(state) = &app.input_mode {
|
||||
let block = Block::default().borders(Borders::ALL).title(" Edit Connection ");
|
||||
let area = centered_rect(60, 40, size);
|
||||
f.render_widget(Clear, area); // Clear the background
|
||||
f.render_widget(block, area);
|
||||
|
||||
let input_layout = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.margin(2)
|
||||
.constraints(
|
||||
[
|
||||
Constraint::Length(3), // Name
|
||||
Constraint::Length(3), // User
|
||||
Constraint::Length(3), // Host
|
||||
Constraint::Length(3), // Port
|
||||
Constraint::Min(1),
|
||||
]
|
||||
.as_ref(),
|
||||
)
|
||||
.split(area);
|
||||
|
||||
let fields = [
|
||||
("Name", &state.name),
|
||||
("User (default: root)", &state.user),
|
||||
("Host/IP", &state.host),
|
||||
("Port (default: 22)", &state.port),
|
||||
];
|
||||
|
||||
for (i, (label, value)) in fields.iter().enumerate() {
|
||||
let mut style = Style::default();
|
||||
if state.field_idx == i {
|
||||
style = style.fg(Color::Yellow);
|
||||
}
|
||||
let input = Paragraph::new(value.as_str())
|
||||
.style(style)
|
||||
.block(Block::default().borders(Borders::ALL).title(*label));
|
||||
f.render_widget(input, input_layout[i]);
|
||||
|
||||
// Show cursor in the active input field
|
||||
if state.field_idx == i {
|
||||
f.set_cursor(
|
||||
input_layout[i].x + value.len() as u16 + 1, // Position after the text
|
||||
input_layout[i].y + 1, // Middle of the input area
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect {
|
||||
let popup_layout = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints(
|
||||
[
|
||||
Constraint::Percentage((100 - percent_y) / 2),
|
||||
Constraint::Percentage(percent_y),
|
||||
Constraint::Percentage((100 - percent_y) / 2),
|
||||
]
|
||||
.as_ref(),
|
||||
)
|
||||
.split(r);
|
||||
|
||||
Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints(
|
||||
[
|
||||
Constraint::Percentage((100 - percent_x) / 2),
|
||||
Constraint::Percentage(percent_x),
|
||||
Constraint::Percentage((100 - percent_x) / 2),
|
||||
]
|
||||
.as_ref(),
|
||||
)
|
||||
.split(popup_layout[1])[1]
|
||||
}
|
||||
Reference in New Issue
Block a user