From 14a7cf8dac4ef29bd160aa02ac5a9dd33987dc76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Feb 2023 21:50:05 -0800 Subject: [PATCH 1/4] Bump clap from 4.1.1 to 4.1.6 (#302) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47d3f50..31aff96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.1" +version = "4.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec7a4128863c188deefe750ac1d1dfe66c236909f845af04beed823638dc1b2" +checksum = "ec0b0588d44d4d63a87dbd75c136c166bbfd9a86a31cb89e09906521c7d3f5e3" dependencies = [ "bitflags", "clap_derive", diff --git a/Cargo.toml b/Cargo.toml index ba64e87..cfa153d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ categories = ["command-line-utilities"] crossterm = "0.25.0" tui = { version = "0.19.0", default-features = false, features = [ "crossterm" ] } tokio = { version = "1.24.1", features = [ "rt", "macros", "rt-multi-thread" ] } -clap = { version = "4.0.32", features = [ "derive", "cargo" ] } +clap = { version = "4.1.6", features = [ "derive", "cargo" ] } serde = { version = "1.0.152", features = [ "derive" ] } serde_json = "1.0.91" unicode-width = "0.1.10" From c75bbbe5b05278bc720ded797ec97472d3fcc97c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Feb 2023 00:58:12 -0800 Subject: [PATCH 2/4] Bump actions/checkout from 2 to 3 (#305) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0c67d9d..b82df01 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - run: cargo login ${CRATES_IO_TOKEN} env: From cbe470d91465bad58da065dd379c52aadc9ec4c5 Mon Sep 17 00:00:00 2001 From: Xithrius Date: Mon, 6 Mar 2023 21:02:08 -0800 Subject: [PATCH 3/4] Bumped crossterm to 0.26, which changed cursor enums --- Cargo.lock | 20 ++++++++++++++++++-- Cargo.toml | 2 +- src/commands.rs | 12 ++++++------ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 31aff96..41126c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -248,6 +248,22 @@ dependencies = [ "winapi", ] +[[package]] +name = "crossterm" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" +dependencies = [ + "bitflags", + "crossterm_winapi", + "libc", + "mio", + "parking_lot 0.12.1", + "signal-hook", + "signal-hook-mio", + "winapi", +] + [[package]] name = "crossterm_winapi" version = "0.9.0" @@ -1628,7 +1644,7 @@ checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1" dependencies = [ "bitflags", "cassowary", - "crossterm", + "crossterm 0.25.0", "unicode-segmentation", "unicode-width", ] @@ -1640,7 +1656,7 @@ dependencies = [ "chrono", "clap", "color-eyre", - "crossterm", + "crossterm 0.26.1", "dialoguer", "fern", "futures", diff --git a/Cargo.toml b/Cargo.toml index cfa153d..27421ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["tui", "twitch"] categories = ["command-line-utilities"] [dependencies] -crossterm = "0.25.0" +crossterm = "0.26.1" tui = { version = "0.19.0", default-features = false, features = [ "crossterm" ] } tokio = { version = "1.24.1", features = [ "rt", "macros", "rt-multi-thread" ] } clap = { version = "4.1.6", features = [ "derive", "cargo" ] } diff --git a/src/commands.rs b/src/commands.rs index 9a48f5c..dc7aa2f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -4,7 +4,7 @@ use std::{ }; use crossterm::{ - cursor::{CursorShape, DisableBlinking, EnableBlinking, SetCursorShape}, + cursor::{DisableBlinking, EnableBlinking, SetCursorStyle}, event::{DisableMouseCapture, EnableMouseCapture}, execute, queue, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, @@ -39,10 +39,10 @@ pub fn reset_terminal() { pub fn init_terminal(frontend_config: &FrontendConfig) -> Terminal> { enable_raw_mode().unwrap(); - let cursor_type = match frontend_config.cursor_shape { - CursorType::Line => CursorShape::Line, - CursorType::UnderScore => CursorShape::UnderScore, - CursorType::Block => CursorShape::Block, + let cursor_style = match frontend_config.cursor_shape { + CursorType::Line => SetCursorStyle::BlinkingBar, + CursorType::Block => SetCursorStyle::BlinkingBlock, + CursorType::UnderScore => SetCursorStyle::BlinkingUnderScore, }; let mut stdout = stdout(); @@ -50,7 +50,7 @@ pub fn init_terminal(frontend_config: &FrontendConfig) -> Terminal Date: Mon, 6 Mar 2023 21:52:46 -0800 Subject: [PATCH 4/4] Error UI occurs on small enough window --- src/terminal.rs | 19 +++++++++++++++++-- src/ui/error.rs | 27 +++++++++++++++++++++++++++ src/ui/mod.rs | 1 + 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/ui/error.rs diff --git a/src/terminal.rs b/src/terminal.rs index 4d0c973..5df743a 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -15,7 +15,7 @@ use crate::{ }, }, twitch::TwitchAction, - ui::draw_ui, + ui::{draw_ui, error::draw_error_ui}, }; pub async fn ui_driver( @@ -56,7 +56,22 @@ pub async fn ui_driver( } terminal - .draw(|frame| draw_ui(frame, &mut app, &config)) + .draw(|frame| { + let size = frame.size(); + + if size.height < 10 || size.width < 60 { + draw_error_ui( + frame, + &[ + "Window to small!", + "Must allow for at least 60x10.", + "Restart and resize.", + ], + ); + } else { + draw_ui(frame, &mut app, &config); + } + }) .unwrap(); if matches!( diff --git a/src/ui/error.rs b/src/ui/error.rs new file mode 100644 index 0000000..6833a9f --- /dev/null +++ b/src/ui/error.rs @@ -0,0 +1,27 @@ +use tui::{ + backend::Backend, + layout::{Alignment, Constraint, Direction, Layout}, + style::{Color, Style}, + terminal::Frame, + text::{Span, Spans}, + widgets::{Block, Borders, Paragraph}, +}; + +pub fn draw_error_ui(frame: &mut Frame, messages: &[&str]) { + let v_chunks = Layout::default() + .direction(Direction::Vertical) + .constraints([Constraint::Min(1)]) + .split(frame.size()); + + let paragraph = Paragraph::new( + messages + .iter() + .map(|&s| Spans::from(vec![Span::raw(s)])) + .collect::>(), + ) + .block(Block::default().borders(Borders::NONE)) + .style(Style::default().fg(Color::White)) + .alignment(Alignment::Center); + + frame.render_widget(paragraph, v_chunks[0]); +} diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 823d6ab..d5adb74 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -24,6 +24,7 @@ use crate::{ }; pub mod components; +pub mod error; pub mod statics; #[derive(Debug, Clone)]