From 4a32bbb9af03cd85e620550f030b47a9fe8a933d Mon Sep 17 00:00:00 2001 From: shy Date: Sun, 11 Apr 2021 14:06:00 +0200 Subject: [PATCH] Make layout.error unnecessary. --- src/buffer.rs | 11 +++++--- src/consts.rs | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/layout.rs | 8 ------ 3 files changed, 82 insertions(+), 11 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index 8c3efd0..34d5d71 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -4,6 +4,8 @@ use termion::raw::RawTerminal; use crate::layout::Layout; use crate::utils; +const PROMPT: &str = "Add alarm: "; + pub struct Buffer { content: String, @@ -65,7 +67,9 @@ impl Buffer { write!(stdout, "{}{}{}{}{}{}", cursor::Hide, - cursor::Goto(layout.error.col, layout.error.line), + cursor::Goto( + layout.buffer.col + (PROMPT.len() as u16), + layout.buffer.line), clear::UntilNewline, color::Fg(color::LightRed), &msg, @@ -75,9 +79,10 @@ impl Buffer { if !self.content.is_empty() { write!(stdout, - "{}{}Add alarm: {}{}", + "{}{}{}{}{}", cursor::Goto(layout.buffer.col, layout.buffer.line), - clear::CurrentLine, + clear::UntilNewline, + PROMPT, cursor::Show, &self.content)?; layout.cursor.col = diff --git a/src/consts.rs b/src/consts.rs index 8ba75d4..e7c9021 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -117,6 +117,80 @@ pub mod digits { ] ]; + pub const _DIGITS_FANCY: [[&str; DIGIT_HEIGHT as usize]; 10] = [ + [ + // 0 + "█▀▀▀█", + "█ █", + "▀ ▀", + "🮐 🮐", + "🮐🮏🮏🮏🮐", + ], [ + // 1 + " ▀█ ", + " █ ", + " ▀ ", + " 🮐 ", + " 🮐 " + ], [ + // 2 + "▀▀▀▀█", + " █", + "▀▀▀▀▀", + "🮐 ", + "🮐🮏🮏🮏🮏" + ], [ + // 3 + "▀▀▀▀█", + " █", + " ▀▀▀▀", + " 🮐", + "🮏🮏🮏🮏🮐" + ], [ + // 4 + "█ ", + "█ █ ", + "▀▀▀▀▀", + " 🮐 ", + " 🮐 " + ], [ + // 5 + "█▀▀▀▀", + "█ ", + "▀▀▀▀▀", + " 🮐", + "🮏🮏🮏🮏🮐" + ], [ + // 6 + "█ ", + "█ ", + "▀▀▀▀▀", + "🮐 🮐", + "🮐🮏🮏🮏🮐" + ], [ + // 7 + "▀▀▀▀█", + " █", + " ▀ ", + " 🮐 ", + " 🮐 ", + ], [ + // 8 + "█▀▀▀█", + "█ █", + "▀▀▀▀▀", + "🮐 🮐", + "🮐🮏🮏🮏🮐" + ], [ + // 9 + "█▀▀▀█", + "█ █", + "▀▀▀▀▀", + " 🮐", + " 🮐" + ] + ]; + pub const DIGITS_PLAIN: [[&str; DIGIT_HEIGHT as usize]; 10] = [ [ // 0 diff --git a/src/layout.rs b/src/layout.rs index 13c52e7..b8d3ada 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -29,7 +29,6 @@ pub struct Layout { pub roster_width: u16, pub roster_height: u16, pub buffer: Position, - pub error: Position, pub cursor: Position, } @@ -52,7 +51,6 @@ impl Layout { roster_width: 0, roster_height: 0, buffer: Position {col: 0, line: 0}, - error: Position {col: 0, line: 0}, cursor: Position {col: 1, line: 1}, } } @@ -142,12 +140,6 @@ impl Layout { col: 1, }; - // Error messages. - self.error = Position { - line: self.height, - col: 12, - }; - // Cursor. Column will be set by main loop. self.cursor.line = self.buffer.line; }