mirror of
https://github.com/Xithrius/twitch-tui.git
synced 2024-09-11 05:35:26 +03:00
Merge branch 'main' into chat-to-list
This commit is contained in:
commit
fa8bd6bd69
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- run: cargo login ${CRATES_IO_TOKEN}
|
- run: cargo login ${CRATES_IO_TOKEN}
|
||||||
env:
|
env:
|
||||||
|
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -120,9 +120,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.1.4"
|
version = "4.1.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76"
|
checksum = "ec0b0588d44d4d63a87dbd75c136c166bbfd9a86a31cb89e09906521c7d3f5e3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
@ -250,9 +250,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossterm"
|
name = "crossterm"
|
||||||
version = "0.26.0"
|
version = "0.26.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "77f67c7faacd4db07a939f55d66a983a5355358a1f17d32cc9a8d01d1266b9ce"
|
checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"crossterm_winapi",
|
"crossterm_winapi",
|
||||||
@ -1650,7 +1650,7 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
"crossterm 0.26.0",
|
"crossterm 0.26.1",
|
||||||
"dialoguer",
|
"dialoguer",
|
||||||
"fern",
|
"fern",
|
||||||
"futures",
|
"futures",
|
||||||
|
@ -13,10 +13,10 @@ keywords = ["tui", "twitch"]
|
|||||||
categories = ["command-line-utilities"]
|
categories = ["command-line-utilities"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
crossterm = "0.26.0"
|
crossterm = "0.26.1"
|
||||||
tui = { version = "0.19.0", default-features = false, features = [ "crossterm" ] }
|
tui = { version = "0.19.0", default-features = false, features = [ "crossterm" ] }
|
||||||
tokio = { version = "1.25.0", features = [ "rt", "macros", "rt-multi-thread" ] }
|
tokio = { version = "1.24.1", features = [ "rt", "macros", "rt-multi-thread" ] }
|
||||||
clap = { version = "4.1.4", features = [ "derive", "cargo" ] }
|
clap = { version = "4.1.6", features = [ "derive", "cargo" ] }
|
||||||
serde = { version = "1.0.152", features = [ "derive" ] }
|
serde = { version = "1.0.152", features = [ "derive" ] }
|
||||||
serde_json = "1.0.93"
|
serde_json = "1.0.93"
|
||||||
unicode-width = "0.1.10"
|
unicode-width = "0.1.10"
|
||||||
|
@ -39,22 +39,10 @@ pub fn reset_terminal() {
|
|||||||
pub fn init_terminal(frontend_config: &FrontendConfig) -> Terminal<CrosstermBackend<Stdout>> {
|
pub fn init_terminal(frontend_config: &FrontendConfig) -> Terminal<CrosstermBackend<Stdout>> {
|
||||||
enable_raw_mode().unwrap();
|
enable_raw_mode().unwrap();
|
||||||
|
|
||||||
let blink = |a: SetCursorStyle, b: SetCursorStyle| -> SetCursorStyle {
|
let cursor_style = match frontend_config.cursor_shape {
|
||||||
if frontend_config.blinking_cursor {
|
CursorType::Line => SetCursorStyle::BlinkingBar,
|
||||||
a
|
CursorType::Block => SetCursorStyle::BlinkingBlock,
|
||||||
} else {
|
CursorType::UnderScore => SetCursorStyle::BlinkingUnderScore,
|
||||||
b
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let cursor_type = match frontend_config.cursor_shape {
|
|
||||||
CursorType::User => SetCursorStyle::DefaultUserShape,
|
|
||||||
CursorType::Line => blink(SetCursorStyle::BlinkingBar, SetCursorStyle::SteadyBar),
|
|
||||||
CursorType::Block => blink(SetCursorStyle::BlinkingBlock, SetCursorStyle::SteadyBlock),
|
|
||||||
CursorType::UnderScore => blink(
|
|
||||||
SetCursorStyle::BlinkingUnderScore,
|
|
||||||
SetCursorStyle::SteadyUnderScore,
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut stdout = stdout();
|
let mut stdout = stdout();
|
||||||
@ -63,7 +51,7 @@ pub fn init_terminal(frontend_config: &FrontendConfig) -> Terminal<CrosstermBack
|
|||||||
stdout,
|
stdout,
|
||||||
EnterAlternateScreen,
|
EnterAlternateScreen,
|
||||||
EnableMouseCapture,
|
EnableMouseCapture,
|
||||||
cursor_type,
|
cursor_style,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
twitch::TwitchAction,
|
twitch::TwitchAction,
|
||||||
ui::draw_ui,
|
ui::{draw_ui, error::draw_error_ui},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn ui_driver(
|
pub async fn ui_driver(
|
||||||
@ -56,7 +56,22 @@ pub async fn ui_driver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
terminal
|
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();
|
.unwrap();
|
||||||
|
|
||||||
if matches!(
|
if matches!(
|
||||||
|
27
src/ui/error.rs
Normal file
27
src/ui/error.rs
Normal file
@ -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<T: Backend>(frame: &mut Frame<T>, 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::<Vec<Spans>>(),
|
||||||
|
)
|
||||||
|
.block(Block::default().borders(Borders::NONE))
|
||||||
|
.style(Style::default().fg(Color::White))
|
||||||
|
.alignment(Alignment::Center);
|
||||||
|
|
||||||
|
frame.render_widget(paragraph, v_chunks[0]);
|
||||||
|
}
|
@ -24,6 +24,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub mod components;
|
pub mod components;
|
||||||
|
pub mod error;
|
||||||
pub mod statics;
|
pub mod statics;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
Loading…
Reference in New Issue
Block a user