Commit af1b4fe68d
Unsigned
Layout: unified · split
Cargo.lock +5 −5
| @@ -150,9 +150,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" | |||
| 150 | 150 | ||
| 151 | [[package]] | 151 | [[package]] |
| 152 | name = "console" | 152 | name = "console" |
| 153 | version = "0.15.3" | 153 | version = "0.15.4" |
| 154 | source = "registry+https://github.com/rust-lang/crates.io-index" | 154 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 155 | checksum = "5556015fe3aad8b968e5d4124980fbe2f6aaee7aeec6b749de1faaa2ca5d0a4c" | 155 | checksum = "c9b6515d269224923b26b5febea2ed42b2d5f2ce37284a4dd670fedd6cb8347a" |
| 156 | dependencies = [ | 156 | dependencies = [ |
| 157 | "encode_unicode", | 157 | "encode_unicode", |
| 158 | "lazy_static", | 158 | "lazy_static", |
| @@ -1477,9 +1477,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" | |||
| 1477 | 1477 | ||
| 1478 | [[package]] | 1478 | [[package]] |
| 1479 | name = "tokio" | 1479 | name = "tokio" |
| 1480 | version = "1.23.0" | 1480 | version = "1.24.0" |
| 1481 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1481 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1482 | checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46" | 1482 | checksum = "7125661431c26622a80ca5051a2f936c9a678318e0351007b0cc313143024e5c" |
| 1483 | dependencies = [ | 1483 | dependencies = [ |
| 1484 | "autocfg", | 1484 | "autocfg", |
| 1485 | "bytes", | 1485 | "bytes", |
| @@ -1943,7 +1943,7 @@ dependencies = [ | |||
| 1943 | 1943 | ||
| 1944 | [[package]] | 1944 | [[package]] |
| 1945 | name = "youtube-tui" | 1945 | name = "youtube-tui" |
| 1946 | version = "0.6.0" | 1946 | version = "0.6.1" |
| 1947 | dependencies = [ | 1947 | dependencies = [ |
| 1948 | "chrono", | 1948 | "chrono", |
| 1949 | "clipboard", | 1949 | "clipboard", |
Cargo.toml +1 −1
| @@ -1,6 +1,6 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "youtube-tui" | 2 | name = "youtube-tui" |
| 3 | version = "0.6.0" | 3 | version = "0.6.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" |
README.md +6 −9
| @@ -12,7 +12,7 @@ Written in Rust, the **YouTube TUI** is a lightweight and user friendly TUI for | |||
| 12 | 12 | ||
| 13 |  | 13 |  |
| 14 | 14 | ||
| 15 | It is like an *app launcher*, it launches other programs to do the heavy lifting (for example, `mpv` for playing videos). | 15 | It is like an _app launcher_, it launches other programs to do the heavy lifting (for example, `mpv` for playing videos). |
| 16 | 16 | ||
| 17 | ## Customisable | 17 | ## Customisable |
| 18 | 18 | ||
| @@ -21,6 +21,7 @@ The YouTube TUI can be customised through config files, they are located in `~/. | |||
| 21 | Here's an example of the config file: | 21 | Here's an example of the config file: |
| 22 | 22 | ||
| 23 | ```yaml | 23 | ```yaml |
| 24 | mouse_support: true | ||
| 24 | invidious_instance: https://vid.puffyan.us | 25 | invidious_instance: https://vid.puffyan.us |
| 25 | max_watch_history: 50 | 26 | max_watch_history: 50 |
| 26 | allow_unicode: false | 27 | allow_unicode: false |
| @@ -32,14 +33,13 @@ env: | |||
| 32 | video-player: mpv | 33 | video-player: mpv |
| 33 | youtube-downloader: yt-dlp | 34 | youtube-downloader: yt-dlp |
| 34 | terminal-emulator: konsole -e | 35 | terminal-emulator: konsole -e |
| 35 | |||
| 36 | ``` | 36 | ``` |
| 37 | 37 | ||
| 38 | Anything from layouts to colours and keybindings can be customised, more on that later. | 38 | Anything from layouts to colours and keybindings can be customised, more on that later. |
| 39 | 39 | ||
| 40 | ## Dependency-free | 40 | ## Dependency-free |
| 41 | 41 | ||
| 42 | The YouTube TUI does not work on its own, it is instead like a *TUI frontend* for programs like `mpv` or `yt-dlp`/`youtube-dl`. | 42 | The YouTube TUI does not work on its own, it is instead like a _TUI frontend_ for programs like `mpv` or `yt-dlp`/`youtube-dl`. |
| 43 | 43 | ||
| 44 | However, the programs to launch can be changed, and therefore the YouTube TUI <u>does not rely on any specific dependencies</u> to run. | 44 | However, the programs to launch can be changed, and therefore the YouTube TUI <u>does not rely on any specific dependencies</u> to run. |
| 45 | 45 | ||
| @@ -61,20 +61,17 @@ It also includes features like: | |||
| 61 | 61 | ||
| 62 | ### What it doesn't have | 62 | ### What it doesn't have |
| 63 | 63 | ||
| 64 | - Command line args (first priority) | 64 | - Binding commands to keys (first priority) |
| 65 | - Bootleg Vimscript? (will implement) | ||
| 66 | - Channel search (will implement) | 65 | - Channel search (will implement) |
| 67 | - Channel videos sorting (will implement) | ||
| 68 | - Subscriptions (will implement) | 66 | - Subscriptions (will implement) |
| 69 | - Recommendations/comments (probably will not implement) | ||
| 70 | 67 | ||
| 71 | ## How to contribute | 68 | ## How to contribute |
| 72 | 69 | ||
| 73 | You will need a <u>general knowledge</u> of the Rust programming language, and the ability to *understand my spaghetti*. | 70 | You will need a <u>general knowledge</u> of the Rust programming language, and the ability to _understand my spaghetti_. |
| 74 | 71 | ||
| 75 | 1. Open an issue to make sure nobody else is working on the same feature | 72 | 1. Open an issue to make sure nobody else is working on the same feature |
| 76 | 2. Write code | 73 | 2. Write code |
| 77 | 3. Open a pull request | 74 | 3. Open a pull request |
| 78 | 4. Get merged? | 75 | 4. Get merged? |
| 79 | 76 | ||
| 80 | Or just *fix that typo in README* -_- | 77 | Or just _fix that typo in README_ -\_- |
docs/src/README.md +5 −7
| @@ -4,7 +4,7 @@ Written in Rust, the **YouTube TUI** is a lightweight and user friendly TUI for | |||
| 4 | 4 | ||
| 5 |  | 5 |  |
| 6 | 6 | ||
| 7 | It is like an *app launcher*, it launches other programs to do the heavy lifting (for example, `mpv` for playing videos). | 7 | It is like an _app launcher_, it launches other programs to do the heavy lifting (for example, `mpv` for playing videos). |
| 8 | 8 | ||
| 9 | ## Customisable | 9 | ## Customisable |
| 10 | 10 | ||
| @@ -13,6 +13,7 @@ The YouTube TUI can be customised through config files, they are located in `~/. | |||
| 13 | Here's an example of the config file: | 13 | Here's an example of the config file: |
| 14 | 14 | ||
| 15 | ```yaml | 15 | ```yaml |
| 16 | mouse_support: true | ||
| 16 | invidious_instance: https://vid.puffyan.us | 17 | invidious_instance: https://vid.puffyan.us |
| 17 | max_watch_history: 50 | 18 | max_watch_history: 50 |
| 18 | allow_unicode: false | 19 | allow_unicode: false |
| @@ -24,14 +25,13 @@ env: | |||
| 24 | video-player: mpv | 25 | video-player: mpv |
| 25 | youtube-downloader: yt-dlp | 26 | youtube-downloader: yt-dlp |
| 26 | terminal-emulator: konsole -e | 27 | terminal-emulator: konsole -e |
| 27 | |||
| 28 | ``` | 28 | ``` |
| 29 | 29 | ||
| 30 | Anything from layouts to colours and keybindings can be customised, more on that later. | 30 | Anything from layouts to colours and keybindings can be customised, more on that later. |
| 31 | 31 | ||
| 32 | ## Dependency-free | 32 | ## Dependency-free |
| 33 | 33 | ||
| 34 | The YouTube TUI does not work on its own, it is instead like a *TUI frontend* for programs like `mpv` or `yt-dlp`/`youtube-dl`. | 34 | The YouTube TUI does not work on its own, it is instead like a _TUI frontend_ for programs like `mpv` or `yt-dlp`/`youtube-dl`. |
| 35 | 35 | ||
| 36 | However, the programs to launch can be changed, and therefore the YouTube TUI <u>does not rely on any specific dependencies</u> to run. | 36 | However, the programs to launch can be changed, and therefore the YouTube TUI <u>does not rely on any specific dependencies</u> to run. |
| 37 | 37 | ||
| @@ -54,18 +54,16 @@ It also includes features like: | |||
| 54 | ### What it doesn't have | 54 | ### What it doesn't have |
| 55 | 55 | ||
| 56 | - Binding commands to keys (first priority) | 56 | - Binding commands to keys (first priority) |
| 57 | - Bootleg Vimscript? (first priority) | ||
| 58 | - Channel search (will implement) | 57 | - Channel search (will implement) |
| 59 | - Channel videos sorting (will implement) | ||
| 60 | - Subscriptions (will implement) | 58 | - Subscriptions (will implement) |
| 61 | 59 | ||
| 62 | ## How to contribute | 60 | ## How to contribute |
| 63 | 61 | ||
| 64 | You will need a <u>general knowledge</u> of the Rust programming language, and the ability to *understand my spaghetti*. | 62 | You will need a <u>general knowledge</u> of the Rust programming language, and the ability to _understand my spaghetti_. |
| 65 | 63 | ||
| 66 | 1. Open an issue to make sure nobody else is working on the same feature | 64 | 1. Open an issue to make sure nobody else is working on the same feature |
| 67 | 2. Write code | 65 | 2. Write code |
| 68 | 3. Open a pull request | 66 | 3. Open a pull request |
| 69 | 4. Get merged? | 67 | 4. Get merged? |
| 70 | 68 | ||
| 71 | Or just *fix that typo in README* -_- | 69 | Or just _fix that typo in README_ -\_- |
docs/src/commands.md +1
| @@ -38,6 +38,7 @@ reload (alt `r`) | |||
| 38 | reload configs (alt `reload/r config/configs`) | 38 | reload configs (alt `reload/r config/configs`) |
| 39 | flush | 39 | flush |
| 40 | quit (alt `q`, `exit`, `x`) | 40 | quit (alt `q`, `exit`, `x`) |
| 41 | run [command] | ||
| 41 | ``` | 42 | ``` |
| 42 | 43 | ||
| 43 | > The `flush` command is used to run all tasks in queue immediately, this is usually done automatically. | 44 | > The `flush` command is used to run all tasks in queue immediately, this is usually done automatically. |
src/config/commands.rs +15 −15
| @@ -63,36 +63,36 @@ fn video_default() -> Vec<HashMap<String, String>> { | |||
| 63 | vec![ | 63 | vec![ |
| 64 | HashMap::from([( | 64 | HashMap::from([( |
| 65 | String::from("Play video"), | 65 | String::from("Play video"), |
| 66 | String::from("${video-player} ${embed-url}"), | 66 | String::from("run ${video-player} ${embed-url}"), |
| 67 | )]), | 67 | )]), |
| 68 | HashMap::from([( | 68 | HashMap::from([( |
| 69 | String::from("Play audio"), | 69 | String::from("Play audio"), |
| 70 | String::from("${terminal-emulator} ${video-player} ${embed-url} --no-video"), | 70 | String::from("run ${terminal-emulator} ${video-player} ${embed-url} --no-video"), |
| 71 | )]), | 71 | )]), |
| 72 | HashMap::from([( | 72 | HashMap::from([( |
| 73 | String::from("Play audio (loop)"), | 73 | String::from("Play audio (loop)"), |
| 74 | String::from( | 74 | String::from( |
| 75 | "${terminal-emulator} ${video-player} ${embed-url} --no-video --loop-file=inf", | 75 | "run ${terminal-emulator} ${video-player} ${embed-url} --no-video --loop-file=inf", |
| 76 | ), | 76 | ), |
| 77 | )]), | 77 | )]), |
| 78 | HashMap::from([( | 78 | HashMap::from([( |
| 79 | String::from("View channel"), | 79 | String::from("View channel"), |
| 80 | String::from(":channel ${channel-id}"), | 80 | String::from("channel ${channel-id}"), |
| 81 | )]), | 81 | )]), |
| 82 | HashMap::from([( | 82 | HashMap::from([( |
| 83 | String::from("Open in browser"), | 83 | String::from("Open in browser"), |
| 84 | String::from("${browser} ${url}"), | 84 | String::from("run ${browser} ${url}"), |
| 85 | )]), | 85 | )]), |
| 86 | HashMap::from([( | 86 | HashMap::from([( |
| 87 | String::from("Download video (webm)"), | 87 | String::from("Download video (webm)"), |
| 88 | String::from( | 88 | String::from( |
| 89 | "${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url}", | 89 | "run ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url}", |
| 90 | ), | 90 | ), |
| 91 | )]), | 91 | )]), |
| 92 | HashMap::from([( | 92 | HashMap::from([( |
| 93 | String::from("Download audio (opus)"), | 93 | String::from("Download audio (opus)"), |
| 94 | String::from( | 94 | String::from( |
| 95 | "${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url} -x", | 95 | "run ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${embed-url} -x", |
| 96 | ), | 96 | ), |
| 97 | )]), | 97 | )]), |
| 98 | HashMap::from([( | 98 | HashMap::from([( |
| @@ -107,35 +107,35 @@ fn playlist_default() -> Vec<HashMap<String, String>> { | |||
| 107 | HashMap::from([(String::from("Switch view"), String::from("%switch-view%"))]), | 107 | HashMap::from([(String::from("Switch view"), String::from("%switch-view%"))]), |
| 108 | HashMap::from([( | 108 | HashMap::from([( |
| 109 | String::from("Play all videos"), | 109 | String::from("Play all videos"), |
| 110 | String::from("${video-player} ${all-videos}"), | 110 | String::from("run ${video-player} ${all-videos}"), |
| 111 | )]), | 111 | )]), |
| 112 | HashMap::from([( | 112 | HashMap::from([( |
| 113 | String::from("Play all audio"), | 113 | String::from("Play all audio"), |
| 114 | String::from("${terminal-emulator} ${video-player} ${all-videos} --no-video"), | 114 | String::from("run ${terminal-emulator} ${video-player} ${all-videos} --no-video"), |
| 115 | )]), | 115 | )]), |
| 116 | HashMap::from([( | 116 | HashMap::from([( |
| 117 | String::from("Shuffle play all audio"), | 117 | String::from("Shuffle play all audio"), |
| 118 | String::from("${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle"), | 118 | String::from("run ${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle"), |
| 119 | )]), | 119 | )]), |
| 120 | HashMap::from([( | 120 | HashMap::from([( |
| 121 | String::from("Shuffle play all audio (loop)"), | 121 | String::from("Shuffle play all audio (loop)"), |
| 122 | String::from("${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle --loop-playlist=inf"), | 122 | String::from("run ${terminal-emulator} ${video-player} ${all-videos} --no-video --shuffle --loop-playlist=inf"), |
| 123 | )]), | 123 | )]), |
| 124 | HashMap::from([( | 124 | HashMap::from([( |
| 125 | String::from("View channel"), | 125 | String::from("View channel"), |
| 126 | String::from(":channel ${channel-id}"), | 126 | String::from("channel ${channel-id}"), |
| 127 | )]), | 127 | )]), |
| 128 | HashMap::from([( | 128 | HashMap::from([( |
| 129 | String::from("Open in browser"), | 129 | String::from("Open in browser"), |
| 130 | String::from("${browser} ${url}"), | 130 | String::from("run ${browser} ${url}"), |
| 131 | )]), | 131 | )]), |
| 132 | HashMap::from([( | 132 | HashMap::from([( |
| 133 | String::from("Download all video (webm)"), | 133 | String::from("Download all video (webm)"), |
| 134 | String::from("${terminal-emulator} ${youtube-downloader} -o ${download-path} ${all-videos}") | 134 | String::from("run ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${all-videos}") |
| 135 | )]), | 135 | )]), |
| 136 | HashMap::from([( | 136 | HashMap::from([( |
| 137 | String::from("Download all audio (opus)"), | 137 | String::from("Download all audio (opus)"), |
| 138 | String::from("${terminal-emulator} ${youtube-downloader} -o ${download-path} ${all-videos} -x") | 138 | String::from("run ${terminal-emulator} ${youtube-downloader} -o ${download-path} ${all-videos} -x") |
| 139 | )]), | 139 | )]), |
| 140 | HashMap::from([( | 140 | HashMap::from([( |
| 141 | String::from("Mode: ${provider}"), | 141 | String::from("Mode: ${provider}"), |
src/global/functions/run_command.rs +10 −1
| @@ -237,8 +237,16 @@ pub fn run_command( | |||
| 237 | )); | 237 | )); |
| 238 | false | 238 | false |
| 239 | } | 239 | } |
| 240 | ["run"] => { | ||
| 241 | *framework.data.global.get_mut::<Message>().unwrap() = | ||
| 242 | Message::Message(String::from("Usage: run [command]")); | ||
| 243 | false | ||
| 244 | } | ||
| 240 | ["run", ..] => { | 245 | ["run", ..] => { |
| 241 | let mut command = execute::command(&command[1..].join(" ")); | 246 | let command = &command[1..].join(" "); |
| 247 | *framework.data.global.get_mut::<Message>().unwrap() = | ||
| 248 | Message::Success(command.clone()); | ||
| 249 | let mut command = execute::command(command); | ||
| 242 | thread::spawn(move || { | 250 | thread::spawn(move || { |
| 243 | let _ = command.output(); | 251 | let _ = command.output(); |
| 244 | }); | 252 | }); |
| @@ -313,6 +321,7 @@ const HELP_MSG: &str = "\x1b[32mYouTube TUI commands\x1b[0m | |||
| 313 | \x1b[33mreload configs\x1b[0m Reload all config files | 321 | \x1b[33mreload configs\x1b[0m Reload all config files |
| 314 | \x1b[33mflush\x1b[0m Run all tasks in queue immediately | 322 | \x1b[33mflush\x1b[0m Run all tasks in queue immediately |
| 315 | \x1b[33mquit\x1b[0m Immediately exit | 323 | \x1b[33mquit\x1b[0m Immediately exit |
| 324 | \x1b[33mrun [command]\x1b[0m Runs a system command (e.g. `run firefox example.com`) | ||
| 316 | 325 | ||
| 317 | \x1b[91mALT:\x1b[0m | 326 | \x1b[91mALT:\x1b[0m |
| 318 | \x1b[37malts links back to the original command\x1b[30m | 327 | \x1b[37malts links back to the original command\x1b[30m |
src/items/channeldisplay.rs +1 −4
| @@ -25,10 +25,7 @@ pub enum ChannelDisplay { | |||
| 25 | /// a blank item, will turn into one of the other variants when `.load()` depending on the page | 25 | /// a blank item, will turn into one of the other variants when `.load()` depending on the page |
| 26 | None, | 26 | None, |
| 27 | /// main channel display page | 27 | /// main channel display page |
| 28 | Main { | 28 | Main { channel: Item, iteminfo: ItemInfo }, |
| 29 | channel: Item, | ||
| 30 | iteminfo: ItemInfo, | ||
| 31 | }, | ||
| 32 | /// latest videos | 29 | /// latest videos |
| 33 | Videos { | 30 | Videos { |
| 34 | videos: Vec<Item>, | 31 | videos: Vec<Item>, |
src/items/singleitem.rs +28 −47
| @@ -9,7 +9,6 @@ use crate::{ | |||
| 9 | }, | 9 | }, |
| 10 | }, | 10 | }, |
| 11 | }; | 11 | }; |
| 12 | use std::thread; | ||
| 13 | use tui::{ | 12 | use tui::{ |
| 14 | layout::{Constraint, Rect}, | 13 | layout::{Constraint, Rect}, |
| 15 | style::Style, | 14 | style::Style, |
| @@ -337,10 +336,12 @@ impl SinglePlaylistItem { | |||
| 337 | } | 336 | } |
| 338 | 337 | ||
| 339 | impl SingleItemType { | 338 | impl SingleItemType { |
| 339 | /// self is none | ||
| 340 | pub fn is_none(&self) -> bool { | 340 | pub fn is_none(&self) -> bool { |
| 341 | matches!(self, Self::None) | 341 | matches!(self, Self::None) |
| 342 | } | 342 | } |
| 343 | 343 | ||
| 344 | /// update colours every render | ||
| 344 | pub fn update_appearance( | 345 | pub fn update_appearance( |
| 345 | &mut self, | 346 | &mut self, |
| 346 | appearance: &AppearanceConfig, | 347 | appearance: &AppearanceConfig, |
| @@ -372,6 +373,7 @@ impl SingleItemType { | |||
| 372 | } | 373 | } |
| 373 | 374 | ||
| 374 | impl SingleItem { | 375 | impl SingleItem { |
| 376 | /// update colours and layout every render | ||
| 375 | fn update_appearance( | 377 | fn update_appearance( |
| 376 | &mut self, | 378 | &mut self, |
| 377 | appearance: &AppearanceConfig, | 379 | appearance: &AppearanceConfig, |
| @@ -394,6 +396,7 @@ impl SingleItem { | |||
| 394 | .update_appearance(appearance, iteminfo, &mut self.grid); | 396 | .update_appearance(appearance, iteminfo, &mut self.grid); |
| 395 | } | 397 | } |
| 396 | 398 | ||
| 399 | /// update hover item preview | ||
| 397 | fn update(&mut self) { | 400 | fn update(&mut self) { |
| 398 | if let SingleItemType::Playlist(singleplaylistitem) = &mut self.r#type { | 401 | if let SingleItemType::Playlist(singleplaylistitem) = &mut self.r#type { |
| 399 | let SinglePlaylistItem { | 402 | let SinglePlaylistItem { |
| @@ -418,6 +421,7 @@ impl SingleItem { | |||
| 418 | } | 421 | } |
| 419 | } | 422 | } |
| 420 | 423 | ||
| 424 | /// handle enter presses | ||
| 421 | fn select_at_cursor( | 425 | fn select_at_cursor( |
| 422 | &mut self, | 426 | &mut self, |
| 423 | framework: &mut FrameworkClean, | 427 | framework: &mut FrameworkClean, |
| @@ -440,31 +444,14 @@ impl SingleItem { | |||
| 440 | ); | 444 | ); |
| 441 | } | 445 | } |
| 442 | _ => { | 446 | _ => { |
| 443 | // joins the env from the one in mainconfig and video info | ||
| 444 | let command_string = apply_envs(command_string); | ||
| 445 | |||
| 446 | // check if the command starts with an ':' which case should be captured | 447 | // check if the command starts with an ':' which case should be captured |
| 447 | if &command_string[0..1] == ":" { | 448 | framework |
| 448 | framework | 449 | .data |
| 449 | .data | 450 | .state |
| 450 | .state | 451 | .get_mut::<Tasks>() |
| 451 | .get_mut::<Tasks>() | 452 | .unwrap() |
| 452 | .unwrap() | 453 | .priority |
| 453 | .priority | 454 | .push(Task::Command(apply_envs(command_string))); |
| 454 | .push(Task::Command(command_string[1..].to_string())) | ||
| 455 | } | ||
| 456 | |||
| 457 | // this allows creating commands from string | ||
| 458 | let mut command = execute::command(command_string); | ||
| 459 | |||
| 460 | *framework.data.global.get_mut::<Message>().unwrap() = Message::Success( | ||
| 461 | format!("{:?} {:?}", command.get_program(), command.get_args()), | ||
| 462 | ); | ||
| 463 | |||
| 464 | // run the command in a new thread so it doesn't freeze the current one | ||
| 465 | thread::spawn(move || { | ||
| 466 | let _ = command.output(); | ||
| 467 | }); | ||
| 468 | } | 455 | } |
| 469 | } | 456 | } |
| 470 | } | 457 | } |
| @@ -491,27 +478,14 @@ impl SingleItem { | |||
| 491 | } | 478 | } |
| 492 | // same as before if string is not a special case then the run the command | 479 | // same as before if string is not a special case then the run the command |
| 493 | _ => { | 480 | _ => { |
| 494 | let command_string = apply_envs(command_string); | ||
| 495 | |||
| 496 | // check if the command starts with an ':' which case should be captured | 481 | // check if the command starts with an ':' which case should be captured |
| 497 | if &command_string[0..1] == ":" { | 482 | framework |
| 498 | framework | 483 | .data |
| 499 | .data | 484 | .state |
| 500 | .state | 485 | .get_mut::<Tasks>() |
| 501 | .get_mut::<Tasks>() | 486 | .unwrap() |
| 502 | .unwrap() | 487 | .priority |
| 503 | .priority | 488 | .push(Task::Command(apply_envs(command_string))); |
| 504 | .push(Task::Command(command_string[1..].to_string())) | ||
| 505 | } | ||
| 506 | |||
| 507 | *framework.data.global.get_mut::<Message>().unwrap() = | ||
| 508 | Message::Success(command_string.clone()); | ||
| 509 | |||
| 510 | let mut command = execute::command(command_string); | ||
| 511 | |||
| 512 | thread::spawn(move || { | ||
| 513 | let _ = command.output(); | ||
| 514 | }); | ||
| 515 | } | 489 | } |
| 516 | }; | 490 | }; |
| 517 | } | 491 | } |
| @@ -762,7 +736,8 @@ impl FrameworkItem for SingleItem { | |||
| 762 | [singleplaylistitem.videos_view.selected - 1] | 736 | [singleplaylistitem.videos_view.selected - 1] |
| 763 | .clone(), | 737 | .clone(), |
| 764 | ); | 738 | ); |
| 765 | } updated | 739 | } |
| 740 | updated | ||
| 766 | } | 741 | } |
| 767 | KeyAction::MoveDown => { | 742 | KeyAction::MoveDown => { |
| 768 | let updated = singleplaylistitem.videos_view.down().is_ok(); | 743 | let updated = singleplaylistitem.videos_view.down().is_ok(); |
| @@ -883,7 +858,13 @@ impl FrameworkItem for SingleItem { | |||
| 883 | } else { | 858 | } else { |
| 884 | let y = (y - chunk.y) as usize + singleplaylistitem.videos_view.scroll; | 859 | let y = (y - chunk.y) as usize + singleplaylistitem.videos_view.scroll; |
| 885 | if singleplaylistitem.videos_view.selected != 0 && y == 0 { | 860 | if singleplaylistitem.videos_view.selected != 0 && y == 0 { |
| 886 | framework.data.state.get_mut::<Tasks>().unwrap().priority.push(Task::ClearPage); | 861 | framework |
| 862 | .data | ||
| 863 | .state | ||
| 864 | .get_mut::<Tasks>() | ||
| 865 | .unwrap() | ||
| 866 | .priority | ||
| 867 | .push(Task::ClearPage); | ||
| 887 | } | 868 | } |
| 888 | &mut singleplaylistitem.videos_view | 869 | &mut singleplaylistitem.videos_view |
| 889 | } | 870 | } |