Commit 6221eb407a
Unsigned
Layout: unified · split
Cargo.lock +25 −25
| @@ -58,9 +58,9 @@ checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" | |||
| 58 | 58 | ||
| 59 | [[package]] | 59 | [[package]] |
| 60 | name = "bytemuck" | 60 | name = "bytemuck" |
| 61 | version = "1.12.2" | 61 | version = "1.12.3" |
| 62 | source = "registry+https://github.com/rust-lang/crates.io-index" | 62 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 63 | checksum = "5aec14f5d4e6e3f927cd0c81f72e5710d95ee9019fbeb4b3021193867491bfd8" | 63 | checksum = "aaa3a8d9a1ca92e282c96a32d6511b695d7d994d1d102ba85d279f9b2756947f" |
| 64 | 64 | ||
| 65 | [[package]] | 65 | [[package]] |
| 66 | name = "byteorder" | 66 | name = "byteorder" |
| @@ -82,9 +82,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" | |||
| 82 | 82 | ||
| 83 | [[package]] | 83 | [[package]] |
| 84 | name = "cc" | 84 | name = "cc" |
| 85 | version = "1.0.74" | 85 | version = "1.0.76" |
| 86 | source = "registry+https://github.com/rust-lang/crates.io-index" | 86 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 87 | checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574" | 87 | checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f" |
| 88 | 88 | ||
| 89 | [[package]] | 89 | [[package]] |
| 90 | name = "cfg-if" | 90 | name = "cfg-if" |
| @@ -94,9 +94,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" | |||
| 94 | 94 | ||
| 95 | [[package]] | 95 | [[package]] |
| 96 | name = "chrono" | 96 | name = "chrono" |
| 97 | version = "0.4.22" | 97 | version = "0.4.23" |
| 98 | source = "registry+https://github.com/rust-lang/crates.io-index" | 98 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 99 | checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" | 99 | checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" |
| 100 | dependencies = [ | 100 | dependencies = [ |
| 101 | "iana-time-zone", | 101 | "iana-time-zone", |
| 102 | "num-integer", | 102 | "num-integer", |
| @@ -235,9 +235,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" | |||
| 235 | 235 | ||
| 236 | [[package]] | 236 | [[package]] |
| 237 | name = "cxx" | 237 | name = "cxx" |
| 238 | version = "1.0.80" | 238 | version = "1.0.81" |
| 239 | source = "registry+https://github.com/rust-lang/crates.io-index" | 239 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 240 | checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" | 240 | checksum = "97abf9f0eca9e52b7f81b945524e76710e6cb2366aead23b7d4fbf72e281f888" |
| 241 | dependencies = [ | 241 | dependencies = [ |
| 242 | "cc", | 242 | "cc", |
| 243 | "cxxbridge-flags", | 243 | "cxxbridge-flags", |
| @@ -247,9 +247,9 @@ dependencies = [ | |||
| 247 | 247 | ||
| 248 | [[package]] | 248 | [[package]] |
| 249 | name = "cxx-build" | 249 | name = "cxx-build" |
| 250 | version = "1.0.80" | 250 | version = "1.0.81" |
| 251 | source = "registry+https://github.com/rust-lang/crates.io-index" | 251 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 252 | checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" | 252 | checksum = "7cc32cc5fea1d894b77d269ddb9f192110069a8a9c1f1d441195fba90553dea3" |
| 253 | dependencies = [ | 253 | dependencies = [ |
| 254 | "cc", | 254 | "cc", |
| 255 | "codespan-reporting", | 255 | "codespan-reporting", |
| @@ -262,15 +262,15 @@ dependencies = [ | |||
| 262 | 262 | ||
| 263 | [[package]] | 263 | [[package]] |
| 264 | name = "cxxbridge-flags" | 264 | name = "cxxbridge-flags" |
| 265 | version = "1.0.80" | 265 | version = "1.0.81" |
| 266 | source = "registry+https://github.com/rust-lang/crates.io-index" | 266 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 267 | checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" | 267 | checksum = "8ca220e4794c934dc6b1207c3b42856ad4c302f2df1712e9f8d2eec5afaacf1f" |
| 268 | 268 | ||
| 269 | [[package]] | 269 | [[package]] |
| 270 | name = "cxxbridge-macro" | 270 | name = "cxxbridge-macro" |
| 271 | version = "1.0.80" | 271 | version = "1.0.81" |
| 272 | source = "registry+https://github.com/rust-lang/crates.io-index" | 272 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 273 | checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" | 273 | checksum = "b846f081361125bfc8dc9d3940c84e1fd83ba54bbca7b17cd29483c828be0704" |
| 274 | dependencies = [ | 274 | dependencies = [ |
| 275 | "proc-macro2", | 275 | "proc-macro2", |
| 276 | "quote", | 276 | "quote", |
| @@ -603,9 +603,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" | |||
| 603 | 603 | ||
| 604 | [[package]] | 604 | [[package]] |
| 605 | name = "hyper" | 605 | name = "hyper" |
| 606 | version = "0.14.22" | 606 | version = "0.14.23" |
| 607 | source = "registry+https://github.com/rust-lang/crates.io-index" | 607 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 608 | checksum = "abfba89e19b959ca163c7752ba59d737c1ceea53a5d31a149c805446fc958064" | 608 | checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" |
| 609 | dependencies = [ | 609 | dependencies = [ |
| 610 | "bytes", | 610 | "bytes", |
| 611 | "futures-channel", | 611 | "futures-channel", |
| @@ -674,9 +674,9 @@ dependencies = [ | |||
| 674 | 674 | ||
| 675 | [[package]] | 675 | [[package]] |
| 676 | name = "image" | 676 | name = "image" |
| 677 | version = "0.24.4" | 677 | version = "0.24.5" |
| 678 | source = "registry+https://github.com/rust-lang/crates.io-index" | 678 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 679 | checksum = "bd8e4fb07cf672b1642304e731ef8a6a4c7891d67bb4fd4f5ce58cd6ed86803c" | 679 | checksum = "69b7ea949b537b0fd0af141fff8c77690f2ce96f4f41f042ccb6c69c6c965945" |
| 680 | dependencies = [ | 680 | dependencies = [ |
| 681 | "bytemuck", | 681 | "bytemuck", |
| 682 | "byteorder", | 682 | "byteorder", |
| @@ -723,9 +723,9 @@ dependencies = [ | |||
| 723 | 723 | ||
| 724 | [[package]] | 724 | [[package]] |
| 725 | name = "ipnet" | 725 | name = "ipnet" |
| 726 | version = "2.5.0" | 726 | version = "2.5.1" |
| 727 | source = "registry+https://github.com/rust-lang/crates.io-index" | 727 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 728 | checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" | 728 | checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745" |
| 729 | 729 | ||
| 730 | [[package]] | 730 | [[package]] |
| 731 | name = "itoa" | 731 | name = "itoa" |
| @@ -735,9 +735,9 @@ checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" | |||
| 735 | 735 | ||
| 736 | [[package]] | 736 | [[package]] |
| 737 | name = "jpeg-decoder" | 737 | name = "jpeg-decoder" |
| 738 | version = "0.2.6" | 738 | version = "0.3.0" |
| 739 | source = "registry+https://github.com/rust-lang/crates.io-index" | 739 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 740 | checksum = "9478aa10f73e7528198d75109c8be5cd7d15fb530238040148d5f9a22d4c5b3b" | 740 | checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" |
| 741 | dependencies = [ | 741 | dependencies = [ |
| 742 | "rayon", | 742 | "rayon", |
| 743 | ] | 743 | ] |
| @@ -1407,9 +1407,9 @@ dependencies = [ | |||
| 1407 | 1407 | ||
| 1408 | [[package]] | 1408 | [[package]] |
| 1409 | name = "tiff" | 1409 | name = "tiff" |
| 1410 | version = "0.7.4" | 1410 | version = "0.8.0" |
| 1411 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1411 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1412 | checksum = "9f71e422515e83e3ab8a03d4781d05ebf864fc61f4546e6ecffa58cbd34181a0" | 1412 | checksum = "f17def29300a156c19ae30814710d9c63cd50288a49c6fd3a10ccfbe4cf886fd" |
| 1413 | dependencies = [ | 1413 | dependencies = [ |
| 1414 | "flate2", | 1414 | "flate2", |
| 1415 | "jpeg-decoder", | 1415 | "jpeg-decoder", |
| @@ -1880,7 +1880,7 @@ dependencies = [ | |||
| 1880 | 1880 | ||
| 1881 | [[package]] | 1881 | [[package]] |
| 1882 | name = "youtube-tui" | 1882 | name = "youtube-tui" |
| 1883 | version = "0.5.0" | 1883 | version = "0.5.1" |
| 1884 | dependencies = [ | 1884 | dependencies = [ |
| 1885 | "chrono", | 1885 | "chrono", |
| 1886 | "crossterm", | 1886 | "crossterm", |
Cargo.toml +7 −3
| @@ -1,6 +1,6 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "youtube-tui" | 2 | name = "youtube-tui" |
| 3 | version = "0.5.0" | 3 | version = "0.5.1" |
| 4 | authors = ["Siriusmart <siriusmart@tuta.io>"] | 4 | authors = ["Siriusmart <siriusmart@tuta.io>"] |
| 5 | edition = "2021" | 5 | edition = "2021" |
| 6 | description = "An aesthetically pleasing YouTube TUI written in Rust" | 6 | description = "An aesthetically pleasing YouTube TUI written in Rust" |
| @@ -9,18 +9,22 @@ readme = "README.md" | |||
| 9 | homepage = "https://siriusmart.github.io/youtube-tui" | 9 | homepage = "https://siriusmart.github.io/youtube-tui" |
| 10 | repository = "https://github.com/siriusmart/youtube-tui" | 10 | repository = "https://github.com/siriusmart/youtube-tui" |
| 11 | license = "GPL-3.0" | 11 | license = "GPL-3.0" |
| 12 | license-file = "LICENSE" | ||
| 13 | keywords = ["cli", "terminal", "youtube", "tui"] | 12 | keywords = ["cli", "terminal", "youtube", "tui"] |
| 14 | categories =["command-line-interface", "command-line-utilities"] | 13 | categories =["command-line-interface", "command-line-utilities"] |
| 15 | exclude = ["/docs"] | 14 | exclude = ["/docs"] |
| 16 | 15 | ||
| 17 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | 16 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
| 18 | 17 | ||
| 18 | [features] | ||
| 19 | default = ["sixel", "halfblock"] | ||
| 20 | sixel = ["viuer/sixel"] | ||
| 21 | halfblock = ["viuer"] | ||
| 22 | |||
| 19 | [dependencies] | 23 | [dependencies] |
| 20 | serde = {version = "1.0", default-features = false, features = ["derive"]} | 24 | serde = {version = "1.0", default-features = false, features = ["derive"]} |
| 21 | tui = {version = "0.19", default-features = false, features = ["serde"]} | 25 | tui = {version = "0.19", default-features = false, features = ["serde"]} |
| 22 | crossterm = {version = "0.25", default-features = false, features = ["serde"]} | 26 | crossterm = {version = "0.25", default-features = false, features = ["serde"]} |
| 23 | viuer = {version = "0.6", default-features = false, features = ["sixel"]} | 27 | viuer = {version = "0.6", default-features = false, optional = true} |
| 24 | home = "0.5" | 28 | home = "0.5" |
| 25 | chrono = {version = "0.4", default-features = false, features = ["clock"]} | 29 | chrono = {version = "0.4", default-features = false, features = ["clock"]} |
| 26 | tui-additions = {version = "0.1", default-features = false, features = ["framework", "widgets"]} | 30 | tui-additions = {version = "0.1", default-features = false, features = ["framework", "widgets"]} |
docs/src/config/README.md +1 −1
| @@ -11,4 +11,4 @@ In the following sections we will go through all config files including: | |||
| 11 | - [`keybindings.yml`](./keybindings.md) | 11 | - [`keybindings.yml`](./keybindings.md) |
| 12 | - [`pages.yml`](./pages.md) | 12 | - [`pages.yml`](./pages.md) |
| 13 | - [`appearance.yml`](./appearance.md) | 13 | - [`appearance.yml`](./appearance.md) |
| 14 | - `search.yml` | 14 | - [`search.yml`](./search.md) |
docs/src/installation.md +22
| @@ -47,3 +47,25 @@ youtube-tui | |||
| 47 | ``` | 47 | ``` |
| 48 | 48 | ||
| 49 | If installed correctly, a TUI should be launched. Press `q` to close the TUI. | 49 | If installed correctly, a TUI should be launched. Press `q` to close the TUI. |
| 50 | |||
| 51 | ## Features | ||
| 52 | |||
| 53 | The TUI has features that can be enabled/disabled when compiling. | ||
| 54 | |||
| 55 | ```sh | ||
| 56 | cargo install youtube-tui # install with all default features | ||
| 57 | cargo install youtube-tui --no-default-features # install without any features enabled | ||
| 58 | cargo install youtube-tui --no-default-features -F 'halfblock' # install with only HalfBlocks support (but not Sixels) | ||
| 59 | cargo install youtube-tui --no-default-features -F 'halfblock' -F 'sixel' # can install with multiple features by doing this | ||
| 60 | cargo install youtube-tui --all-features # install with all features (even if not included in default) | ||
| 61 | ``` | ||
| 62 | |||
| 63 | ### `halfblock` (default) | ||
| 64 | |||
| 65 | Display images through HalfBlocks, work best in terminals with TrueColour support (so would not recommend for Windows users). | ||
| 66 | |||
| 67 | ### `sixel` (default) | ||
| 68 | |||
| 69 | Display images with Sixels, allows the display of images at full definition. Not present on windows. | ||
| 70 | |||
| 71 | Enabling this will also enable `halfblock`. | ||
src/config/main.rs +2 −2
| @@ -56,7 +56,7 @@ impl ConfigTrait for MainConfig { | |||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | /// how images are handled/displayed | 58 | /// how images are handled/displayed |
| 59 | #[derive(Clone, Copy, Serialize, Deserialize, PartialEq)] | 59 | #[derive(Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] |
| 60 | pub enum Images { | 60 | pub enum Images { |
| 61 | r#None, | 61 | r#None, |
| 62 | HalfBlocks, | 62 | HalfBlocks, |
| @@ -73,7 +73,7 @@ impl Images { | |||
| 73 | } | 73 | } |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | #[derive(Clone, Copy, Serialize, Deserialize, PartialEq)] | 76 | #[derive(Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] |
| 77 | pub enum Provider { | 77 | pub enum Provider { |
| 78 | YouTube, | 78 | YouTube, |
| 79 | Invidious, | 79 | Invidious, |
src/global/functions/date_text.rs +3 −1
| @@ -2,6 +2,8 @@ use chrono::{Datelike, NaiveDateTime}; | |||
| 2 | 2 | ||
| 3 | /// Convert timestamp into `DD/MM/YYYY` | 3 | /// Convert timestamp into `DD/MM/YYYY` |
| 4 | pub fn date_text(timestamp: u64) -> String { | 4 | pub fn date_text(timestamp: u64) -> String { |
| 5 | let date = NaiveDateTime::from_timestamp(timestamp as i64, 0).date(); | 5 | let date = NaiveDateTime::from_timestamp_opt(timestamp as i64, 0) |
| 6 | .unwrap() | ||
| 7 | .date(); | ||
| 6 | format!("{}/{}/{}", date.day(), date.month(), date.year()) | 8 | format!("{}/{}/{}", date.day(), date.month(), date.year()) |
| 7 | } | 9 | } |
src/global/functions/download_all_images.rs +6 −1
| @@ -42,10 +42,15 @@ impl From<&Item> for Option<DownloadRequest> { | |||
| 42 | 42 | ||
| 43 | /// Function to download all thumbnails (or just any files) to `~/.cache/thumbnails` with no file exitension (cuz its not needed) | 43 | /// Function to download all thumbnails (or just any files) to `~/.cache/thumbnails` with no file exitension (cuz its not needed) |
| 44 | pub fn download_all_images(downloads: Vec<Option<DownloadRequest>>) { | 44 | pub fn download_all_images(downloads: Vec<Option<DownloadRequest>>) { |
| 45 | // do not download the images if non of the features are enabled | ||
| 46 | if cfg!(not(any(feature = "sixel", feature = "halfblock"))) { | ||
| 47 | return; | ||
| 48 | } | ||
| 49 | |||
| 45 | thread::spawn(move || { | 50 | thread::spawn(move || { |
| 46 | let rt: Runtime = tokio::runtime::Runtime::new().unwrap(); | 51 | let rt: Runtime = tokio::runtime::Runtime::new().unwrap(); |
| 47 | 52 | ||
| 48 | let _ = rt.block_on(download_all_images_async( | 53 | rt.block_on(download_all_images_async( |
| 49 | downloads.into_iter().flatten().collect(), | 54 | downloads.into_iter().flatten().collect(), |
| 50 | )); | 55 | )); |
| 51 | }); | 56 | }); |
src/global/structs/page.rs +5 −5
| @@ -6,7 +6,7 @@ use typemap::Key; | |||
| 6 | 6 | ||
| 7 | // Page can be converted into PageConfig, which can then be converted into State | 7 | // Page can be converted into PageConfig, which can then be converted into State |
| 8 | /// Covers all possible pages and variants | 8 | /// Covers all possible pages and variants |
| 9 | #[derive(Clone, PartialEq)] | 9 | #[derive(Clone, PartialEq, Eq)] |
| 10 | pub enum Page { | 10 | pub enum Page { |
| 11 | MainMenu(MainMenuPage), | 11 | MainMenu(MainMenuPage), |
| 12 | Search(Search), | 12 | Search(Search), |
| @@ -49,7 +49,7 @@ impl Key for Page { | |||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | /// page variants for the main menu | 51 | /// page variants for the main menu |
| 52 | #[derive(Clone, Copy, PartialEq)] | 52 | #[derive(Clone, Copy, PartialEq, Eq)] |
| 53 | pub enum MainMenuPage { | 53 | pub enum MainMenuPage { |
| 54 | Trending, | 54 | Trending, |
| 55 | Popular, | 55 | Popular, |
| @@ -63,13 +63,13 @@ impl Default for MainMenuPage { | |||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | /// variants of the coannel display page | 65 | /// variants of the coannel display page |
| 66 | #[derive(Clone, PartialEq)] | 66 | #[derive(Clone, PartialEq, Eq)] |
| 67 | pub struct ChannelDisplayPage { | 67 | pub struct ChannelDisplayPage { |
| 68 | pub id: String, | 68 | pub id: String, |
| 69 | pub r#type: ChannelDisplayPageType, | 69 | pub r#type: ChannelDisplayPageType, |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | #[derive(Clone, Copy, PartialEq)] | 72 | #[derive(Clone, Copy, PartialEq, Eq)] |
| 73 | pub enum ChannelDisplayPageType { | 73 | pub enum ChannelDisplayPageType { |
| 74 | Main, | 74 | Main, |
| 75 | Videos, | 75 | Videos, |
| @@ -77,7 +77,7 @@ pub enum ChannelDisplayPageType { | |||
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | /// Different items to be displayed on a single item page | 79 | /// Different items to be displayed on a single item page |
| 80 | #[derive(Clone, PartialEq)] | 80 | #[derive(Clone, PartialEq, Eq)] |
| 81 | pub enum SingleItemPage { | 81 | pub enum SingleItemPage { |
| 82 | Video(String), | 82 | Video(String), |
| 83 | Playlist(String), | 83 | Playlist(String), |
src/global/structs/tasks.rs +1 −1
| @@ -19,7 +19,7 @@ pub enum Task { | |||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | /// multiple tasks joined together, with duplicates removed | 21 | /// multiple tasks joined together, with duplicates removed |
| 22 | #[derive(Clone, PartialEq)] | 22 | #[derive(Clone, PartialEq, Eq)] |
| 23 | pub struct TaskQueue { | 23 | pub struct TaskQueue { |
| 24 | pub render: RenderTask, | 24 | pub render: RenderTask, |
| 25 | pub reload: bool, | 25 | pub reload: bool, |
src/items/iteminfo.rs +35 −26
| @@ -4,6 +4,7 @@ use tui::{ | |||
| 4 | widgets::{Paragraph, Wrap}, | 4 | widgets::{Paragraph, Wrap}, |
| 5 | }; | 5 | }; |
| 6 | use tui_additions::framework::FrameworkItem; | 6 | use tui_additions::framework::FrameworkItem; |
| 7 | #[cfg(any(feature = "sixel", feature = "halfblock"))] | ||
| 7 | use viuer::{print_from_file, Config}; | 8 | use viuer::{print_from_file, Config}; |
| 8 | 9 | ||
| 9 | use crate::{ | 10 | use crate::{ |
| @@ -40,37 +41,45 @@ impl FrameworkItem for ItemInfo { | |||
| 40 | let appearance = framework.data.global.get::<AppearanceConfig>().unwrap(); | 41 | let appearance = framework.data.global.get::<AppearanceConfig>().unwrap(); |
| 41 | 42 | ||
| 42 | // The scroll (space above) text info will be the height of the image, but if the image fail to display, the scroll will be 0 | 43 | // The scroll (space above) text info will be the height of the image, but if the image fail to display, the scroll will be 0 |
| 43 | let scroll = if main_config.images.display() | 44 | let scroll = if cfg!(any(feature = "halfblock", feature = "sixel")) |
| 45 | && main_config.images.display() | ||
| 44 | && !framework.data.state.get::<Status>().unwrap().popup_opened | 46 | && !framework.data.state.get::<Status>().unwrap().popup_opened |
| 45 | { | 47 | { |
| 46 | let thumbnail_path = home::home_dir() | 48 | let mut scroll = 0; |
| 47 | .unwrap() | 49 | |
| 48 | .join(".cache/youtube-tui/thumbnails/") | 50 | #[cfg(any(feature = "sixel", feature = "halfblock"))] |
| 49 | .join(item.thumbnail_id()); | 51 | { |
| 50 | if thumbnail_path.exists() { | 52 | let thumbnail_path = home::home_dir() |
| 51 | let config = Config { | 53 | .unwrap() |
| 52 | // channel thumbnails are squares, limiting their maximum width can prevent the | 54 | .join(".cache/youtube-tui/thumbnails/") |
| 53 | // entire page being taken up by the image | 55 | .join(item.thumbnail_id()); |
| 54 | width: Some(if let Item::MiniChannel(_) = item { | 56 | if thumbnail_path.exists() { |
| 55 | area.width / 2 | 57 | #[cfg(any(feature = "sixel", feature = "halfblock"))] |
| 56 | } else if let Item::FullChannel(_) = item { | 58 | let config = Config { |
| 57 | area.width / 4 | 59 | // channel thumbnails are squares, limiting their maximum width can prevent the |
| 60 | // entire page being taken up by the image | ||
| 61 | width: Some(if let Item::MiniChannel(_) = item { | ||
| 62 | area.width / 2 | ||
| 63 | } else if let Item::FullChannel(_) = item { | ||
| 64 | area.width / 4 | ||
| 65 | } else { | ||
| 66 | area.width | ||
| 67 | } as u32), | ||
| 68 | x: area.x, | ||
| 69 | y: area.y as i16, | ||
| 70 | #[cfg(feature = "sixel")] | ||
| 71 | use_sixel: main_config.images.use_sixels(), | ||
| 72 | ..Default::default() | ||
| 73 | }; | ||
| 74 | |||
| 75 | if let Ok((_, height)) = print_from_file(thumbnail_path, &config) { | ||
| 76 | scroll = height as u16; | ||
| 58 | } else { | 77 | } else { |
| 59 | area.width | 78 | scroll = 0; |
| 60 | } as u32), | 79 | } |
| 61 | x: area.x, | ||
| 62 | y: area.y as i16, | ||
| 63 | use_sixel: main_config.images.use_sixels(), | ||
| 64 | ..Default::default() | ||
| 65 | }; | ||
| 66 | if let Ok((_, height)) = print_from_file(thumbnail_path, &config) { | ||
| 67 | height as u16 | ||
| 68 | } else { | ||
| 69 | 0 | ||
| 70 | } | 80 | } |
| 71 | } else { | ||
| 72 | 0 | ||
| 73 | } | 81 | } |
| 82 | scroll | ||
| 74 | } else { | 83 | } else { |
| 75 | 0 | 84 | 0 |
| 76 | }; | 85 | }; |
src/items/pagebutton.rs +3 −2
| @@ -1,7 +1,7 @@ | |||
| 1 | use crate::{ | 1 | use crate::{ |
| 2 | config::AppearanceConfig, | 2 | config::AppearanceConfig, |
| 3 | global::structs::{ | 3 | global::structs::{ |
| 4 | ChannelDisplayPage, ChannelDisplayPageType, MainMenuPage, Page, Task, Tasks, Message, | 4 | ChannelDisplayPage, ChannelDisplayPageType, MainMenuPage, Message, Page, Task, Tasks, |
| 5 | }, | 5 | }, |
| 6 | }; | 6 | }; |
| 7 | use tui::{ | 7 | use tui::{ |
| @@ -97,7 +97,8 @@ impl FrameworkItem for PageButton { | |||
| 97 | let current_page = framework.data.state.get::<Page>().unwrap().clone(); | 97 | let current_page = framework.data.state.get::<Page>().unwrap().clone(); |
| 98 | 98 | ||
| 99 | if self.page(¤t_page) == current_page { | 99 | if self.page(¤t_page) == current_page { |
| 100 | *framework.data.global.get_mut::<Message>().unwrap() = Message::Message(String::from("You are already on this page")); | 100 | *framework.data.global.get_mut::<Message>().unwrap() = |
| 101 | Message::Message(String::from("You are already on this page")); | ||
| 101 | return false; | 102 | return false; |
| 102 | } | 103 | } |
| 103 | 104 | ||
src/items/singleitem.rs +5 −7
| @@ -370,14 +370,12 @@ impl SingleItem { | |||
| 370 | if iteminfo.selected { | 370 | if iteminfo.selected { |
| 371 | self.grid | 371 | self.grid |
| 372 | .set_border_style(Style::default().fg(appearance.colors.outline_selected)); | 372 | .set_border_style(Style::default().fg(appearance.colors.outline_selected)); |
| 373 | } else if iteminfo.hover { | ||
| 374 | self.grid | ||
| 375 | .set_border_style(Style::default().fg(appearance.colors.outline_hover)); | ||
| 373 | } else { | 376 | } else { |
| 374 | if iteminfo.hover { | 377 | self.grid |
| 375 | self.grid | 378 | .set_border_style(Style::default().fg(appearance.colors.outline)); |
| 376 | .set_border_style(Style::default().fg(appearance.colors.outline_hover)); | ||
| 377 | } else { | ||
| 378 | self.grid | ||
| 379 | .set_border_style(Style::default().fg(appearance.colors.outline)); | ||
| 380 | } | ||
| 381 | } | 379 | } |
| 382 | 380 | ||
| 383 | self.r#type | 381 | self.r#type |