diff --git a/Cargo.lock b/Cargo.lock index 7fb1187..bb8bf3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "ahash" @@ -111,15 +111,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", @@ -128,9 +128,9 @@ dependencies = [ [[package]] name = "atom_syndication" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f34613907f31c9dbef0240156db3c9263f34842b6e1a8999d2304ea62c8a30" +checksum = "2a3a5ed3201df5658d1aa45060c5a57dc9dba8a8ada20d696d67cb0c479ee043" dependencies = [ "chrono", "derive_builder", @@ -153,17 +153,17 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets", ] [[package]] @@ -195,9 +195,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "cassowary" @@ -216,9 +216,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.14" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d2eb3cd3d1bf4529e31c215ee6f93ec5a3d536d9f578f93d9d33ee19562932" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" dependencies = [ "shlex", ] @@ -246,9 +246,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.16" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" +checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" dependencies = [ "clap_builder", "clap_derive", @@ -256,9 +256,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" dependencies = [ "anstream", "anstyle", @@ -408,18 +408,18 @@ dependencies = [ [[package]] name = "derive_builder" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0350b5cb0331628a5916d6c5c0b72e97393b8b6b03b47a9284f4e7f5a405ffd7" +checksum = "cd33f37ee6a119146a1781d3356a7c26028f83d779b2e04ecd45fdc75c76877b" dependencies = [ "derive_builder_macro", ] [[package]] name = "derive_builder_core" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d48cda787f839151732d396ac69e3473923d54312c070ee21e9effcaa8ca0b1d" +checksum = "7431fa049613920234f22c47fdc33e6cf3ee83067091ea4277a3f8c4587aae38" dependencies = [ "darling", "proc-macro2", @@ -429,9 +429,9 @@ dependencies = [ [[package]] name = "derive_builder_macro" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" +checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" dependencies = [ "derive_builder_core", "syn", @@ -704,9 +704,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "h2" @@ -825,9 +825,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http", @@ -859,9 +859,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" dependencies = [ "bytes", "futures-channel", @@ -879,9 +879,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -918,9 +918,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown", @@ -936,11 +936,21 @@ dependencies = [ "syn", ] +[[package]] +name = "intuitils" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe41f023631befe1fdb683fbaf9af116277e39ad99a5580a61ac3a9616e7f757" +dependencies = [ + "crossterm", + "serde", +] + [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "is-docker" @@ -1077,11 +1087,11 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] @@ -1137,9 +1147,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.3" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] @@ -1400,9 +1410,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.31.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc" dependencies = [ "encoding_rs", "memchr", @@ -1410,9 +1420,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.3" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156" +checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" dependencies = [ "bytes", "pin-project-lite", @@ -1428,9 +1438,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.6" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" dependencies = [ "bytes", "rand", @@ -1445,15 +1455,15 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" +checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" dependencies = [ "libc", "once_cell", "socket2", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1519,9 +1529,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" dependencies = [ "bitflags", ] @@ -1624,6 +1634,7 @@ version = "0.5.0" dependencies = [ "anyhow", "crossterm", + "intuitils", "magnetease", "ratatui", "rm-shared", @@ -1649,9 +1660,9 @@ dependencies = [ [[package]] name = "rss" -version = "2.0.8" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f374fd66bb795938b78c021db1662d43a8ffbc42ec1ac25429fc4833b732751" +checksum = "27e92048f840d98c6d6dd870af9101610ea9ff413f11f1bcebf4f4c31d96d957" dependencies = [ "atom_syndication", "derive_builder", @@ -1673,9 +1684,9 @@ checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags", "errno", @@ -1686,9 +1697,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.12" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ "once_cell", "ring", @@ -1716,9 +1727,9 @@ checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" [[package]] name = "rustls-webpki" -version = "0.102.6" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring", "rustls-pki-types", @@ -1767,11 +1778,11 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1840,18 +1851,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -1860,9 +1871,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.127" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -2058,9 +2069,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.76" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -2178,9 +2189,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -2226,9 +2237,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -2260,9 +2271,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" dependencies = [ "indexmap", "serde", @@ -2365,24 +2376,24 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-truncate" @@ -2537,9 +2548,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.3" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" dependencies = [ "rustls-pki-types", ] diff --git a/Cargo.toml b/Cargo.toml index 48c1038..18c7367 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,8 @@ license = "GPL-3.0-or-later" rm-config = { version = "0.5", path = "rm-config" } rm-shared = { version = "0.5", path = "rm-shared" } +intuitils = "0.0.2" + magnetease = "0.3" anyhow = "1" serde = { version = "1", features = ["derive"] } diff --git a/rm-config/Cargo.toml b/rm-config/Cargo.toml index 3096816..c13a1f0 100644 --- a/rm-config/Cargo.toml +++ b/rm-config/Cargo.toml @@ -22,3 +22,4 @@ crossterm.workspace = true thiserror.workspace = true transmission-rpc.workspace = true magnetease.workspace = true +intuitils.workspace = true diff --git a/rm-config/src/keymap/actions/general.rs b/rm-config/src/keymap/actions/general.rs index dad4414..3bab6c3 100644 --- a/rm-config/src/keymap/actions/general.rs +++ b/rm-config/src/keymap/actions/general.rs @@ -1,9 +1,8 @@ +use intuitils::user_action::UserAction; use rm_shared::action::Action; use serde::{Deserialize, Serialize}; -use super::UserAction; - -#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum GeneralAction { ShowHelp, Quit, diff --git a/rm-config/src/keymap/actions/mod.rs b/rm-config/src/keymap/actions/mod.rs index eb7f88e..74a2ef1 100644 --- a/rm-config/src/keymap/actions/mod.rs +++ b/rm-config/src/keymap/actions/mod.rs @@ -1,13 +1,3 @@ -use rm_shared::action::Action; - pub mod general; pub mod search_tab; pub mod torrents_tab; - -pub trait UserAction: Into { - fn desc(&self) -> &'static str; - fn merge_desc_with(&self, other: &Self) -> Option<&'static str> { - let _ = other; - None - } -} diff --git a/rm-config/src/keymap/actions/search_tab.rs b/rm-config/src/keymap/actions/search_tab.rs index 9231308..b7f8c10 100644 --- a/rm-config/src/keymap/actions/search_tab.rs +++ b/rm-config/src/keymap/actions/search_tab.rs @@ -1,9 +1,8 @@ +use intuitils::user_action::UserAction; use rm_shared::action::Action; use serde::{Deserialize, Serialize}; -use super::UserAction; - -#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum SearchAction { ShowProvidersInfo, } diff --git a/rm-config/src/keymap/actions/torrents_tab.rs b/rm-config/src/keymap/actions/torrents_tab.rs index 411c20c..d783fc3 100644 --- a/rm-config/src/keymap/actions/torrents_tab.rs +++ b/rm-config/src/keymap/actions/torrents_tab.rs @@ -1,9 +1,8 @@ +use intuitils::user_action::UserAction; use rm_shared::action::Action; use serde::{Deserialize, Serialize}; -use super::UserAction; - -#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum TorrentsAction { AddMagnet, MoveTorrent, diff --git a/rm-config/src/keymap/mod.rs b/rm-config/src/keymap/mod.rs index 9fb9a03..b506462 100644 --- a/rm-config/src/keymap/mod.rs +++ b/rm-config/src/keymap/mod.rs @@ -1,372 +1,23 @@ pub mod actions; -use std::{ - borrow::Cow, - collections::{BTreeMap, HashMap}, - io::ErrorKind, - marker::PhantomData, - path::PathBuf, - sync::OnceLock, -}; +use std::{io::ErrorKind, path::PathBuf, sync::OnceLock}; -use actions::{search_tab::SearchAction, UserAction}; use anyhow::{Context, Result}; -use crossterm::event::{ - KeyCode, KeyModifiers as CrosstermKeyModifiers, MediaKeyCode, ModifierKeyCode, -}; -use serde::{ - de::{self, Visitor}, - Deserialize, Serialize, -}; +use intuitils::config::keybindings::KeybindsHolder; +use serde::Deserialize; -use crate::{ - utils::{self, ConfigFetchingError}, - CONFIG, -}; +use crate::utils::{self, ConfigFetchingError}; use rm_shared::action::Action; -use self::actions::{general::GeneralAction, torrents_tab::TorrentsAction}; +pub use self::actions::{ + general::GeneralAction, search_tab::SearchAction, torrents_tab::TorrentsAction, +}; -#[derive(Serialize, Deserialize, Clone)] +#[derive(Deserialize, Clone)] pub struct KeymapConfig { - pub general: KeybindsHolder, - pub torrents_tab: KeybindsHolder, - pub search_tab: KeybindsHolder, - #[serde(skip)] - pub general_keymap: HashMap<(KeyCode, CrosstermKeyModifiers), Action>, - #[serde(skip)] - pub torrent_keymap: HashMap<(KeyCode, CrosstermKeyModifiers), Action>, - #[serde(skip)] - pub search_keymap: HashMap<(KeyCode, CrosstermKeyModifiers), Action>, -} - -#[derive(Serialize, Deserialize, Clone)] -pub struct KeybindsHolder + UserAction> { - pub keybindings: Vec>, -} - -impl KeybindsHolder { - const KEYS_DELIMITER: &'static str = ", "; - - pub fn get_help_repr(&self) -> Vec<(String, &'static str)> { - let mut keys: BTreeMap<&T, Vec> = BTreeMap::new(); - for keybinding in &self.keybindings { - if !keybinding.show_in_help { - continue; - } - - keys.entry(&keybinding.action) - .or_default() - .push(keybinding.keycode_string().into()); - } - - let mut new_keys = vec![]; - - for (action, keycodes) in keys { - new_keys.push((action, keycodes)); - } - - let mut res = vec![]; - let mut skip_next_loop = false; - for (idx, (action, keycodes)) in new_keys.iter().enumerate() { - if skip_next_loop { - skip_next_loop = false; - continue; - } - - if let Some((next_action, next_keycodes)) = new_keys.get(idx + 1) { - if let Some(merged_desc) = action.merge_desc_with(next_action) { - skip_next_loop = true; - let keys = format!( - "{} / {}", - keycodes.join(Self::KEYS_DELIMITER), - next_keycodes.join(Self::KEYS_DELIMITER) - ); - - res.push((keys, merged_desc)); - continue; - } - } - - let keycode_string = keycodes.join(Self::KEYS_DELIMITER); - let desc = action.desc(); - res.push((keycode_string, desc)); - } - - res - } -} - -#[derive(Serialize, Clone)] -pub struct Keybinding { - pub on: KeyCode, - #[serde(default)] - pub modifier: KeyModifier, - pub action: T, - pub show_in_help: bool, -} - -impl Keybinding { - pub fn keycode_string(&self) -> Cow<'static, str> { - let key = match self.on { - KeyCode::Backspace => "Backspace".into(), - KeyCode::Enter => "Enter".into(), - KeyCode::Left => CONFIG.icons.arrow_left.clone().into(), - KeyCode::Right => CONFIG.icons.arrow_right.clone().into(), - KeyCode::Up => CONFIG.icons.arrow_up.clone().into(), - KeyCode::Down => CONFIG.icons.arrow_down.clone().into(), - KeyCode::Home => "Home".into(), - KeyCode::End => "End".into(), - KeyCode::PageUp => "PageUp".into(), - KeyCode::PageDown => "PageDown".into(), - KeyCode::Tab => "Tab".into(), - KeyCode::BackTab => "BackTab".into(), - KeyCode::Delete => "Delete".into(), - KeyCode::Insert => "Insert".into(), - KeyCode::F(i) => format!("F{i}").into(), - KeyCode::Char(c) => { - if c == ' ' { - Cow::Borrowed("Space") - } else { - Cow::Owned(c.to_string()) - } - } - KeyCode::Null => "Null".into(), - KeyCode::Esc => "Esc".into(), - KeyCode::CapsLock => "CapsLock".into(), - KeyCode::ScrollLock => "ScrollLock".into(), - KeyCode::NumLock => "NumLock".into(), - KeyCode::PrintScreen => "PrintScreen".into(), - KeyCode::Pause => "Pause".into(), - KeyCode::Menu => "Menu".into(), - KeyCode::KeypadBegin => "KeypadBegin".into(), - KeyCode::Media(media) => match media { - MediaKeyCode::Play => "Play", - MediaKeyCode::Pause => "Pause", - MediaKeyCode::PlayPause => "PlayPause", - MediaKeyCode::Reverse => "Reverse", - MediaKeyCode::Stop => "Stop", - MediaKeyCode::FastForward => "FastForward", - MediaKeyCode::Rewind => "Rewind", - MediaKeyCode::TrackNext => "TrackNext", - MediaKeyCode::TrackPrevious => "TrackPrevious", - MediaKeyCode::Record => "Record", - MediaKeyCode::LowerVolume => "LowerVolume", - MediaKeyCode::RaiseVolume => "RaiseVolume", - MediaKeyCode::MuteVolume => "MuteVolume", - } - .into(), - KeyCode::Modifier(modifier) => match modifier { - ModifierKeyCode::LeftShift => "LeftShift", - ModifierKeyCode::LeftControl => "LeftControl", - ModifierKeyCode::LeftAlt => "LeftAlt", - ModifierKeyCode::LeftSuper => "LeftSuper", - ModifierKeyCode::LeftHyper => "LeftHyper", - ModifierKeyCode::LeftMeta => "LeftMeta", - ModifierKeyCode::RightShift => "RightShift", - ModifierKeyCode::RightControl => "RightControl", - ModifierKeyCode::RightAlt => "RightAlt", - ModifierKeyCode::RightSuper => "RightSuper", - ModifierKeyCode::RightHyper => "RightHyper", - ModifierKeyCode::RightMeta => "RightMeta", - ModifierKeyCode::IsoLevel3Shift => "IsoLevel3Shift", - ModifierKeyCode::IsoLevel5Shift => "IsoLevel5Shift", - } - .into(), - } - .into(); - - if !self.modifier.is_none() { - format!("{}-{key}", self.modifier.to_str()).into() - } else { - key - } - } -} - -impl Keybinding { - fn new(on: KeyCode, action: T, modifier: Option, show_in_help: bool) -> Self { - Self { - on, - modifier: modifier.unwrap_or(KeyModifier::None), - action, - show_in_help, - } - } -} - -impl<'de, T: Deserialize<'de>> Deserialize<'de> for Keybinding { - fn deserialize(deserializer: D) -> std::prelude::v1::Result - where - D: serde::Deserializer<'de>, - { - #[derive(Deserialize)] - #[serde(field_identifier, rename_all = "snake_case")] - enum Field { - On, - Modifier, - Action, - ShowInHelp, - } - - struct KeybindingVisitor { - phantom: PhantomData, - } - - impl<'de, T: Deserialize<'de>> Visitor<'de> for KeybindingVisitor { - type Value = Keybinding; - - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - formatter.write_str("struct Keybinding") - } - - fn visit_map(self, mut map: A) -> std::prelude::v1::Result - where - A: serde::de::MapAccess<'de>, - { - let mut on = None; - let mut modifier = None; - let mut action = None; - let mut show_in_help = None; - while let Some(key) = map.next_key()? { - match key { - Field::On => { - if on.is_some() { - return Err(de::Error::duplicate_field("on")); - } - let key = map.next_value::()?; - - if key.len() == 1 { - on = Some(KeyCode::Char(key.chars().next().unwrap())); - } else if key.starts_with('F') && (key.len() == 2 || key.len() == 3) { - let which_f = key[1..].parse::().map_err(|_| { - de::Error::invalid_value( - de::Unexpected::Str(&key), - &"something_correct", - ) - })?; - on = Some(KeyCode::F(which_f)); - } else { - on = { - match key.to_lowercase().as_str() { - "enter" => Some(KeyCode::Enter), - "esc" => Some(KeyCode::Esc), - "up" => Some(KeyCode::Up), - "down" => Some(KeyCode::Down), - "left" => Some(KeyCode::Left), - "right" => Some(KeyCode::Right), - "home" => Some(KeyCode::Home), - "end" => Some(KeyCode::End), - "pageup" => Some(KeyCode::PageUp), - "pagedown" => Some(KeyCode::PageDown), - "tab" => Some(KeyCode::Tab), - "backspace" => Some(KeyCode::Backspace), - "delete" => Some(KeyCode::Delete), - - _ => { - return Err(de::Error::invalid_value( - de::Unexpected::Str(&key), - &"something correct", - )) - } - } - }; - } - } - Field::Modifier => { - if modifier.is_some() { - return Err(de::Error::duplicate_field("modifier")); - } - modifier = Some(map.next_value()); - } - Field::Action => { - if action.is_some() { - return Err(de::Error::duplicate_field("action")); - } - action = Some(map.next_value()); - } - Field::ShowInHelp => { - if show_in_help.is_some() { - return Err(de::Error::duplicate_field("action")); - } - show_in_help = Some(map.next_value()); - } - } - } - let on = on.ok_or_else(|| de::Error::missing_field("on"))?; - let action = action.ok_or_else(|| de::Error::missing_field("action"))??; - let modifier = modifier.transpose().unwrap(); - let show_in_help = show_in_help.transpose().unwrap().unwrap_or(true); - - if modifier.is_some() { - if let KeyCode::Char(char) = on { - if char.is_uppercase() { - return Err(de::Error::custom( - "you can't have a modifier with an uppercase letter, sorry", - )); - } - } - } - - Ok(Keybinding::new(on, action, modifier, show_in_help)) - } - } - - const FIELDS: &[&str] = &["on", "modifier", "action"]; - deserializer.deserialize_struct( - "Keybinding", - FIELDS, - KeybindingVisitor { - phantom: PhantomData, - }, - ) - } -} - -#[derive(Serialize, Deserialize, Hash, Clone, Copy, PartialEq, Eq)] -pub enum KeyModifier { - None, - Ctrl, - Shift, - Alt, - Super, - Meta, -} - -impl KeyModifier { - fn to_str(self) -> &'static str { - match self { - KeyModifier::None => "", - KeyModifier::Ctrl => "CTRL", - KeyModifier::Shift => "SHIFT", - KeyModifier::Alt => "ALT", - KeyModifier::Super => "SUPER", - KeyModifier::Meta => "META", - } - } - - fn is_none(self) -> bool { - self == KeyModifier::None - } -} - -impl From for CrosstermKeyModifiers { - fn from(value: KeyModifier) -> Self { - match value { - KeyModifier::None => CrosstermKeyModifiers::NONE, - KeyModifier::Ctrl => CrosstermKeyModifiers::CONTROL, - KeyModifier::Shift => CrosstermKeyModifiers::SHIFT, - KeyModifier::Alt => CrosstermKeyModifiers::ALT, - KeyModifier::Super => CrosstermKeyModifiers::SUPER, - KeyModifier::Meta => CrosstermKeyModifiers::META, - } - } -} - -impl Default for KeyModifier { - fn default() -> Self { - Self::None - } + pub general: KeybindsHolder, + pub torrents_tab: KeybindsHolder, + pub search_tab: KeybindsHolder, } impl KeymapConfig { @@ -375,15 +26,11 @@ impl KeymapConfig { pub fn init() -> Result { match utils::fetch_config::(Self::FILENAME) { - Ok(mut keymap_config) => { - keymap_config.populate_hashmap(); - Ok(keymap_config) - } + Ok(keymap_config) => Ok(keymap_config), Err(e) => match e { ConfigFetchingError::Io(e) if e.kind() == ErrorKind::NotFound => { - let mut keymap_config = + let keymap_config = utils::put_config::(Self::DEFAULT_CONFIG, Self::FILENAME)?; - keymap_config.populate_hashmap(); Ok(keymap_config) } ConfigFetchingError::Toml(e) => Err(e).with_context(|| { @@ -397,57 +44,6 @@ impl KeymapConfig { } } - pub fn get_keys_for_action_joined(&self, action: Action) -> Option { - let keys = self.get_keys_for_action(action)?; - - Some(keys.join("/")) - } - - pub fn get_keys_for_action(&self, action: Action) -> Option>> { - let mut keys = vec![]; - - for keybinding in &self.general.keybindings { - if action == keybinding.action.into() { - keys.push(keybinding.keycode_string().into()); - } - } - - for keybinding in &self.torrents_tab.keybindings { - if action == keybinding.action.into() { - keys.push(keybinding.keycode_string().into()); - } - } - for keybinding in &self.search_tab.keybindings { - if action == keybinding.action.into() { - keys.push(keybinding.keycode_string().into()); - } - } - - if keys.is_empty() { - None - } else { - Some(keys) - } - } - - fn populate_hashmap(&mut self) { - for keybinding in &self.general.keybindings { - let hash_value = (keybinding.on, keybinding.modifier.into()); - self.general_keymap - .insert(hash_value, keybinding.action.into()); - } - for keybinding in &self.torrents_tab.keybindings { - let hash_value = (keybinding.on, keybinding.modifier.into()); - self.torrent_keymap - .insert(hash_value, keybinding.action.into()); - } - for keybinding in &self.search_tab.keybindings { - let hash_value = (keybinding.on, keybinding.modifier.into()); - self.search_keymap - .insert(hash_value, keybinding.action.into()); - } - } - pub fn path() -> &'static PathBuf { static PATH: OnceLock = OnceLock::new(); PATH.get_or_init(|| utils::get_config_path(Self::FILENAME)) diff --git a/rm-main/src/tui/app.rs b/rm-main/src/tui/app.rs index 0da592c..b6ae1d0 100644 --- a/rm-main/src/tui/app.rs +++ b/rm-main/src/tui/app.rs @@ -212,12 +212,12 @@ pub fn event_to_action(ctx: &Ctx, mode: Mode, current_tab: CurrentTab, event: Ev Event::Key(key) => { let keymaps = match current_tab { CurrentTab::Torrents => [ - &CONFIG.keybindings.general_keymap, - &CONFIG.keybindings.torrent_keymap, + &CONFIG.keybindings.general.map, + &CONFIG.keybindings.torrents_tab.map, ], CurrentTab::Search => [ - &CONFIG.keybindings.general_keymap, - &CONFIG.keybindings.search_keymap, + &CONFIG.keybindings.general.map, + &CONFIG.keybindings.search_tab.map, ], }; diff --git a/rm-main/src/tui/global_popups/help.rs b/rm-main/src/tui/global_popups/help.rs index 49d6bac..8f88890 100644 --- a/rm-main/src/tui/global_popups/help.rs +++ b/rm-main/src/tui/global_popups/help.rs @@ -1,3 +1,6 @@ +use std::borrow::Cow; + +use crossterm::event::KeyCode; use ratatui::{ prelude::*, widgets::{Block, Borders, Clear, Paragraph, Scrollbar, ScrollbarOrientation, ScrollbarState}, @@ -49,11 +52,30 @@ impl Scroll { impl HelpPopup { pub fn new(ctx: app::Ctx) -> Self { + fn override_keycode(key: KeyCode) -> Option> { + match key { + KeyCode::Left => Some(CONFIG.icons.arrow_left.as_str().into()), + KeyCode::Right => Some(CONFIG.icons.arrow_right.as_str().into()), + KeyCode::Up => Some(CONFIG.icons.arrow_up.as_str().into()), + KeyCode::Down => Some(CONFIG.icons.arrow_down.as_str().into()), + _ => None, + } + } + let mut max_key_len = 0; let mut max_line_len = 0; - let global_keys = CONFIG.keybindings.general.get_help_repr(); - let torrent_keys = CONFIG.keybindings.torrents_tab.get_help_repr(); - let search_keys = CONFIG.keybindings.search_tab.get_help_repr(); + let global_keys = CONFIG + .keybindings + .general + .get_help_repr_with_override(override_keycode); + let torrent_keys = CONFIG + .keybindings + .torrents_tab + .get_help_repr_with_override(override_keycode); + let search_keys = CONFIG + .keybindings + .search_tab + .get_help_repr_with_override(override_keycode); let mut calc_max_lens = |keys: &[(String, &'static str)]| { for (keycode, desc) in keys { diff --git a/rm-main/src/tui/tabs/search/bottom_bar.rs b/rm-main/src/tui/tabs/search/bottom_bar.rs index a7e7710..dd53daf 100644 --- a/rm-main/src/tui/tabs/search/bottom_bar.rs +++ b/rm-main/src/tui/tabs/search/bottom_bar.rs @@ -5,7 +5,7 @@ use ratatui::{ widgets::Paragraph, Frame, }; -use rm_config::CONFIG; +use rm_config::{keymap::SearchAction, CONFIG}; use rm_shared::action::{Action, UpdateAction}; use throbber_widgets_tui::ThrobberState; @@ -137,7 +137,8 @@ impl Component for SearchState { let append_key_info = |line: &mut Line| { let providers_key = CONFIG .keybindings - .get_keys_for_action_joined(Action::ShowProvidersInfo); + .search_tab + .get_keys_for_action_joined(SearchAction::ShowProvidersInfo); if let Some(key) = providers_key { line.push_span(Span::raw("Press ")); line.push_span(Span::styled(key, keybinding_style())); diff --git a/rm-main/src/tui/tabs/torrents/popups/details.rs b/rm-main/src/tui/tabs/torrents/popups/details.rs index 016964e..2b2f523 100644 --- a/rm-main/src/tui/tabs/torrents/popups/details.rs +++ b/rm-main/src/tui/tabs/torrents/popups/details.rs @@ -2,7 +2,7 @@ use ratatui::{ prelude::*, widgets::{block::Title, Block, BorderType, Clear, Paragraph, Wrap}, }; -use rm_config::CONFIG; +use rm_config::{keymap::TorrentsAction, CONFIG}; use rm_shared::{action::Action, utils::bytes_to_human_format}; use style::Styled; @@ -86,7 +86,8 @@ impl Component for DetailsPopup { show_files_line.push_span(Span::styled( CONFIG .keybindings - .get_keys_for_action_joined(Action::ShowFiles) + .torrents_tab + .get_keys_for_action_joined(TorrentsAction::ShowFiles) .unwrap_or_default(), keybinding_style(), )); @@ -96,7 +97,8 @@ impl Component for DetailsPopup { move_location_line.push_span(Span::styled( CONFIG .keybindings - .get_keys_for_action_joined(Action::MoveTorrent) + .torrents_tab + .get_keys_for_action_joined(TorrentsAction::MoveTorrent) .unwrap_or_default(), keybinding_style(), )); @@ -106,7 +108,8 @@ impl Component for DetailsPopup { delete_line.push_span(Span::styled( CONFIG .keybindings - .get_keys_for_action_joined(Action::Delete) + .torrents_tab + .get_keys_for_action_joined(TorrentsAction::Delete) .unwrap_or_default(), keybinding_style(), )); @@ -116,7 +119,8 @@ impl Component for DetailsPopup { change_category_line.push_span(Span::styled( CONFIG .keybindings - .get_keys_for_action_joined(Action::ChangeCategory) + .torrents_tab + .get_keys_for_action_joined(TorrentsAction::ChangeCategory) .unwrap_or_default(), keybinding_style(), )); diff --git a/rm-main/src/tui/tabs/torrents/popups/files.rs b/rm-main/src/tui/tabs/torrents/popups/files.rs index bdbfc86..c8fc6cb 100644 --- a/rm-main/src/tui/tabs/torrents/popups/files.rs +++ b/rm-main/src/tui/tabs/torrents/popups/files.rs @@ -8,7 +8,7 @@ use ratatui::{ Clear, Paragraph, }, }; -use rm_config::CONFIG; +use rm_config::{keymap::GeneralAction, CONFIG}; use tokio::{sync::oneshot, task::JoinHandle}; use transmission_rpc::types::{Id, Torrent, TorrentSetArgs}; use tui_tree_widget::{Tree, TreeItem, TreeState}; @@ -285,13 +285,21 @@ impl Component for FilesPopup { if CONFIG.general.beginner_mode { let mut keys = vec![]; - if let Some(key) = CONFIG.keybindings.get_keys_for_action_joined(Action::Select) { + if let Some(key) = CONFIG + .keybindings + .general + .get_keys_for_action_joined(GeneralAction::Select) + { keys.push(Span::raw(" ")); keys.push(Span::styled(key, keybinding_style())); keys.push(Span::raw(" - toggle | ")); } - if let Some(key) = CONFIG.keybindings.get_keys_for_action_joined(Action::XdgOpen) { + if let Some(key) = CONFIG + .keybindings + .general + .get_keys_for_action_joined(GeneralAction::XdgOpen) + { keys.push(Span::styled(key, keybinding_style())); keys.push(Span::raw(" - xdg_open ")); } diff --git a/rm-main/src/tui/tabs/torrents/tasks/default.rs b/rm-main/src/tui/tabs/torrents/tasks/default.rs index 0af668c..45f46d4 100644 --- a/rm-main/src/tui/tabs/torrents/tasks/default.rs +++ b/rm-main/src/tui/tabs/torrents/tasks/default.rs @@ -1,6 +1,5 @@ use ratatui::prelude::*; -use rm_config::CONFIG; -use rm_shared::action::Action; +use rm_config::{keymap::GeneralAction, CONFIG}; use crate::tui::components::{keybinding_style, Component}; @@ -18,7 +17,11 @@ impl Component for Default { let mut line_is_empty = true; if CONFIG.general.beginner_mode { - if let Some(keys) = CONFIG.keybindings.get_keys_for_action(Action::ShowHelp) { + if let Some(keys) = CONFIG + .keybindings + .general + .get_keys_for_action(GeneralAction::ShowHelp) + { line.push_span(Span::raw(format!("{} ", CONFIG.icons.help))); line_is_empty = false; let keys_len = keys.len(); @@ -30,7 +33,11 @@ impl Component for Default { } line.push_span(Span::raw(" - help")); } - if let Some(keys) = CONFIG.keybindings.get_keys_for_action_joined(Action::Confirm) { + if let Some(keys) = CONFIG + .keybindings + .general + .get_keys_for_action_joined(GeneralAction::Confirm) + { if !line_is_empty { line.push_span(Span::raw(" | ")); } else { diff --git a/rm-main/src/tui/tabs/torrents/tasks/selection.rs b/rm-main/src/tui/tabs/torrents/tasks/selection.rs index 8fbf523..f518c6d 100644 --- a/rm-main/src/tui/tabs/torrents/tasks/selection.rs +++ b/rm-main/src/tui/tabs/torrents/tasks/selection.rs @@ -1,6 +1,5 @@ use crate::tui::components::{keybinding_style, Component}; -use rm_config::CONFIG; -use rm_shared::action::Action; +use rm_config::{keymap::GeneralAction, CONFIG}; use ratatui::{prelude::*, text::Span}; @@ -19,7 +18,11 @@ impl Component for Selection { let mut line = Line::default(); let mut line_is_empty = true; - if let Some(keys) = CONFIG.keybindings.get_keys_for_action_joined(Action::Close) { + if let Some(keys) = CONFIG + .keybindings + .general + .get_keys_for_action_joined(GeneralAction::Close) + { line_is_empty = false; line.push_span(Span::styled(keys, keybinding_style())); line.push_span(Span::raw(" - clear selection")); diff --git a/rm-main/src/tui/tabs/torrents/tasks/sort.rs b/rm-main/src/tui/tabs/torrents/tasks/sort.rs index 382014a..b36e022 100644 --- a/rm-main/src/tui/tabs/torrents/tasks/sort.rs +++ b/rm-main/src/tui/tabs/torrents/tasks/sort.rs @@ -1,5 +1,4 @@ -use rm_config::CONFIG; -use rm_shared::action::Action; +use rm_config::{keymap::GeneralAction, CONFIG}; use ratatui::prelude::*; @@ -18,13 +17,21 @@ impl Component for Sort { let mut line = Line::default(); let mut line_is_empty = true; - if let Some(keys) = CONFIG.keybindings.get_keys_for_action_joined(Action::Close) { + if let Some(keys) = CONFIG + .keybindings + .general + .get_keys_for_action_joined(GeneralAction::Close) + { line_is_empty = false; line.push_span(Span::styled(keys, keybinding_style())); line.push_span(Span::raw(" - reset & exit")); } - if let Some(keys) = CONFIG.keybindings.get_keys_for_action_joined(Action::Confirm) { + if let Some(keys) = CONFIG + .keybindings + .general + .get_keys_for_action_joined(GeneralAction::Confirm) + { if !line_is_empty { line.push_span(Span::raw(" | ")); } @@ -33,7 +40,11 @@ impl Component for Sort { line.push_span(Span::raw(" - apply")); } - if let Some(keys) = CONFIG.keybindings.get_keys_for_action_joined(Action::Down) { + if let Some(keys) = CONFIG + .keybindings + .general + .get_keys_for_action_joined(GeneralAction::Down) + { if !line_is_empty { line.push_span(Span::raw(" | ")); }