mirror of
https://github.com/Xithrius/twitch-tui.git
synced 2024-10-04 09:07:33 +03:00
Appeased clippy, added startup time to debug widget
This commit is contained in:
parent
08f132318a
commit
e37397d901
@ -1,5 +1,6 @@
|
||||
use std::{cell::RefCell, collections::VecDeque, rc::Rc};
|
||||
|
||||
use chrono::{DateTime, Local};
|
||||
use rustyline::line_buffer::LineBuffer;
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
@ -59,7 +60,11 @@ macro_rules! shared {
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub fn new(config: CompleteConfig, following: FollowingList) -> Self {
|
||||
pub fn new(
|
||||
config: CompleteConfig,
|
||||
following: FollowingList,
|
||||
startup_time: DateTime<Local>,
|
||||
) -> Self {
|
||||
let shared_config = shared!(config.clone());
|
||||
|
||||
let shared_config_borrow = shared_config.borrow();
|
||||
@ -85,6 +90,7 @@ impl App {
|
||||
filters.clone(),
|
||||
messages.clone(),
|
||||
following,
|
||||
startup_time,
|
||||
);
|
||||
|
||||
Self {
|
||||
|
@ -364,28 +364,64 @@ impl ToVec<(String, String)> for FiltersConfig {
|
||||
impl ToVec<(String, String)> for FrontendConfig {
|
||||
fn to_vec(&self) -> Vec<(String, String)> {
|
||||
vec![
|
||||
("Show datetimes".to_string(), self.show_datetimes.to_string()),
|
||||
("Datetime format".to_string(), self.datetime_format.to_string()),
|
||||
("Username shown".to_string(), self.username_shown.to_string()),
|
||||
(
|
||||
"Show datetimes".to_string(),
|
||||
self.show_datetimes.to_string(),
|
||||
),
|
||||
(
|
||||
"Datetime format".to_string(),
|
||||
self.datetime_format.to_string(),
|
||||
),
|
||||
(
|
||||
"Username shown".to_string(),
|
||||
self.username_shown.to_string(),
|
||||
),
|
||||
// ("".to_string(), self.palette.to_string()),
|
||||
("Title shown".to_string(), self.title_shown.to_string()),
|
||||
("Margin".to_string(), self.margin.to_string()),
|
||||
("Badges".to_string(), self.badges.to_string()),
|
||||
// ("".to_string(), self.theme.to_string()),
|
||||
("Username highlight".to_string(), self.username_highlight.to_string()),
|
||||
(
|
||||
"Username highlight".to_string(),
|
||||
self.username_highlight.to_string(),
|
||||
),
|
||||
("State tabs".to_string(), self.state_tabs.to_string()),
|
||||
// ("".to_string(), self.cursor_shape.to_string()),
|
||||
("Blinking cursor".to_string(), self.blinking_cursor.to_string()),
|
||||
("Inverted scrolling".to_string(), self.inverted_scrolling.to_string()),
|
||||
("Scroll offset shown".to_string(), self.show_scroll_offset.to_string()),
|
||||
(
|
||||
"Blinking cursor".to_string(),
|
||||
self.blinking_cursor.to_string(),
|
||||
),
|
||||
(
|
||||
"Inverted scrolling".to_string(),
|
||||
self.inverted_scrolling.to_string(),
|
||||
),
|
||||
(
|
||||
"Scroll offset shown".to_string(),
|
||||
self.show_scroll_offset.to_string(),
|
||||
),
|
||||
("Twitch emotes".to_string(), self.twitch_emotes.to_string()),
|
||||
("BetterTTV emotes".to_string(), self.betterttv_emotes.to_string()),
|
||||
("SevenTV emotes".to_string(), self.seventv_emotes.to_string()),
|
||||
("FrankerFacez emotes".to_string(), self.frankerfacez_emotes.to_string()),
|
||||
(
|
||||
"BetterTTV emotes".to_string(),
|
||||
self.betterttv_emotes.to_string(),
|
||||
),
|
||||
(
|
||||
"SevenTV emotes".to_string(),
|
||||
self.seventv_emotes.to_string(),
|
||||
),
|
||||
(
|
||||
"FrankerFacez emotes".to_string(),
|
||||
self.frankerfacez_emotes.to_string(),
|
||||
),
|
||||
// ("".to_string(), self.favorite_channels.to_string()),
|
||||
("Recent channel count".to_string(), self.recent_channel_count.to_string()),
|
||||
(
|
||||
"Recent channel count".to_string(),
|
||||
self.recent_channel_count.to_string(),
|
||||
),
|
||||
// ("".to_string(), self.border_type.to_string()),
|
||||
("Right aligned usernames".to_string(), self.right_align_usernames.to_string()),
|
||||
(
|
||||
"Right aligned usernames".to_string(),
|
||||
self.right_align_usernames.to_string(),
|
||||
),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,8 @@ fn initialize_logging(config: &CompleteConfig) {
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let startup_time = chrono::Local::now();
|
||||
|
||||
color_eyre::install().unwrap();
|
||||
|
||||
let config = CompleteConfig::new(Cli::parse())
|
||||
@ -74,7 +76,7 @@ async fn main() -> Result<()> {
|
||||
|
||||
let following = get_following(&config.twitch.clone()).await;
|
||||
|
||||
let mut app = App::new(config.clone(), following);
|
||||
let mut app = App::new(config.clone(), following, startup_time);
|
||||
|
||||
info!("Started tokio communication channels.");
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
use chrono::{DateTime, Local};
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
layout::{Constraint, Rect},
|
||||
prelude::Alignment,
|
||||
style::{Color, Modifier, Style},
|
||||
widgets::{Block, Borders, Clear, Row, Table},
|
||||
widgets::{block::Position, Block, Borders, Clear, Row, Table},
|
||||
Frame,
|
||||
};
|
||||
|
||||
@ -21,13 +23,15 @@ use crate::{
|
||||
pub struct DebugWidget {
|
||||
config: SharedCompleteConfig,
|
||||
focused: bool,
|
||||
startup_time: DateTime<Local>,
|
||||
}
|
||||
|
||||
impl DebugWidget {
|
||||
pub fn new(config: SharedCompleteConfig) -> Self {
|
||||
pub fn new(config: SharedCompleteConfig, startup_time: DateTime<Local>) -> Self {
|
||||
Self {
|
||||
config,
|
||||
focused: false,
|
||||
startup_time,
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,10 +96,31 @@ impl Component for DebugWidget {
|
||||
.border_type(self.config.borrow().frontend.border_type.clone().into()),
|
||||
)
|
||||
// TODO: Automatically calculate the constraints
|
||||
.widths(&[Constraint::Length(20), Constraint::Length(20)]);
|
||||
.widths(&[Constraint::Length(25), Constraint::Length(25)]);
|
||||
|
||||
f.render_widget(Clear, area);
|
||||
f.render_widget(table, area);
|
||||
|
||||
let title_binding = self
|
||||
.startup_time
|
||||
.format(&self.config.borrow().frontend.datetime_format)
|
||||
.to_string();
|
||||
|
||||
let title = [TitleStyle::Combined("Startup time", &title_binding)];
|
||||
|
||||
let bottom_block = Block::default()
|
||||
.borders(Borders::BOTTOM | Borders::LEFT | Borders::RIGHT)
|
||||
.border_type(self.config.borrow().frontend.border_type.clone().into())
|
||||
.title(title_line(
|
||||
&title,
|
||||
Style::default().add_modifier(Modifier::BOLD).fg(Color::Red),
|
||||
))
|
||||
.title_position(Position::Bottom)
|
||||
.title_alignment(Alignment::Left);
|
||||
|
||||
let rect = Rect::new(area.x, area.bottom() - 1, area.width, 1);
|
||||
|
||||
f.render_widget(bottom_block, rect);
|
||||
}
|
||||
|
||||
fn event(&mut self, event: &Event) -> Option<TerminalAction> {
|
||||
|
@ -14,6 +14,7 @@ pub mod utils;
|
||||
pub use channel_switcher::ChannelSwitcherWidget;
|
||||
pub use chat::ChatWidget;
|
||||
pub use chat_input::ChatInputWidget;
|
||||
use chrono::{DateTime, Local};
|
||||
pub use dashboard::DashboardWidget;
|
||||
pub use debug::DebugWidget;
|
||||
pub use error::ErrorWidget;
|
||||
@ -75,10 +76,11 @@ impl Components {
|
||||
filters: SharedFilters,
|
||||
messages: SharedMessages,
|
||||
following: FollowingList,
|
||||
startup_time: DateTime<Local>,
|
||||
) -> Self {
|
||||
Self {
|
||||
tabs: StateTabsWidget::new(config.clone()),
|
||||
debug: DebugWidget::new(config.clone()),
|
||||
debug: DebugWidget::new(config.clone(), startup_time),
|
||||
|
||||
chat: ChatWidget::new(
|
||||
config.clone(),
|
||||
|
Loading…
Reference in New Issue
Block a user