diff --git a/Cargo.lock b/Cargo.lock index bd2414dd..95cc714e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1100,6 +1100,7 @@ dependencies = [ "assert2", "bon", "bytes", + "chrono", "clap", "color-eyre", "derive-with", diff --git a/Cargo.toml b/Cargo.toml index 78ea927d..77940eff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ lazy_static = "1.5" color-eyre = "0.6" tui-scrollview = "0.4" regex = "1.10" +chrono = "0.4" # CLI parsing clap = { version = "4.5", features = ["cargo", "derive"] } diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 885ecdf7..e478c2b2 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -16,7 +16,7 @@ categories = { workspace = true } default = ["forgejo", "github", "tui"] forgejo = ["git-next-forge-forgejo"] github = ["git-next-forge-github"] -tui = ["ratatui", "directories", "lazy_static", "tui-scrollview", "regex"] +tui = ["ratatui", "directories", "lazy_static", "tui-scrollview", "regex", "chrono"] [dependencies] git-next-core = { workspace = true } @@ -30,6 +30,7 @@ lazy_static = { workspace = true, optional = true } color-eyre = { workspace = true } tui-scrollview = { workspace = true, optional = true } regex = { workspace = true, optional = true } +chrono = { workspace = true, optional = true } # CLI parsing clap = { workspace = true } diff --git a/crates/cli/src/tui/actor/model.rs b/crates/cli/src/tui/actor/model.rs index a62214c2..f779dd47 100644 --- a/crates/cli/src/tui/actor/model.rs +++ b/crates/cli/src/tui/actor/model.rs @@ -5,7 +5,10 @@ use ratatui::{ style::{Color, Style, Stylize as _}, symbols::border, text::{Line, Span}, - widgets::{block::Title, Block, Paragraph, StatefulWidget, Widget}, + widgets::{ + block::{Position, Title}, + Block, Paragraph, StatefulWidget, Widget, + }, }; use git_next_core::{ @@ -51,6 +54,10 @@ impl State { } } +fn time() -> String { + chrono::Local::now().format("%H:%M").to_string() +} + #[derive(Clone, Debug, PartialEq, Eq)] pub enum ServerState { /// UI has started but has no information on the state of the server @@ -356,7 +363,10 @@ impl StatefulWidget for &State { Self: Sized, { let block = Block::bordered() - .title(Title::from(" Git-Next ".bold()).alignment(Alignment::Center)) + .title( + Title::from(format!(" Git-Next v{} ", clap::crate_version!()).bold()) + .alignment(Alignment::Center), + ) .title( Title::from(Line::from(vec![ " [q]uit ".into(), @@ -364,7 +374,12 @@ impl StatefulWidget for &State { " ".into(), ])) .alignment(Alignment::Center) - .position(ratatui::widgets::block::Position::Bottom), + .position(Position::Bottom), + ) + .title( + Title::from(format!(" {} ", time())) + .alignment(Alignment::Right) + .position(Position::Bottom), ) .border_set(border::THICK); let interior = block.inner(area);