Make layout.error unnecessary.

This commit is contained in:
shy 2021-04-11 14:06:00 +02:00
parent ade2c9f4da
commit 4a32bbb9af
3 changed files with 82 additions and 11 deletions

View file

@ -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 =

View file

@ -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

View file

@ -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;
}