generated from PlexSheep/rs-base
show mode of timebar with extra info #18
|
@ -11,7 +11,7 @@ use ratatui::backend::CrosstermBackend;
|
||||||
use ratatui::crossterm::event::{self, poll, Event, KeyCode, KeyModifiers};
|
use ratatui::crossterm::event::{self, poll, Event, KeyCode, KeyModifiers};
|
||||||
use ratatui::layout::{Alignment, Constraint, Direction, Layout, Rect};
|
use ratatui::layout::{Alignment, Constraint, Direction, Layout, Rect};
|
||||||
use ratatui::style::{Style, Stylize};
|
use ratatui::style::{Style, Stylize};
|
||||||
use ratatui::widgets::{Block, LineGauge, Padding, Paragraph};
|
use ratatui::widgets::{Block, Padding, Paragraph};
|
||||||
use ratatui::Terminal;
|
use ratatui::Terminal;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::{Cursor, Stdout, Write};
|
use std::io::{Cursor, Stdout, Write};
|
||||||
|
@ -111,7 +111,7 @@ impl Clock {
|
||||||
}
|
}
|
||||||
TimeBarLength::Custom(_) => {
|
TimeBarLength::Custom(_) => {
|
||||||
if since_last_reset.num_seconds() >= 1
|
if since_last_reset.num_seconds() >= 1
|
||||||
&& i64::from(since_last_reset.num_seconds()) >= len.as_secs()
|
&& since_last_reset.num_seconds() >= len.as_secs()
|
||||||
{
|
{
|
||||||
self.last_reset = Some(Local::now());
|
self.last_reset = Some(Local::now());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
use chrono::{Duration, TimeDelta};
|
use chrono::Duration;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum TimeBarLength {
|
pub enum TimeBarLength {
|
||||||
|
|
|
@ -150,7 +150,7 @@ pub fn timebarw_label<'a>(
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
Paragraph::new(format!("{} / {}", time_now, len))
|
Paragraph::new(format!("{time_now} / {len}"))
|
||||||
.alignment(Alignment::Center)
|
.alignment(Alignment::Center)
|
||||||
.block(
|
.block(
|
||||||
Block::default().padding(Padding::right(if inner_rect.width > 80 {
|
Block::default().padding(Padding::right(if inner_rect.width > 80 {
|
||||||
|
|
Reference in New Issue