feat: display date
This commit is contained in:
2
config
2
config
@@ -14,7 +14,7 @@ fps=30
|
||||
|
||||
# Which color mode to use
|
||||
# Value: "term", "hex" or "ansi"
|
||||
color_mode=ansi
|
||||
color_mode=term
|
||||
|
||||
# Loaded if color_mode is set to "term"
|
||||
# Value: 0-15
|
||||
|
||||
17
src/main.rs
17
src/main.rs
@@ -10,7 +10,7 @@ use crossterm::{
|
||||
cursor,
|
||||
event::{self, Event, KeyCode, KeyModifiers},
|
||||
execute, queue,
|
||||
style::{self, Color},
|
||||
style::{self, Attribute, Color},
|
||||
terminal::{self, ClearType},
|
||||
};
|
||||
|
||||
@@ -102,6 +102,21 @@ fn render_frame(config: &Config) -> io::Result<()> {
|
||||
}
|
||||
draw_symbol(minute.chars().last().unwrap(), x - 2 + 4 * 7, y, color)?;
|
||||
|
||||
// Display date
|
||||
let date = time.date_naive().format("%Y-%m-%d").to_string();
|
||||
let mut stdout = io::stdout();
|
||||
|
||||
let x = width / 2 - (date.len() as u16) / 2;
|
||||
let y = height / 2 + text_height / 2 + 2;
|
||||
|
||||
queue!(
|
||||
stdout,
|
||||
cursor::MoveTo(x, y),
|
||||
style::SetForegroundColor(color),
|
||||
style::SetAttribute(Attribute::Bold)
|
||||
)?;
|
||||
write!(stdout, "{}", date)?;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user