Commit a49e41106a
Unsigned
Layout: unified · split
Cargo.lock +20 −21
| @@ -235,9 +235,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" | ||
| 235 | 235 | |
| 236 | 236 | [[package]] |
| 237 | 237 | name = "cxx" |
| 238 | version = "1.0.81" | |
| 238 | version = "1.0.82" | |
| 239 | 239 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 240 | checksum = "97abf9f0eca9e52b7f81b945524e76710e6cb2366aead23b7d4fbf72e281f888" | |
| 240 | checksum = "d4a41a86530d0fe7f5d9ea779916b7cadd2d4f9add748b99c2c029cbbdfaf453" | |
| 241 | 241 | dependencies = [ |
| 242 | 242 | "cc", |
| 243 | 243 | "cxxbridge-flags", |
| @@ -247,9 +247,9 @@ dependencies = [ | ||
| 247 | 247 | |
| 248 | 248 | [[package]] |
| 249 | 249 | name = "cxx-build" |
| 250 | version = "1.0.81" | |
| 250 | version = "1.0.82" | |
| 251 | 251 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 252 | checksum = "7cc32cc5fea1d894b77d269ddb9f192110069a8a9c1f1d441195fba90553dea3" | |
| 252 | checksum = "06416d667ff3e3ad2df1cd8cd8afae5da26cf9cec4d0825040f88b5ca659a2f0" | |
| 253 | 253 | dependencies = [ |
| 254 | 254 | "cc", |
| 255 | 255 | "codespan-reporting", |
| @@ -262,15 +262,15 @@ dependencies = [ | ||
| 262 | 262 | |
| 263 | 263 | [[package]] |
| 264 | 264 | name = "cxxbridge-flags" |
| 265 | version = "1.0.81" | |
| 265 | version = "1.0.82" | |
| 266 | 266 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 267 | checksum = "8ca220e4794c934dc6b1207c3b42856ad4c302f2df1712e9f8d2eec5afaacf1f" | |
| 267 | checksum = "820a9a2af1669deeef27cb271f476ffd196a2c4b6731336011e0ba63e2c7cf71" | |
| 268 | 268 | |
| 269 | 269 | [[package]] |
| 270 | 270 | name = "cxxbridge-macro" |
| 271 | version = "1.0.81" | |
| 271 | version = "1.0.82" | |
| 272 | 272 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 273 | checksum = "b846f081361125bfc8dc9d3940c84e1fd83ba54bbca7b17cd29483c828be0704" | |
| 273 | checksum = "a08a6e2fcc370a089ad3b4aaf54db3b1b4cee38ddabce5896b33eb693275f470" | |
| 274 | 274 | dependencies = [ |
| 275 | 275 | "proc-macro2", |
| 276 | 276 | "quote", |
| @@ -693,9 +693,9 @@ dependencies = [ | ||
| 693 | 693 | |
| 694 | 694 | [[package]] |
| 695 | 695 | name = "indexmap" |
| 696 | version = "1.9.1" | |
| 696 | version = "1.9.2" | |
| 697 | 697 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 698 | checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" | |
| 698 | checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" | |
| 699 | 699 | dependencies = [ |
| 700 | 700 | "autocfg", |
| 701 | 701 | "hashbrown", |
| @@ -1071,11 +1071,10 @@ dependencies = [ | ||
| 1071 | 1071 | |
| 1072 | 1072 | [[package]] |
| 1073 | 1073 | name = "rayon" |
| 1074 | version = "1.5.3" | |
| 1074 | version = "1.6.0" | |
| 1075 | 1075 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1076 | checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" | |
| 1076 | checksum = "1e060280438193c554f654141c9ea9417886713b7acd75974c85b18a69a88e0b" | |
| 1077 | 1077 | dependencies = [ |
| 1078 | "autocfg", | |
| 1079 | 1078 | "crossbeam-deque", |
| 1080 | 1079 | "either", |
| 1081 | 1080 | "rayon-core", |
| @@ -1083,9 +1082,9 @@ dependencies = [ | ||
| 1083 | 1082 | |
| 1084 | 1083 | [[package]] |
| 1085 | 1084 | name = "rayon-core" |
| 1086 | version = "1.9.3" | |
| 1085 | version = "1.10.1" | |
| 1087 | 1086 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1088 | checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" | |
| 1087 | checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3" | |
| 1089 | 1088 | dependencies = [ |
| 1090 | 1089 | "crossbeam-channel", |
| 1091 | 1090 | "crossbeam-deque", |
| @@ -1113,9 +1112,9 @@ dependencies = [ | ||
| 1113 | 1112 | |
| 1114 | 1113 | [[package]] |
| 1115 | 1114 | name = "reqwest" |
| 1116 | version = "0.11.12" | |
| 1115 | version = "0.11.13" | |
| 1117 | 1116 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1118 | checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc" | |
| 1117 | checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c" | |
| 1119 | 1118 | dependencies = [ |
| 1120 | 1119 | "base64", |
| 1121 | 1120 | "bytes", |
| @@ -1236,9 +1235,9 @@ dependencies = [ | ||
| 1236 | 1235 | |
| 1237 | 1236 | [[package]] |
| 1238 | 1237 | name = "serde_json" |
| 1239 | version = "1.0.87" | |
| 1238 | version = "1.0.88" | |
| 1240 | 1239 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1241 | checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" | |
| 1240 | checksum = "8e8b3801309262e8184d9687fb697586833e939767aea0dda89f5a8e650e8bd7" | |
| 1242 | 1241 | dependencies = [ |
| 1243 | 1242 | "itoa", |
| 1244 | 1243 | "ryu", |
| @@ -1433,9 +1432,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" | ||
| 1433 | 1432 | |
| 1434 | 1433 | [[package]] |
| 1435 | 1434 | name = "tokio" |
| 1436 | version = "1.21.2" | |
| 1435 | version = "1.22.0" | |
| 1437 | 1436 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1438 | checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" | |
| 1437 | checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3" | |
| 1439 | 1438 | dependencies = [ |
| 1440 | 1439 | "autocfg", |
| 1441 | 1440 | "bytes", |
docs/src/README.md +3 −1
| @@ -48,7 +48,9 @@ The YouTube TUI allows you to browse YouTube with (almost) all of it's features, | ||
| 48 | 48 | |
| 49 | 49 | ### What it doesn't have |
| 50 | 50 | |
| 51 | - Vim-like commands (first priority) | |
| 51 | - Next page button in pages (first priority) | |
| 52 | - Lazy image loading (first priority) | |
| 53 | - Vim-like commands (will implement) | |
| 52 | 54 | - Channel search (will implement) |
| 53 | 55 | - Channel videos sorting (will implement) |
| 54 | 56 | - Subscriptions (will implement) |
docs/src/changelogs.md +8 −1
| @@ -1,6 +1,13 @@ | ||
| 1 | 1 | # Changelogs |
| 2 | 2 | |
| 3 | ## v0.5.0 | |
| 3 | ## v0.5.1 | |
| 4 | ||
| 5 | #### Added | |
| 6 | ||
| 7 | - Image lazy loading (will not rerender image if already rendered) | |
| 8 | - Optional features that can be disabled | |
| 9 | ||
| 10 | ### v0.5.0 | |
| 4 | 11 | |
| 5 | 12 | #### Added |
| 6 | 13 | |
docs/src/installation.md +7 −1
| @@ -2,6 +2,8 @@ | ||
| 2 | 2 | |
| 3 | 3 | It's about download (or building) the binary and putting them in an easily accessible location (like `/bin/`). |
| 4 | 4 | |
| 5 | The YouTube TUI is not tested for Windows. | |
| 6 | ||
| 5 | 7 | ## Install from Crates.io (recommended) |
| 6 | 8 | |
| 7 | 9 | Crates.io is a repository for programs written in Rust, and the YouTube TUI is avaliable <a href="https://crates.io/crates/youtube-tui" target=_blank>*there*</a>. |
| @@ -62,10 +64,14 @@ cargo install youtube-tui --all-features # install with all features (even if no | ||
| 62 | 64 | |
| 63 | 65 | ### `halfblock` (default) |
| 64 | 66 | |
| 65 | Display images through HalfBlocks, work best in terminals with TrueColour support (so would not recommend for Windows users). | |
| 67 | Display images through HalfBlocks, work best in terminals with TrueColour support. | |
| 66 | 68 | |
| 67 | 69 | ### `sixel` (default) |
| 68 | 70 | |
| 69 | 71 | Display images with Sixels, allows the display of images at full definition. Not present on windows. |
| 70 | 72 | |
| 71 | 73 | Enabling this will also enable `halfblock`. |
| 74 | ||
| 75 | Requires <a href="https://github.com/saitoha/libsixel" target=_blank>`libsixel`</a>. | |
| 76 | ||
| 77 | > `sixel` and `halfblock` does not compile on Windows. | |
src/global/structs/status.rs +3
| @@ -4,6 +4,8 @@ use typemap::Key; | ||
| 4 | 4 | #[derive(Clone)] |
| 5 | 5 | pub struct Status { |
| 6 | 6 | pub popup_opened: bool, |
| 7 | /// to prevent rerendering the same image | |
| 8 | pub render_image: bool, | |
| 7 | 9 | } |
| 8 | 10 | |
| 9 | 11 | impl Key for Status { |
| @@ -14,6 +16,7 @@ impl Default for Status { | ||
| 14 | 16 | fn default() -> Self { |
| 15 | 17 | Self { |
| 16 | 18 | popup_opened: false, |
| 19 | render_image: true, | |
| 17 | 20 | } |
| 18 | 21 | } |
| 19 | 22 | } |
src/global/structs/tasks.rs +14 −1
| @@ -16,6 +16,7 @@ pub enum Task { | ||
| 16 | 16 | RenderOnly(usize, usize), |
| 17 | 17 | LoadPage(Page), |
| 18 | 18 | ClearPage, |
| 19 | LazyRendered, | |
| 19 | 20 | } |
| 20 | 21 | |
| 21 | 22 | /// multiple tasks joined together, with duplicates removed |
| @@ -25,6 +26,7 @@ pub struct TaskQueue { | ||
| 25 | 26 | pub reload: bool, |
| 26 | 27 | pub load_page: Option<Page>, |
| 27 | 28 | pub clear_all: bool, |
| 29 | pub lazy_rendered: bool, | |
| 28 | 30 | } |
| 29 | 31 | |
| 30 | 32 | impl Default for TaskQueue { |
| @@ -34,6 +36,7 @@ impl Default for TaskQueue { | ||
| 34 | 36 | reload: false, |
| 35 | 37 | load_page: None, |
| 36 | 38 | clear_all: false, |
| 39 | lazy_rendered: false, | |
| 37 | 40 | } |
| 38 | 41 | } |
| 39 | 42 | } |
| @@ -56,6 +59,7 @@ impl TaskQueue { | ||
| 56 | 59 | }, |
| 57 | 60 | Task::LoadPage(page) => self.load_page = Some(page), |
| 58 | 61 | Task::ClearPage => self.clear_all = true, |
| 62 | Task::LazyRendered => self.lazy_rendered = true, | |
| 59 | 63 | // _ => {} |
| 60 | 64 | } |
| 61 | 65 | } |
| @@ -74,6 +78,15 @@ impl TaskQueue { | ||
| 74 | 78 | terminal.clear()?; |
| 75 | 79 | } |
| 76 | 80 | |
| 81 | if self.lazy_rendered { | |
| 82 | framework | |
| 83 | .data | |
| 84 | .global | |
| 85 | .get_mut::<Status>() | |
| 86 | .unwrap() | |
| 87 | .render_image = false; | |
| 88 | } | |
| 89 | ||
| 77 | 90 | // save state in history, then replace all items by whats in the new page and run `.load()` on them |
| 78 | 91 | if let Some(page) = self.load_page { |
| 79 | 92 | *framework.data.global.get_mut::<Message>().unwrap() = |
| @@ -87,7 +100,7 @@ impl TaskQueue { | ||
| 87 | 100 | |
| 88 | 101 | let state = page_config.to_state(framework); |
| 89 | 102 | framework.set_state(state); |
| 90 | framework.data.state.get_mut::<Status>().unwrap().reset(); | |
| 103 | framework.data.global.get_mut::<Status>().unwrap().reset(); | |
| 91 | 104 | *framework.data.state.get_mut::<Page>().unwrap() = page; |
| 92 | 105 | Self::render_force_clear(framework, terminal)?; |
| 93 | 106 | *framework.data.global.get_mut::<Message>().unwrap() = Message::None; |
src/init.rs +1 −1
| @@ -69,6 +69,7 @@ pub fn init(framework: &mut Framework) -> Result<(), Box<dyn Error>> { | ||
| 69 | 69 | .data |
| 70 | 70 | .global |
| 71 | 71 | .insert::<CommandsConfig>(CommandsConfig::from(*CommandsConfigSerde::load()?)); |
| 72 | framework.data.global.insert::<Status>(Status::default()); | |
| 72 | 73 | |
| 73 | 74 | framework.data.state.insert::<Tasks>(Tasks::default()); |
| 74 | 75 | framework.data.state.insert::<Page>(Page::default()); |
| @@ -77,7 +78,6 @@ pub fn init(framework: &mut Framework) -> Result<(), Box<dyn Error>> { | ||
| 77 | 78 | .data |
| 78 | 79 | .state |
| 79 | 80 | .insert::<MinDimentions>(MinDimentions::default()); |
| 80 | framework.data.state.insert::<Status>(Status::default()); | |
| 81 | 81 | |
| 82 | 82 | Ok(()) |
| 83 | 83 | } |
src/items/channeldisplay.rs +22 −13
| @@ -5,7 +5,7 @@ use crate::{ | ||
| 5 | 5 | functions::download_all_images, |
| 6 | 6 | structs::{ |
| 7 | 7 | ChannelDisplayPageType, InvidiousClient, Item, KeyAction, Message, Page, |
| 8 | SingleItemPage, Task, Tasks, | |
| 8 | SingleItemPage, Status, Task, Tasks, | |
| 9 | 9 | }, |
| 10 | 10 | }, |
| 11 | 11 | }; |
| @@ -25,6 +25,7 @@ pub enum ChannelDisplay { | ||
| 25 | 25 | None, |
| 26 | 26 | Main { |
| 27 | 27 | channel: Item, |
| 28 | iteminfo: ItemInfo, | |
| 28 | 29 | }, |
| 29 | 30 | Videos { |
| 30 | 31 | videos: Vec<Item>, |
| @@ -133,7 +134,7 @@ impl FrameworkItem for ChannelDisplay { | ||
| 133 | 134 | .border_style(border_style); |
| 134 | 135 | frame.render_widget(block, area); |
| 135 | 136 | } |
| 136 | Self::Main { channel } => { | |
| 137 | Self::Main { iteminfo, .. } => { | |
| 137 | 138 | let block = Block::default() |
| 138 | 139 | .border_type(appearance.borders) |
| 139 | 140 | .borders(Borders::ALL) |
| @@ -141,10 +142,7 @@ impl FrameworkItem for ChannelDisplay { | ||
| 141 | 142 | let inner = block.inner(area); |
| 142 | 143 | |
| 143 | 144 | frame.render_widget(block, area); |
| 144 | ItemInfo { | |
| 145 | item: Some(channel.clone()), | |
| 146 | } | |
| 147 | .render(frame, framework, inner, popup_render, info); | |
| 145 | iteminfo.render(frame, framework, inner, popup_render, info); | |
| 148 | 146 | } |
| 149 | 147 | Self::Videos { |
| 150 | 148 | textlist, |
| @@ -237,6 +235,12 @@ impl FrameworkItem for ChannelDisplay { | ||
| 237 | 235 | .unwrap() |
| 238 | 236 | .priority |
| 239 | 237 | .push(Task::RenderAll); |
| 238 | framework | |
| 239 | .data | |
| 240 | .global | |
| 241 | .get_mut::<Status>() | |
| 242 | .unwrap() | |
| 243 | .render_image = true; | |
| 240 | 244 | iteminfo.item = Some(videos[textlist.selected].clone()); |
| 241 | 245 | } |
| 242 | 246 | } |
| @@ -279,6 +283,12 @@ impl FrameworkItem for ChannelDisplay { | ||
| 279 | 283 | .unwrap() |
| 280 | 284 | .priority |
| 281 | 285 | .push(Task::RenderAll); |
| 286 | framework | |
| 287 | .data | |
| 288 | .global | |
| 289 | .get_mut::<Status>() | |
| 290 | .unwrap() | |
| 291 | .render_image = true; | |
| 282 | 292 | iteminfo.item = Some(playlists[textlist.selected].clone()); |
| 283 | 293 | } |
| 284 | 294 | } |
| @@ -310,7 +320,10 @@ impl FrameworkItem for ChannelDisplay { | ||
| 310 | 320 | mainconfig.image_index, |
| 311 | 321 | ); |
| 312 | 322 | download_all_images(vec![(&channel).into()]); |
| 313 | *self = Self::Main { channel } | |
| 323 | *self = Self::Main { | |
| 324 | iteminfo: ItemInfo::new(Some(channel.clone())), | |
| 325 | channel, | |
| 326 | } | |
| 314 | 327 | } |
| 315 | 328 | ChannelDisplayPageType::Videos => { |
| 316 | 329 | let videos = framework |
| @@ -331,9 +344,7 @@ impl FrameworkItem for ChannelDisplay { | ||
| 331 | 344 | .border_type(appearance.borders) |
| 332 | 345 | .style(Style::default().fg(appearance.colors.text)) |
| 333 | 346 | .items(&videos)?, |
| 334 | iteminfo: ItemInfo { | |
| 335 | item: videos.first().cloned(), | |
| 336 | }, | |
| 347 | iteminfo: ItemInfo::new(videos.first().cloned()), | |
| 337 | 348 | grid: Grid::new( |
| 338 | 349 | vec![Constraint::Percentage(60), Constraint::Percentage(40)], |
| 339 | 350 | vec![Constraint::Percentage(100)], |
| @@ -361,9 +372,7 @@ impl FrameworkItem for ChannelDisplay { | ||
| 361 | 372 | .border_type(appearance.borders) |
| 362 | 373 | .style(Style::default().fg(appearance.colors.text)) |
| 363 | 374 | .items(&playlists)?, |
| 364 | iteminfo: ItemInfo { | |
| 365 | item: playlists.first().cloned(), | |
| 366 | }, | |
| 375 | iteminfo: ItemInfo::new(playlists.first().cloned()), | |
| 367 | 376 | grid: Grid::new( |
| 368 | 377 | vec![Constraint::Percentage(60), Constraint::Percentage(40)], |
| 369 | 378 | vec![Constraint::Percentage(100)], |
src/items/iteminfo.rs +31 −5
| @@ -9,13 +9,14 @@ use viuer::{print_from_file, Config}; | ||
| 9 | 9 | |
| 10 | 10 | use crate::{ |
| 11 | 11 | config::{AppearanceConfig, MainConfig}, |
| 12 | global::structs::{Item, Status}, | |
| 12 | global::structs::{Item, Status, Task, Tasks}, | |
| 13 | 13 | }; |
| 14 | 14 | |
| 15 | 15 | /// an item info displays info of any `Item`s |
| 16 | 16 | #[derive(Clone)] |
| 17 | 17 | pub struct ItemInfo { |
| 18 | 18 | pub item: Option<Item>, |
| 19 | pub lazy_scroll: u16, | |
| 19 | 20 | } |
| 20 | 21 | |
| 21 | 22 | impl FrameworkItem for ItemInfo { |
| @@ -38,12 +39,14 @@ impl FrameworkItem for ItemInfo { | ||
| 38 | 39 | }; |
| 39 | 40 | |
| 40 | 41 | let main_config = framework.data.global.get::<MainConfig>().unwrap(); |
| 41 | let appearance = framework.data.global.get::<AppearanceConfig>().unwrap(); | |
| 42 | let status = framework.data.global.get::<Status>().unwrap(); | |
| 42 | 43 | |
| 43 | 44 | // 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 |
| 44 | let scroll = if cfg!(any(feature = "halfblock", feature = "sixel")) | |
| 45 | let scroll = if !status.render_image { | |
| 46 | self.lazy_scroll | |
| 47 | } else if cfg!(any(feature = "halfblock", feature = "sixel")) | |
| 45 | 48 | && main_config.images.display() |
| 46 | && !framework.data.state.get::<Status>().unwrap().popup_opened | |
| 49 | && !status.popup_opened | |
| 47 | 50 | { |
| 48 | 51 | let mut scroll = 0; |
| 49 | 52 | |
| @@ -74,6 +77,13 @@ impl FrameworkItem for ItemInfo { | ||
| 74 | 77 | |
| 75 | 78 | if let Ok((_, height)) = print_from_file(thumbnail_path, &config) { |
| 76 | 79 | scroll = height as u16; |
| 80 | framework | |
| 81 | .data | |
| 82 | .state | |
| 83 | .get_mut::<Tasks>() | |
| 84 | .unwrap() | |
| 85 | .priority | |
| 86 | .push(Task::LazyRendered); | |
| 77 | 87 | } else { |
| 78 | 88 | scroll = 0; |
| 79 | 89 | } |
| @@ -84,6 +94,10 @@ impl FrameworkItem for ItemInfo { | ||
| 84 | 94 | 0 |
| 85 | 95 | }; |
| 86 | 96 | |
| 97 | self.lazy_scroll = scroll; | |
| 98 | ||
| 99 | let appearance = framework.data.global.get::<AppearanceConfig>().unwrap(); | |
| 100 | ||
| 87 | 101 | // Each "span" contains a string and a Style, and they are one line max each |
| 88 | 102 | // A "text" is used for descriptions in video/playlist and channels, and starts a new line if the old one runs out |
| 89 | 103 | let (spans, text) = match item { |
| @@ -359,6 +373,18 @@ impl FrameworkItem for ItemInfo { | ||
| 359 | 373 | |
| 360 | 374 | impl Default for ItemInfo { |
| 361 | 375 | fn default() -> Self { |
| 362 | Self { item: None } | |
| 376 | Self { | |
| 377 | item: None, | |
| 378 | lazy_scroll: 0, | |
| 379 | } | |
| 380 | } | |
| 381 | } | |
| 382 | ||
| 383 | impl ItemInfo { | |
| 384 | pub fn new(item: Option<Item>) -> Self { | |
| 385 | Self { | |
| 386 | item, | |
| 387 | ..Default::default() | |
| 388 | } | |
| 363 | 389 | } |
| 364 | 390 | } |
src/items/itemlist.rs +7 −1
| @@ -14,7 +14,7 @@ use crate::{ | ||
| 14 | 14 | structs::{ |
| 15 | 15 | ChannelDisplayPage, ChannelDisplayPageType, FullPlaylistItem, FullVideoItem, |
| 16 | 16 | InvidiousClient, Item, KeyAction, MainMenuPage, MiniChannelItem, MiniPlaylistItem, |
| 17 | MiniVideoItem, Page, SingleItemPage, Task, Tasks, WatchHistory, | |
| 17 | MiniVideoItem, Page, SingleItemPage, Status, Task, Tasks, WatchHistory, | |
| 18 | 18 | }, |
| 19 | 19 | }, |
| 20 | 20 | }; |
| @@ -264,6 +264,12 @@ impl FrameworkItem for ItemList { | ||
| 264 | 264 | |
| 265 | 265 | // only create a render task if the key event actually changed something |
| 266 | 266 | if updated { |
| 267 | framework | |
| 268 | .data | |
| 269 | .global | |
| 270 | .get_mut::<Status>() | |
| 271 | .unwrap() | |
| 272 | .render_image = true; | |
| 267 | 273 | self.info.item = Some(self.items[self.textlist.selected].clone()); |
| 268 | 274 | framework |
| 269 | 275 | .data |
src/items/searchfilters.rs +5 −7
| @@ -188,7 +188,7 @@ impl FrameworkItem for SearchFilter { | ||
| 188 | 188 | fn select(&mut self, framework: &mut tui_additions::framework::FrameworkClean) -> bool { |
| 189 | 189 | framework |
| 190 | 190 | .data |
| 191 | .state | |
| 191 | .global | |
| 192 | 192 | .get_mut::<Status>() |
| 193 | 193 | .unwrap() |
| 194 | 194 | .popup_opened = true; |
| @@ -220,12 +220,10 @@ impl FrameworkItem for SearchFilter { | ||
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | fn deselect(&mut self, framework: &mut tui_additions::framework::FrameworkClean) -> bool { |
| 223 | framework | |
| 224 | .data | |
| 225 | .state | |
| 226 | .get_mut::<Status>() | |
| 227 | .unwrap() | |
| 228 | .popup_opened = false; | |
| 223 | *framework.data.global.get_mut::<Status>().unwrap() = Status { | |
| 224 | popup_opened: false, | |
| 225 | render_image: true, | |
| 226 | }; | |
| 229 | 227 | |
| 230 | 228 | // refresh page only if changed and enabled in options |
| 231 | 229 | let search_options = framework.data.state.get::<Search>().unwrap().clone(); |
src/items/singleitem.rs +12 −8
| @@ -4,7 +4,7 @@ use crate::{ | ||
| 4 | 4 | global::{ |
| 5 | 5 | functions::download_all_images, |
| 6 | 6 | structs::{ |
| 7 | InvidiousClient, Item, KeyAction, Message, Page, SingleItemPage, Task, Tasks, | |
| 7 | InvidiousClient, Item, KeyAction, Message, Page, SingleItemPage, Status, Task, Tasks, | |
| 8 | 8 | WatchHistory, |
| 9 | 9 | }, |
| 10 | 10 | }, |
| @@ -168,13 +168,11 @@ impl SinglePlaylistItem { | ||
| 168 | 168 | mainconfig: &MainConfig, |
| 169 | 169 | playlist_items: &[Item], |
| 170 | 170 | ) -> Self { |
| 171 | let hovered_video = ItemInfo { | |
| 172 | item: if playlist_items.is_empty() { | |
| 173 | None | |
| 174 | } else { | |
| 175 | Some(playlist_items[0].clone()) | |
| 176 | }, | |
| 177 | }; | |
| 171 | let hovered_video = ItemInfo::new(if playlist_items.is_empty() { | |
| 172 | None | |
| 173 | } else { | |
| 174 | Some(playlist_items[0].clone()) | |
| 175 | }); | |
| 178 | 176 | Self { |
| 179 | 177 | commands_view: TextList::default() |
| 180 | 178 | .items(&commands.playlist.iter().map(|command| &command.0).collect()) |
| @@ -763,6 +761,12 @@ impl FrameworkItem for SingleItem { | ||
| 763 | 761 | }; |
| 764 | 762 | |
| 765 | 763 | if updated { |
| 764 | framework | |
| 765 | .data | |
| 766 | .global | |
| 767 | .get_mut::<Status>() | |
| 768 | .unwrap() | |
| 769 | .render_image = true; | |
| 766 | 770 | framework |
| 767 | 771 | .data |
| 768 | 772 | .state |
src/run.rs +19 −1
| @@ -5,7 +5,7 @@ use tui_additions::framework::{Framework, FrameworkDirection}; | ||
| 5 | 5 | |
| 6 | 6 | use crate::{ |
| 7 | 7 | config::KeyBindingsConfig, |
| 8 | global::structs::{KeyAction, MainMenuPage, Message, Page, Task, Tasks}, | |
| 8 | global::structs::{KeyAction, MainMenuPage, Message, Page, Status, Task, Tasks}, | |
| 9 | 9 | }; |
| 10 | 10 | |
| 11 | 11 | /// the main event loop of the program |
| @@ -91,6 +91,12 @@ pub fn run( | ||
| 91 | 91 | "This is already the beginning of history", |
| 92 | 92 | )) |
| 93 | 93 | } else { |
| 94 | framework | |
| 95 | .data | |
| 96 | .global | |
| 97 | .get_mut::<Status>() | |
| 98 | .unwrap() | |
| 99 | .render_image = true; | |
| 94 | 100 | framework |
| 95 | 101 | .data |
| 96 | 102 | .state |
| @@ -107,6 +113,12 @@ pub fn run( | ||
| 107 | 113 | "This is already the beginning of history", |
| 108 | 114 | )) |
| 109 | 115 | } else { |
| 116 | framework | |
| 117 | .data | |
| 118 | .global | |
| 119 | .get_mut::<Status>() | |
| 120 | .unwrap() | |
| 121 | .render_image = true; | |
| 110 | 122 | framework |
| 111 | 123 | .data |
| 112 | 124 | .state |
| @@ -153,6 +165,12 @@ pub fn run( | ||
| 153 | 165 | .unwrap() |
| 154 | 166 | .priority |
| 155 | 167 | .push(Task::RenderAll); |
| 168 | framework | |
| 169 | .data | |
| 170 | .global | |
| 171 | .get_mut::<Status>() | |
| 172 | .unwrap() | |
| 173 | .render_image = true; | |
| 156 | 174 | } |
| 157 | 175 | _ => {} |
| 158 | 176 | } |