Commit f7dc24b611

f7dc24b6113ac61fba5cfe0a7bd1899fafe5a517

parent: fde98b5a5b

Unsigned

Siriusmart <71584876+Siriusmart@users.noreply.github.com> · 2022-09-25 17:20 UTC

all search items + docs

Layout: unified · split

Cargo.lock +54 −54
@@ -273,9 +273,9 @@ dependencies = [
273273
274274[[package]]
275275name = "exr"
276version = "1.5.0"
276version = "1.5.1"
277277source = "registry+https://github.com/rust-lang/crates.io-index"
278checksum = "78c26a90d9dd411a3d119d6f55752fb4c134ca243250c32fb9cab7b2561638d2"
278checksum = "c9a7880199e74c6d3fe45579df2f436c5913a71405494cb89d59234d86b47dc5"
279279dependencies = [
280280 "bit_field",
281281 "flume",
@@ -582,14 +582,13 @@ dependencies = [
582582
583583[[package]]
584584name = "iana-time-zone"
585version = "0.1.47"
585version = "0.1.50"
586586source = "registry+https://github.com/rust-lang/crates.io-index"
587checksum = "4c495f162af0bf17656d0014a0eded5f3cd2f365fdd204548c2869db89359dc7"
587checksum = "fd911b35d940d2bd0bea0f9100068e5b97b51a1cbe13d13382f132e0365257a0"
588588dependencies = [
589589 "android_system_properties",
590590 "core-foundation-sys",
591591 "js-sys",
592 "once_cell",
593592 "wasm-bindgen",
594593 "winapi 0.3.9",
595594]
@@ -676,9 +675,9 @@ dependencies = [
676675
677676[[package]]
678677name = "js-sys"
679version = "0.3.59"
678version = "0.3.60"
680679source = "registry+https://github.com/rust-lang/crates.io-index"
681checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2"
680checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47"
682681dependencies = [
683682 "wasm-bindgen",
684683]
@@ -713,15 +712,15 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
713712
714713[[package]]
715714name = "libc"
716version = "0.2.132"
715version = "0.2.133"
717716source = "registry+https://github.com/rust-lang/crates.io-index"
718checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
717checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966"
719718
720719[[package]]
721720name = "lock_api"
722version = "0.4.8"
721version = "0.4.9"
723722source = "registry+https://github.com/rust-lang/crates.io-index"
724checksum = "9f80bf5aacaf25cbfc8210d1cfb718f2bf3b11c4c54e5afe36c236853a8ec390"
723checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df"
725724dependencies = [
726725 "autocfg",
727726 "scopeguard",
@@ -862,9 +861,9 @@ dependencies = [
862861
863862[[package]]
864863name = "once_cell"
865version = "1.14.0"
864version = "1.15.0"
866865source = "registry+https://github.com/rust-lang/crates.io-index"
867checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0"
866checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
868867
869868[[package]]
870869name = "openssl"
@@ -992,9 +991,9 @@ dependencies = [
992991
993992[[package]]
994993name = "proc-macro2"
995version = "1.0.43"
994version = "1.0.44"
996995source = "registry+https://github.com/rust-lang/crates.io-index"
997checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab"
996checksum = "7bd7356a8122b6c4a24a82b278680c73357984ca2fc79a0f9fa6dea7dced7c58"
998997dependencies = [
999998 "unicode-ident",
1000999]
@@ -1071,9 +1070,9 @@ dependencies = [
10711070
10721071[[package]]
10731072name = "reqwest"
1074version = "0.11.11"
1073version = "0.11.12"
10751074source = "registry+https://github.com/rust-lang/crates.io-index"
1076checksum = "b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92"
1075checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc"
10771076dependencies = [
10781077 "base64",
10791078 "bytes",
@@ -1087,10 +1086,10 @@ dependencies = [
10871086 "hyper-tls",
10881087 "ipnet",
10891088 "js-sys",
1090 "lazy_static 1.4.0",
10911089 "log",
10921090 "mime",
10931091 "native-tls",
1092 "once_cell",
10941093 "percent-encoding",
10951094 "pin-project-lite",
10961095 "serde",
@@ -1108,9 +1107,9 @@ dependencies = [
11081107
11091108[[package]]
11101109name = "rgb"
1111version = "0.8.33"
1110version = "0.8.34"
11121111source = "registry+https://github.com/rust-lang/crates.io-index"
1113checksum = "c3b221de559e4a29df3b957eec92bc0de6bc8eaf6ca9cfed43e5e1d67ff65a34"
1112checksum = "3603b7d71ca82644f79b5a06d1220e9a58ede60bd32255f698cb1af8838b8db3"
11141113dependencies = [
11151114 "bytemuck",
11161115]
@@ -1178,18 +1177,18 @@ dependencies = [
11781177
11791178[[package]]
11801179name = "serde"
1181version = "1.0.144"
1180version = "1.0.145"
11821181source = "registry+https://github.com/rust-lang/crates.io-index"
1183checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860"
1182checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b"
11841183dependencies = [
11851184 "serde_derive",
11861185]
11871186
11881187[[package]]
11891188name = "serde_derive"
1190version = "1.0.144"
1189version = "1.0.145"
11911190source = "registry+https://github.com/rust-lang/crates.io-index"
1192checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00"
1191checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c"
11931192dependencies = [
11941193 "proc-macro2",
11951194 "quote",
@@ -1221,9 +1220,9 @@ dependencies = [
12211220
12221221[[package]]
12231222name = "serde_yaml"
1224version = "0.9.11"
1223version = "0.9.13"
12251224source = "registry+https://github.com/rust-lang/crates.io-index"
1226checksum = "89f31df3f50926cdf2855da5fd8812295c34752cb20438dae42a67f79e021ac3"
1225checksum = "8613d593412a0deb7bbd8de9d908efff5a0cb9ccd8f62c641e7b2ed2f57291d1"
12271226dependencies = [
12281227 "indexmap",
12291228 "itoa",
@@ -1318,9 +1317,9 @@ dependencies = [
13181317
13191318[[package]]
13201319name = "syn"
1321version = "1.0.99"
1320version = "1.0.100"
13221321source = "registry+https://github.com/rust-lang/crates.io-index"
1323checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13"
1322checksum = "52205623b1b0f064a4e71182c3b18ae902267282930c6d5462c91b859668426e"
13241323dependencies = [
13251324 "proc-macro2",
13261325 "quote",
@@ -1416,9 +1415,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
14161415
14171416[[package]]
14181417name = "tokio"
1419version = "1.21.0"
1418version = "1.21.1"
14201419source = "registry+https://github.com/rust-lang/crates.io-index"
1421checksum = "89797afd69d206ccd11fb0ea560a44bbb87731d020670e79416d442919257d42"
1420checksum = "0020c875007ad96677dcc890298f4b942882c5d4eb7cc8f439fc3bf813dc9c95"
14221421dependencies = [
14231422 "autocfg",
14241423 "bytes",
@@ -1536,30 +1535,30 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
15361535
15371536[[package]]
15381537name = "unicode-ident"
1539version = "1.0.3"
1538version = "1.0.4"
15401539source = "registry+https://github.com/rust-lang/crates.io-index"
1541checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
1540checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd"
15421541
15431542[[package]]
15441543name = "unicode-normalization"
1545version = "0.1.21"
1544version = "0.1.22"
15461545source = "registry+https://github.com/rust-lang/crates.io-index"
1547checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6"
1546checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
15481547dependencies = [
15491548 "tinyvec",
15501549]
15511550
15521551[[package]]
15531552name = "unicode-segmentation"
1554version = "1.9.0"
1553version = "1.10.0"
15551554source = "registry+https://github.com/rust-lang/crates.io-index"
1556checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99"
1555checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a"
15571556
15581557[[package]]
15591558name = "unicode-width"
1560version = "0.1.9"
1559version = "0.1.10"
15611560source = "registry+https://github.com/rust-lang/crates.io-index"
1562checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
1561checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
15631562
15641563[[package]]
15651564name = "unsafe-any"
@@ -1572,9 +1571,9 @@ dependencies = [
15721571
15731572[[package]]
15741573name = "unsafe-libyaml"
1575version = "0.2.2"
1574version = "0.2.4"
15761575source = "registry+https://github.com/rust-lang/crates.io-index"
1577checksum = "931179334a56395bcf64ba5e0ff56781381c1a5832178280c7d7f91d1679aeb0"
1576checksum = "c1e5fa573d8ac5f1a856f8d7be41d390ee973daf97c806b2c1a465e4e1406e68"
15781577
15791578[[package]]
15801579name = "url"
@@ -1635,9 +1634,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
16351634
16361635[[package]]
16371636name = "wasm-bindgen"
1638version = "0.2.82"
1637version = "0.2.83"
16391638source = "registry+https://github.com/rust-lang/crates.io-index"
1640checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d"
1639checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
16411640dependencies = [
16421641 "cfg-if",
16431642 "wasm-bindgen-macro",
@@ -1645,9 +1644,9 @@ dependencies = [
16451644
16461645[[package]]
16471646name = "wasm-bindgen-backend"
1648version = "0.2.82"
1647version = "0.2.83"
16491648source = "registry+https://github.com/rust-lang/crates.io-index"
1650checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f"
1649checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
16511650dependencies = [
16521651 "bumpalo",
16531652 "log",
@@ -1660,9 +1659,9 @@ dependencies = [
16601659
16611660[[package]]
16621661name = "wasm-bindgen-futures"
1663version = "0.4.32"
1662version = "0.4.33"
16641663source = "registry+https://github.com/rust-lang/crates.io-index"
1665checksum = "fa76fb221a1f8acddf5b54ace85912606980ad661ac7a503b4570ffd3a624dad"
1664checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d"
16661665dependencies = [
16671666 "cfg-if",
16681667 "js-sys",
@@ -1672,9 +1671,9 @@ dependencies = [
16721671
16731672[[package]]
16741673name = "wasm-bindgen-macro"
1675version = "0.2.82"
1674version = "0.2.83"
16761675source = "registry+https://github.com/rust-lang/crates.io-index"
1677checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602"
1676checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
16781677dependencies = [
16791678 "quote",
16801679 "wasm-bindgen-macro-support",
@@ -1682,9 +1681,9 @@ dependencies = [
16821681
16831682[[package]]
16841683name = "wasm-bindgen-macro-support"
1685version = "0.2.82"
1684version = "0.2.83"
16861685source = "registry+https://github.com/rust-lang/crates.io-index"
1687checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da"
1686checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
16881687dependencies = [
16891688 "proc-macro2",
16901689 "quote",
@@ -1695,15 +1694,15 @@ dependencies = [
16951694
16961695[[package]]
16971696name = "wasm-bindgen-shared"
1698version = "0.2.82"
1697version = "0.2.83"
16991698source = "registry+https://github.com/rust-lang/crates.io-index"
1700checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a"
1699checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
17011700
17021701[[package]]
17031702name = "web-sys"
1704version = "0.3.59"
1703version = "0.3.60"
17051704source = "registry+https://github.com/rust-lang/crates.io-index"
1706checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1"
1705checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
17071706dependencies = [
17081707 "js-sys",
17091708 "wasm-bindgen",
@@ -1822,6 +1821,7 @@ dependencies = [
18221821 "invidious",
18231822 "reqwest",
18241823 "serde",
1824 "serde_json",
18251825 "serde_yaml",
18261826 "tokio",
18271827 "tui",
Cargo.toml +1 −1
@@ -27,5 +27,5 @@ dyn-clone = "1.0"
2727tokio = "1.21"
2828futures = "0.3"
2929reqwest = "0.11"
30# serde_json = "1.0"
30serde_json = "1.0"
3131tui-additions = {path = "../../Rust/Packages/tui-additions", default-features = false, features = ["framework", "widgets"]}
README.md +2 −1
@@ -41,10 +41,11 @@ An aesthetically pleasing YouTube TUI written in Rust.
4141>
4242> - Config files (mostly, more options will be added when I get to that part)
4343> - Home and search page
44> - Search fully functional
4445>
4546> #### To do before release
4647>
47> - All pages (video/playlist/channel info)
48> - Item info, channels page
4849> - Watch history
4950> - Basically back to where it is before the rewrite
5051
src/config/appearance.rs +20 −1
@@ -1,8 +1,10 @@
1use super::{serde::BorderTypeSerde, ConfigTrait};
1use super::serde::BorderTypeSerde;
2use crate::global::traits::ConfigTrait;
23use serde::{Deserialize, Serialize};
34use tui::{style::Color, widgets::BorderType};
45use typemap::Key;
56
7/// `appearance.yml`, impl serde version of AppearanceConfig
68#[derive(Default, Serialize, Deserialize, Clone)]
79pub struct AppearanceConfigSerde {
810 #[serde(default)]
@@ -11,12 +13,14 @@ pub struct AppearanceConfigSerde {
1113 pub colors: ColorsConfig,
1214}
1315
16/// `appearance.yml`, this struct is stored in `data.global`
1417#[derive(Clone)]
1518pub struct AppearanceConfig {
1619 pub borders: BorderType,
1720 pub colors: ColorsConfig,
1821}
1922
23/// Includes all configurable colors
2024#[derive(Clone, Copy, Serialize, Deserialize)]
2125pub struct ColorsConfig {
2226 #[serde(default = "outline_default")]
@@ -39,6 +43,7 @@ pub struct ColorsConfig {
3943 pub item_info: ItemInfoColors,
4044}
4145
46/// Colors used by ItemInfo
4247#[derive(Clone, Copy, Serialize, Deserialize)]
4348pub struct ItemInfoColors {
4449 #[serde(default = "tag_default")]
@@ -55,6 +60,10 @@ pub struct ItemInfoColors {
5560 pub length: Color,
5661 #[serde(default = "published_default")]
5762 pub published: Color,
63 #[serde(default = "video_count_default")]
64 pub video_count: Color,
65 #[serde(default = "sub_count_default")]
66 pub sub_count: Color,
5867}
5968
6069impl Default for ColorsConfig {
@@ -83,6 +92,8 @@ impl Default for ItemInfoColors {
8392 viewcount: viewcount_default(),
8493 length: length_default(),
8594 published: published_default(),
95 video_count: video_count_default(),
96 sub_count: sub_count_default(),
8697 }
8798 }
8899}
@@ -165,3 +176,11 @@ fn length_default() -> Color {
165176fn published_default() -> Color {
166177 Color::LightMagenta
167178}
179
180fn video_count_default() -> Color {
181 Color::Rgb(131, 141, 255)
182}
183
184fn sub_count_default() -> Color {
185 Color::LightYellow
186}
src/config/keybindings.rs +3 −2
@@ -1,5 +1,4 @@
1use super::ConfigTrait;
2use crate::global::keyaction::KeyAction;
1use crate::global::{structs::KeyAction, traits::ConfigTrait};
32use crossterm::event::KeyCode;
43use serde::{Deserialize, Serialize};
54use std::collections::HashMap;
@@ -9,6 +8,7 @@ use typemap::Key;
98// The inner HashMap<u8, KeyAction> gets the action using a u8 representing a key modifier
109// The u8 for each modifier key can be found in https://docs.rs/crossterm/latest/src/crossterm/event.rs.html#587-603
1110// The sum of u8 for each key modifier would mean having all of those modifiers at the same time
11/// `keybindings.yml`, contains a hashmap of key + key modifier to action pair
1212#[derive(Serialize, Deserialize, Clone)]
1313pub struct KeyBindingsConfig(pub HashMap<KeyCode, HashMap<u8, KeyAction>>);
1414
@@ -60,6 +60,7 @@ impl Default for KeyBindingsConfig {
6060 r.insert(2, KeyAction::Reload);
6161 map.insert(KeyCode::Char('r'), r);
6262
63 // vim keybindings
6364 let mut h = HashMap::new();
6465 h.insert(0, KeyAction::MoveLeft);
6566 map.insert(KeyCode::Char('h'), h);
src/config/main.rs +2 −1
@@ -1,8 +1,9 @@
1use super::ConfigTrait;
1use crate::global::traits::ConfigTrait;
22use serde::{Deserialize, Serialize};
33use std::collections::HashMap;
44use typemap::Key;
55
6/// `main.yml`, the main config file
67#[derive(Serialize, Deserialize, Clone)]
78pub struct MainConfig {
89 #[serde(default = "invidious_instance_default")]
src/config/mod.rs +1 −2
@@ -1,5 +1,4 @@
1mod configtrait;
2pub use configtrait::*;
1//! Structs for config files, all impl ConfigTrait, config files are stored in `~./config`
32mod main;
43pub use main::*;
54mod appearance;
src/config/pages.rs +15 −7
@@ -1,14 +1,15 @@
1use super::ConfigTrait;
2use crate::items::{ItemList, MessageBar, PageButton, SearchBar, SearchFilter};
1use crate::{
2 global::traits::ConfigTrait,
3 items::{ItemList, MessageBar, PageButton, SearchBar, SearchFilter},
4};
35use serde::{Deserialize, Serialize};
46use std::slice;
57use tui::layout::Constraint;
68use tui_additions::framework::{Framework, FrameworkItem, Row, RowItem, State};
79use typemap::Key;
810
9// Minimum screen dimention for the tui to display without panicking,
11/// Minimum screen dimention for the tui to display without panicking, stored in `data.state`
1012// is automatically generated from PageConfig
11// will be inserted into `framework.data.state`
1213#[derive(Clone, Copy)]
1314pub struct MinDimentions {
1415 pub width: u16,
@@ -34,6 +35,7 @@ impl Key for MinDimentions {
3435 type Value = Self;
3536}
3637
38/// Layout for all pages
3739#[derive(Clone, Serialize, Deserialize)]
3840pub struct PagesConfig {
3941 #[serde(default = "main_menu_default")]
@@ -62,6 +64,7 @@ impl Default for PagesConfig {
6264// This struct impls Into<State>, the corresponding page is converted into State on page load
6365// Each page has its own minimum width and height, which is automatically determined by the items in the page
6466// If it doesn't meet the minimum dimentions, a "protective screen" will be shown to prevent panicking
67/// Layout for one single page
6568#[derive(Clone, Serialize, Deserialize)]
6669pub struct PageConfig {
6770 pub layout: Vec<PageRow>,
@@ -69,6 +72,7 @@ pub struct PageConfig {
6972}
7073
7174impl PageConfig {
75 /// Calculates minimum width for all items to display
7276 pub fn min_width(&self) -> u16 {
7377 self.layout
7478 .iter()
@@ -81,6 +85,7 @@ impl PageConfig {
8185 .unwrap()
8286 }
8387
88 /// Calculates minimum height for all items to display
8489 pub fn min_height(&self) -> u16 {
8590 self.layout
8691 .iter()
@@ -93,6 +98,7 @@ impl PageConfig {
9398 .sum::<u16>()
9499 }
95100
101 /// Converts itself into `State` to be used in `Framework`
96102 pub fn to_state(&self, framework: &mut Framework) -> State {
97103 State(
98104 self.layout
@@ -115,7 +121,7 @@ impl PageConfig {
115121 }
116122}
117123
118// CenteredRow will have its items centered, while NonCenteredRow will align to the left
124/// CenteredRow will have its items centered, while NonCenteredRow will align to the left
119125#[derive(Clone, Serialize, Deserialize)]
120126pub enum PageRow {
121127 CenteredRow(Vec<PageItems>),
@@ -148,6 +154,7 @@ impl PageRow {
148154// PageItems will be converted into Box<dyn FrameworkItem> on page load to be used an item in the framework
149155// Seen https://docs.rs/tui-additions/latest/tui_additions/framework/trait.FrameworkItem.html
150156// Each item has a minimum width and height for it to render without panicking
157/// All avaliable items for `PageConfig`
151158#[derive(Clone, Copy, Serialize, Deserialize)]
152159pub enum PageItems {
153160 SearchBar,
@@ -159,13 +166,14 @@ pub enum PageItems {
159166}
160167
161168impl PageItems {
162 pub fn to_framework_item(&self, framework: &mut Framework) -> Box<dyn FrameworkItem> {
169 /// Converts `Self` into a `FrameworkItem` to be used in `State`
170 pub fn to_framework_item(&self, _framework: &mut Framework) -> Box<dyn FrameworkItem> {
163171 match *self {
164172 Self::SearchBar => Box::new(SearchBar::default()),
165173 Self::Popular => Box::new(PageButton::Popular),
166174 Self::Trending => Box::new(PageButton::Trending),
167175 Self::MessageBar => Box::new(MessageBar::default()),
168 Self::ItemList => Box::new(ItemList::new(framework)),
176 Self::ItemList => Box::new(ItemList::default()),
169177 Self::SearchFilters => Box::new(SearchFilter::default()),
170178 }
171179 }
src/config/search.rs +14 −20
@@ -1,12 +1,12 @@
1use crate::{
2 config::ConfigTrait,
3 global::{message::Message, traits::asurlstring::AsUrlString},
1use crate::global::{
2 structs::Message,
3 traits::{AsUrlString, ConfigTrait, SearchFilterItem},
44};
55use serde::{Deserialize, Serialize};
6use tui_additions::framework::FrameworkClean;
76use typemap::Key;
87
98// can be turned into URL Params for the search term with filters
9/// Search query & filters
1010#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
1111pub struct Search {
1212 pub query: String,
@@ -34,8 +34,7 @@ impl ToString for Search {
3434 }
3535}
3636
37// Search filters
38
37/// Search filters, read comments for function docs
3938#[derive(Default, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
4039pub struct SearchFilters {
4140 pub sort: SearchFilterSort,
@@ -44,7 +43,12 @@ pub struct SearchFilters {
4443 pub r#type: SearchFilterType,
4544}
4645
46// These functions are used in the search filter item
47// Think of the ordering of stuff in the popup menu
4748impl SearchFilters {
49 // This function returns [(Option name, [Options])]
50 // Option name is a string like "sory by" and "type"
51 // Options are the options that you can select like "relevance" and "upload date" for sorting
4852 pub fn get_all() -> [(&'static str, Vec<&'static str>); 5] {
4953 [
5054 (SearchFilterSort::NAME, SearchFilterSort::ordering()),
@@ -55,6 +59,8 @@ impl SearchFilters {
5559 ]
5660 }
5761
62 // uses the index of the selected option name to get the index of the selected option
63 // aka using the hover location of the left textlist to get the hover location of the right text list
5864 pub fn get_selected(&self, index: usize) -> usize {
5965 match index {
6066 0 => self.sort.selected_index(),
@@ -66,8 +72,9 @@ impl SearchFilters {
6672 }
6773 }
6874
75 // saves the settings for a filter given the index of the option (among other options) and the index of the selected options
76 // v left textlist v right textlist
6977 pub fn set_index(&mut self, index_at: usize, set_index: usize, message: &mut Message) {
70 // panic!("function ran");
7178 match index_at {
7279 0 => self.sort = SearchFilterSort::at_index(set_index),
7380 1 => self.date = SearchFilterDate::at_index(set_index),
@@ -86,7 +93,6 @@ impl SearchFilters {
8693
8794 pub fn reset(&mut self, message: &mut Message) {
8895 *self = Self::default();
89
9096 *message = Message::Success(String::from("Search filters has been reset"));
9197 }
9298}
@@ -211,18 +217,6 @@ impl AsUrlString for SearchFilterType {
211217 const TAG: &'static str = "type";
212218}
213219
214pub trait SearchFilterItem
215where
216 Self: Sized,
217{
218 const NAME: &'static str;
219
220 fn option_name(&self) -> &'static str;
221 fn ordering() -> Vec<&'static str>;
222 fn selected_index(&self) -> usize;
223 fn at_index(index: usize) -> Self;
224}
225
226220const SORT_ORDERING: [SearchFilterSort; 4] = [
227221 SearchFilterSort::Relevance,
228222 SearchFilterSort::Rating,
src/config/serde.rs +2 −1
@@ -1,8 +1,9 @@
1// Structs that impl Into<WhatEverStruct> because WhatEverStruct does not impl Serde
1//! Structs that impl `Into<T>` because `T` does not impl Serde but is used in config files
22
33use serde::{Deserialize, Serialize};
44use tui::widgets::BorderType;
55
6/// `BorderType` but impl `serde`
67#[derive(Serialize, Deserialize, Clone, Copy)]
78pub enum BorderTypeSerde {
89 Plain,
src/exit.rs +1
@@ -1,6 +1,7 @@
11use home::home_dir;
22use std::{error::Error, fs};
33
4/// function to run when the app ends
45// exit tasks:
56// - remove `~/.cache`
67pub fn exit() -> Result<(), Box<dyn Error>> {
src/global/functions/date_text.rs +1 −1
@@ -1,6 +1,6 @@
11use chrono::{Datelike, NaiveDateTime};
22
3// Convert timestamp into DD/MM/YYYY
3/// Convert timestamp into `DD/MM/YYYY`
44pub fn date_text(timestamp: u64) -> String {
55 let date = NaiveDateTime::from_timestamp(timestamp as i64, 0).date();
66 format!("{}/{}/{}", date.day(), date.month(), date.year())
src/global/functions/download_all_images.rs +26 −8
@@ -1,4 +1,4 @@
1use crate::global::item::Item;
1use crate::global::structs::Item;
22use futures::future::join_all;
33use std::{error::Error, fs, io::Cursor, thread};
44use tokio::runtime::Runtime;
@@ -8,23 +8,41 @@ pub struct DownloadRequest {
88 pub id: String,
99}
1010
11impl From<&Item> for DownloadRequest {
11impl From<&Item> for Option<DownloadRequest> {
1212 fn from(item: &Item) -> Self {
13 match item {
14 Item::MiniVideo(minivideo) => Self {
13 Some(match item {
14 Item::MiniVideo(minivideo) => DownloadRequest {
1515 url: minivideo.thumbnail_url.clone(),
1616 id: minivideo.id.clone(),
1717 },
18 }
18 Item::MiniPlaylist(miniplaylist) => match &miniplaylist.thumbnail {
19 Some((id, url)) => DownloadRequest {
20 url: url.clone(),
21 id: id.clone(),
22 },
23 None => return None,
24 },
25 Item::MiniChannel(minichannel) => DownloadRequest {
26 url: minichannel.thumbnail_url.clone(),
27 id: minichannel.id.clone(),
28 },
29 Item::Unknown(_) => return None,
30 })
1931 }
2032}
2133
22// Function to download all thumbnails (or just any files) to `~/.cache/thumbnails` with no file exitension (cuz its not needed)
23pub fn download_all_images(downloads: Vec<DownloadRequest>) {
34/// Function to download all thumbnails (or just any files) to `~/.cache/thumbnails` with no file exitension (cuz its not needed)
35pub fn download_all_images(downloads: Vec<Option<DownloadRequest>>) {
2436 thread::spawn(move || {
2537 let rt: Runtime = tokio::runtime::Runtime::new().unwrap();
2638
27 let _ = rt.block_on(download_all_images_async(downloads));
39 let _ = rt.block_on(download_all_images_async(
40 downloads
41 .into_iter()
42 .filter(|request| request.is_some())
43 .map(|request| request.unwrap())
44 .collect(),
45 ));
2846 });
2947}
3048
src/global/functions/mod.rs +1
@@ -1,3 +1,4 @@
1//! public functions
12mod secs_display_string;
23pub use secs_display_string::secs_display_string;
34mod viewcount_text;
src/global/functions/popup_area.rs +1
@@ -1,5 +1,6 @@
11use tui::layout::Rect;
22
3/// Tries to create a centered area for popup, returns `Err` if not enough space is given
34pub fn popup_area(
45 (max_width_percentage, max_height_percentage): (u16, u16),
56 (min_width_length, min_height_length): (u16, u16),
src/global/functions/secs_display_string.rs +1 −1
@@ -1,7 +1,7 @@
11const SECS_IN_MINUTE: u32 = 60;
22const SECS_IN_HOUR: u32 = 3600;
33
4// Turns seconds into pretty format like 02:43
4/// Turns seconds into pretty format like `02:43`
55pub fn secs_display_string(mut secs: u32) -> String {
66 let mut out = Vec::new();
77
src/global/functions/viewcount_text.rs +4 −2
@@ -5,10 +5,12 @@ const UNITS: &[(&'static str, f64)] = &[
55 ("", 1_f64),
66];
77
8// Turns number into short hand like 1.56M instead of its full form
8/// Turns number into short hand like `1.56M` instead of `1560000`
99pub fn viewcount_text(views: u64) -> String {
1010 for unit in UNITS.iter() {
11 if views >= unit.1 as u64 {
11 if unit.1 == 1_f64 {
12 return format!("{}", views);
13 } else if views >= unit.1 as u64 {
1214 return format!("{:.2}{}", views as f64 / unit.1, unit.0);
1315 }
1416 }
src/global/mod.rs +2 −9
@@ -1,11 +1,4 @@
1pub mod errors;
2pub mod invidiousclient;
3pub mod item;
4pub mod keyaction;
5pub mod message;
6pub mod page;
7pub mod status;
8pub mod tasks;
9
1//! Structs , traits and functions for the entire app
102pub mod functions;
3pub mod structs;
114pub mod traits;
src/global/errors.rs → src/global/structs/errors.rs renamed +1 −1
@@ -1,6 +1,6 @@
11use std::{error::Error, fmt::Display};
22
3// Errors for displaying custom string in the message bar if there is an error
3/// Errors for displaying custom string in the message bar if there is an error
44#[derive(Debug)]
55pub enum Errors {
66 BlankError,
src/global/invidiousclient.rs → src/global/structs/invidiousclient.rs renamed +2 −1
@@ -1,7 +1,8 @@
11use invidious::reqwest::blocking::Client;
22use typemap::Key;
33
4// Holds the invidious client
4// used in `data.global`
5/// Holds the invidious client
56#[derive(Clone)]
67pub struct InvidiousClient(pub Client);
78
src/global/item.rs → src/global/structs/item.rs renamed +101 −5
@@ -1,16 +1,21 @@
1use crate::global::functions::{date_text, secs_display_string, viewcount_text};
2use invidious::structs::hidden::{
3 Playlist, PopularItem, SearchItem, SearchItemTransition, TrendingVideo,
4};
15use std::fmt::Display;
26
3use super::functions::{date_text, secs_display_string, viewcount_text};
4use invidious::structs::hidden::{PopularItem, SearchItem, TrendingVideo};
5
6// Items are things like a single video/playlist and channel
7/// Items are things like a single video/playlist and channel
78// they are displayed by the item info widget in `iteminfo.rs`
89#[derive(Clone)]
910pub enum Item {
1011 // minivideos are all videos that appeared without actually clicking into the video
1112 MiniVideo(MiniVideoItem),
13 MiniPlaylist(MiniPlaylistItem),
14 MiniChannel(MiniChannelItem),
15 Unknown(SearchItemTransition),
1216}
1317
18/// info from a video from search, trending and popular page
1419#[derive(Clone)]
1520pub struct MiniVideoItem {
1621 pub title: String,
@@ -24,10 +29,35 @@ pub struct MiniVideoItem {
2429 pub description: Option<String>,
2530}
2631
32#[derive(Clone)]
33pub struct MiniPlaylistItem {
34 pub title: String,
35 pub id: String,
36 pub channel: String,
37 pub channel_id: String,
38 pub video_count: u32,
39 // (id, url)
40 pub thumbnail: Option<(String, String)>,
41}
42
43#[derive(Clone)]
44pub struct MiniChannelItem {
45 pub name: String,
46 pub id: String,
47 pub thumbnail_url: String,
48 pub sub_count: u32,
49 pub sub_count_text: String,
50 pub video_count: u32,
51 pub description: String,
52}
53
2754impl Display for Item {
2855 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2956 f.write_str(match self {
3057 Self::MiniVideo(video) => &video.title,
58 Self::MiniPlaylist(playlist) => &playlist.title,
59 Self::MiniChannel(channel) => &channel.name,
60 Self::Unknown(_) => "Unknown item",
3161 })
3262 }
3363}
@@ -37,6 +67,12 @@ impl Item {
3767 pub fn thumbnail_id(&self) -> &str {
3868 match self {
3969 Self::MiniVideo(video) => &video.id,
70 Self::MiniPlaylist(playlist) => match &playlist.thumbnail {
71 Some((id, _)) => &id,
72 None => "invalid",
73 },
74 Self::MiniChannel(channel) => &channel.id,
75 Self::Unknown(_) => "invalid",
4076 }
4177 }
4278
@@ -77,6 +113,24 @@ impl Item {
77113 })
78114 }
79115
116 pub fn from_mini_playlist(original: Playlist, image_index: usize) -> Self {
117 Self::MiniPlaylist(MiniPlaylistItem {
118 title: original.title,
119 id: original.id,
120 channel: original.author,
121 channel_id: original.author_id,
122 video_count: original.video_count,
123 thumbnail: if original.videos.len() == 0 {
124 None
125 } else {
126 Some((
127 original.videos[0].id.clone(),
128 original.videos[0].thumbnails[image_index].url.clone(),
129 ))
130 },
131 })
132 }
133
80134 pub fn from_search_item(original: SearchItem, image_index: usize) -> Self {
81135 match original {
82136 SearchItem::Video {
@@ -106,7 +160,49 @@ impl Item {
106160 published: format!("{} [{}]", published_text, date_text(published)),
107161 description: Some(description),
108162 }),
109 _ => todo!(),
163 SearchItem::Playlist {
164 title,
165 id,
166 author,
167 author_id,
168 author_url: _,
169 video_count,
170 videos,
171 } => Self::MiniPlaylist(MiniPlaylistItem {
172 title,
173 id,
174 channel: author,
175 channel_id: author_id,
176 video_count,
177 thumbnail: if videos.len() == 0 {
178 None
179 } else {
180 Some((
181 videos[0].id.clone(),
182 videos[0].thumbnails[image_index].url.clone(),
183 ))
184 },
185 }),
186 SearchItem::Channel {
187 name,
188 id,
189 url: _,
190 thumbnails,
191 subscribers,
192 video_count,
193 description,
194 description_html: _,
195 } => {
196 Self::MiniChannel(MiniChannelItem {
197 name,
198 id,
199 thumbnail_url: format!("https://{}", thumbnails[image_index].url),
200 video_count,
201 sub_count: subscribers,
202 sub_count_text: viewcount_text(subscribers as u64),
203 description,
204 })},
205 SearchItem::Unknown(searchitem_transitional) => Self::Unknown(searchitem_transitional),
110206 }
111207 }
112208}
src/global/keyaction.rs → src/global/structs/keyaction.rs renamed +1
@@ -1,5 +1,6 @@
11use serde::{Deserialize, Serialize};
22
3/// Part of the keybindings config
34// Each key + modifier is bind to a key in a HashMap<KeyCode, HashMap<u8, KeyAction>>
45#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Debug)]
56pub enum KeyAction {
src/global/message.rs → src/global/structs/message.rs renamed +2 −1
@@ -1,6 +1,7 @@
11use typemap::Key;
22
3// Messages in the message bar, the struct is global
3/// Messages in the message bar
4// is stored in `data.global`
45#[derive(Clone)]
56pub enum Message {
67 Message(String),
src/global/structs/mod.rs added +18
@@ -0,0 +1,18 @@
1//! enums and structs
2mod errors;
3mod invidiousclient;
4mod item;
5mod keyaction;
6mod message;
7mod page;
8mod status;
9mod tasks;
10
11pub use errors::*;
12pub use invidiousclient::*;
13pub use item::*;
14pub use keyaction::*;
15pub use message::*;
16pub use page::*;
17pub use status::*;
18pub use tasks::*;
src/global/page.rs → src/global/structs/page.rs renamed +2 −1
@@ -3,7 +3,7 @@ use tui_additions::framework::Framework;
33use typemap::Key;
44
55// Page can be converted into PageConfig, which can then be converted into State
6// Covers all possible pages and its variants
6/// Covers all possible pages and variants
77#[derive(Clone, PartialEq, Eq)]
88pub enum Page {
99 MainMenu(MainMenuPage),
@@ -20,6 +20,7 @@ impl Key for Page {
2020 type Value = Self;
2121}
2222
23/// page variants for the main menu
2324#[derive(Clone, PartialEq, Eq)]
2425pub enum MainMenuPage {
2526 Trending,
src/global/status.rs → src/global/structs/status.rs renamed +1
@@ -1,5 +1,6 @@
11use typemap::Key;
22
3/// a struct for storing different info, currently only stores one info
34#[derive(Clone)]
45pub struct Status {
56 pub popup_opened: bool,
src/global/tasks.rs → src/global/structs/tasks.rs renamed +3 −1
@@ -8,6 +8,7 @@ use tui::{
88use tui_additions::framework::{CursorState, Framework};
99use typemap::Key;
1010
11/// tasks to be put on taskqueues
1112#[derive(Clone)]
1213pub enum Task {
1314 RenderAll,
@@ -17,6 +18,7 @@ pub enum Task {
1718 ClearPage,
1819}
1920
21/// multiple tasks joined together, with duplicates removed
2022#[derive(Clone, PartialEq, Eq)]
2123pub struct TaskQueue {
2224 pub render: RenderTask,
@@ -194,9 +196,9 @@ pub enum RenderTask {
194196 Only(Vec<(usize, usize)>),
195197}
196198
199/// priority will get executed first, last will get executed after priority queue finished
197200#[derive(Clone, Default)]
198201pub struct Tasks {
199 // priority will get executed first, last will get executed after priority queue finished
200202 pub priority: TaskQueue,
201203 pub last: TaskQueue,
202204}
src/global/traits/asurlstring.rs +1 −1
@@ -1,4 +1,4 @@
1// A single URL param
1/// A single URL param
22pub trait AsUrlString {
33 const TAG: &'static str;
44 fn as_url_string(&self) -> String
src/config/configtrait.rs → src/global/traits/configtrait.rs renamed +2 −2
@@ -5,9 +5,9 @@ use std::{
55 io::Write,
66};
77
8pub const EXTENSION: &'static str = "yml";
8const EXTENSION: &'static str = "yml";
99
10// Trait for loading, saving config files
10/// Trait for loading, saving config files
1111pub trait ConfigTrait {
1212 const LABEL: &'static str;
1313
src/global/traits/mod.rs +8 −1
@@ -1 +1,8 @@
1pub mod asurlstring;
1//! public traits
2mod asurlstring;
3mod configtrait;
4mod searchfilteritem;
5
6pub use asurlstring::*;
7pub use configtrait::*;
8pub use searchfilteritem::*;
src/global/traits/searchfilteritem.rs added +13
@@ -0,0 +1,13 @@
1/// trait for on single search filter
2pub trait SearchFilterItem
3where
4 Self: Sized,
5{
6 // display name of the option
7 const NAME: &'static str;
8
9 fn option_name(&self) -> &'static str;
10 fn ordering() -> Vec<&'static str>;
11 fn selected_index(&self) -> usize;
12 fn at_index(index: usize) -> Self;
13}
src/init.rs +5 −5
@@ -1,22 +1,22 @@
11use crate::{
22 config::{
3 AppearanceConfig, AppearanceConfigSerde, ConfigTrait, KeyBindingsConfig, MainConfig,
4 MinDimentions, PagesConfig, Search,
3 AppearanceConfig, AppearanceConfigSerde, KeyBindingsConfig, MainConfig, MinDimentions,
4 PagesConfig, Search,
55 },
66 global::{
7 invidiousclient::InvidiousClient, message::Message, page::Page, status::Status,
8 tasks::Tasks,
7 structs::{InvidiousClient, Message, Page, Status, Tasks},
8 traits::ConfigTrait,
99 },
1010};
1111use home::home_dir;
1212use std::{error::Error, fs};
1313use tui_additions::framework::Framework;
1414
15/// app to run before the app starts
1516// init tasks:
1617// - create folders like `~/.config/youtube-tui/` and `~/.cache/youtube-tui/thumbnails/`
1718// - load all config files
1819// - insert data
19
2020pub fn init(framework: &mut Framework) -> Result<(), Box<dyn Error>> {
2121 // creating files
2222 let home_dir = home_dir().unwrap();
src/items/iteminfo.rs +82 −3
@@ -8,10 +8,10 @@ use viuer::{print_from_file, Config};
88
99use crate::{
1010 config::{AppearanceConfig, MainConfig},
11 global::{item::Item, status::Status},
11 global::structs::{Item, Status},
1212};
1313
14// an item info displays info of any `Item`s
14/// an item info displays info of any `Item`s
1515#[derive(Clone)]
1616pub struct ItemInfo {
1717 pub item: Option<Item>,
@@ -49,7 +49,11 @@ impl FrameworkItem for ItemInfo {
4949 .join(item.thumbnail_id());
5050 if thumbnail_path.exists() {
5151 let config = Config {
52 width: Some(area.width as u32),
52 width: Some(if let Item::MiniChannel(_) = item {
53 area.width / 2
54 } else {
55 area.width
56 } as u32),
5357 x: area.x,
5458 y: area.y as i16,
5559 use_sixel: main_config.images.use_sixels(),
@@ -116,6 +120,81 @@ impl FrameworkItem for ItemInfo {
116120 );
117121 out
118122 }
123 Item::MiniPlaylist(miniplaylist) => (
124 vec![
125 (
126 String::from("[Playlist]"),
127 Style::default().fg(appearance.colors.item_info.tag),
128 ),
129 (
130 miniplaylist.title.clone(),
131 Style::default().fg(appearance.colors.item_info.title),
132 ),
133 (
134 format!("Created by by {}", miniplaylist.channel),
135 Style::default().fg(appearance.colors.item_info.author),
136 ),
137 (
138 format!(
139 "{} video{}",
140 miniplaylist.video_count,
141 if miniplaylist.video_count <= 1 {
142 ""
143 } else {
144 "s"
145 }
146 ),
147 Style::default().fg(appearance.colors.item_info.video_count),
148 ),
149 ],
150 None,
151 ),
152 Item::MiniChannel(minichannel) => (
153 vec![
154 (
155 String::from("[Channel]"),
156 Style::default().fg(appearance.colors.item_info.tag),
157 ),
158 (
159 minichannel.name.clone(),
160 Style::default().fg(appearance.colors.item_info.title),
161 ),
162 (
163 format!("{} subscriber{}", minichannel.sub_count_text, if minichannel.sub_count <= 1 {
164 ""
165 } else {
166 "s"
167 }),
168 Style::default().fg(appearance.colors.item_info.sub_count),
169 ),
170 (
171 format!(
172 "{} video{}",
173 minichannel.video_count,
174 if minichannel.video_count <= 1 {
175 ""
176 } else {
177 "s"
178 }
179 ),
180 Style::default().fg(appearance.colors.item_info.video_count),
181 ),
182 ],
183 Some((
184 minichannel.description.clone(),
185 Style::default().fg(appearance.colors.item_info.description),
186 )),
187 ),
188 Item::Unknown(searchitem_transitional) => (
189 vec![(
190 format!("Unknown type `{}`", searchitem_transitional.r#type),
191 Style::default().fg(appearance.colors.error_text),
192 )],
193 Some((
194 serde_json::to_string(&searchitem_transitional).unwrap(),
195 Style::default().fg(appearance.colors.item_info.description),
196 )),
197 ),
119198 };
120199
121200 // puts each "span" in its own line
src/items/itemlist.rs +5 −9
@@ -2,7 +2,7 @@ use std::error::Error;
22
33use tui::{layout::Constraint, style::Style};
44use tui_additions::{
5 framework::{Framework, FrameworkItem},
5 framework::FrameworkItem,
66 widgets::{Grid, TextList},
77};
88
@@ -11,15 +11,11 @@ use crate::{
1111 config::{AppearanceConfig, KeyBindingsConfig, MainConfig},
1212 global::{
1313 functions::download_all_images,
14 invidiousclient::InvidiousClient,
15 item::Item,
16 keyaction::KeyAction,
17 page::{MainMenuPage, Page},
18 tasks::{Task, Tasks},
14 structs::{InvidiousClient, Item, KeyAction, MainMenuPage, Page, Task, Tasks},
1915 },
2016};
2117
22// An item list displays a list of items
18/// An item list displays a list of items
2319// It consists of a 1 x 2 grid, with the left cell displaying a text list, the right displaying item info of the currently hovered item
2420#[derive(Clone)]
2521pub struct ItemList {
@@ -29,8 +25,8 @@ pub struct ItemList {
2925 pub grid: Grid,
3026}
3127
32impl ItemList {
33 pub fn new(framework: &mut Framework) -> Self {
28impl Default for ItemList {
29 fn default() -> Self {
3430 Self {
3531 info: ItemInfo::default(),
3632 items: Vec::new(),
src/items/messagebar.rs +2 −1
@@ -1,6 +1,6 @@
11use crate::{
22 config::{AppearanceConfig, MainConfig},
3 global::message::Message,
3 global::structs::Message,
44};
55use tui::{
66 style::Style,
@@ -8,6 +8,7 @@ use tui::{
88};
99use tui_additions::framework::FrameworkItem;
1010
11/// a message bar item, contains no fields because the message is taken from `data.global.Message`
1112#[derive(Clone, Copy, Default)]
1213pub struct MessageBar;
1314
src/items/mod.rs +1
@@ -1,3 +1,4 @@
1//! items to be rendered, impls FrameworkItem
12mod searchbar;
23pub use searchbar::*;
34mod messagebar;
src/items/pagebutton.rs +2 −5
@@ -1,9 +1,6 @@
11use crate::{
22 config::AppearanceConfig,
3 global::{
4 page::{MainMenuPage, Page},
5 tasks::{Task, Tasks},
6 },
3 global::structs::{MainMenuPage, Page, Task, Tasks},
74};
85use tui::{
96 layout::Alignment,
@@ -12,7 +9,7 @@ use tui::{
129};
1310use tui_additions::framework::FrameworkItem;
1411
15// button that on press will go to another page instead of selecting it
12/// button that on press will go to another page instead of selecting it
1613#[derive(Clone, Copy)]
1714pub enum PageButton {
1815 Trending,
src/items/searchbar.rs +1 −4
@@ -2,10 +2,7 @@ use std::error::Error;
22
33use crate::{
44 config::{AppearanceConfig, Search},
5 global::{
6 page::Page,
7 tasks::{Task, Tasks},
8 },
5 global::structs::{Page, Task, Tasks},
96};
107use crossterm::event::KeyCode;
118use tui::{
src/items/searchfilters.rs +2 −6
@@ -1,13 +1,8 @@
1use std::array::IntoIter;
2
31use crate::{
42 config::{AppearanceConfig, KeyBindingsConfig, Search, SearchFilters},
53 global::{
64 functions::popup_area,
7 keyaction::KeyAction,
8 message::Message,
9 status::Status,
10 tasks::{Task, Tasks},
5 structs::{KeyAction, Message, Status, Task, Tasks},
116 },
127};
138use tui::{
@@ -25,6 +20,7 @@ const POPUP_MIN_HEIGHT: u16 = 9;
2520const POPUP_WIDTH_PERCENTAGE: u16 = 70;
2621const POPOUP_HEIGHT_PERCENTAGE: u16 = 70;
2722
23/// a tiny button when not selected, renders a popup when selected
2824#[derive(Clone)]
2925pub struct SearchFilter {
3026 pub left_textlist: TextList,
src/run.rs +2 −7
@@ -5,15 +5,10 @@ use tui_additions::framework::{Framework, FrameworkDirection};
55
66use crate::{
77 config::KeyBindingsConfig,
8 global::{
9 keyaction::KeyAction,
10 message::Message,
11 page::{MainMenuPage, Page},
12 tasks::{Task, Tasks},
13 },
8 global::structs::{KeyAction, MainMenuPage, Message, Page, Task, Tasks},
149};
1510
16// the main event loop of the program
11/// the main event loop of the program
1712pub fn run(
1813 terminal: &mut Terminal<CrosstermBackend<Stdout>>,
1914 mut framework: Framework,