diff options
author | Joris | 2022-02-12 16:57:19 +0100 |
---|---|---|
committer | Joris | 2022-02-12 16:57:19 +0100 |
commit | 3adf3f9697c4e2beb10e652947046d5fddda2ed4 (patch) | |
tree | 689e704cf4665cc4cd1949c06d4a7b0553d07501 /src/gui/util.rs | |
parent | a2ba205df12332a360d89991fe508f964d88c73f (diff) |
Say when the next card will be available
Diffstat (limited to 'src/gui/util.rs')
-rw-r--r-- | src/gui/util.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gui/util.rs b/src/gui/util.rs new file mode 100644 index 0000000..38ed1e7 --- /dev/null +++ b/src/gui/util.rs @@ -0,0 +1,21 @@ +use tui::{ + layout::{Alignment, Rect}, + style::{Color, Modifier, Style}, + widgets::Paragraph, +}; + +pub fn title(str: &str) -> Paragraph { + Paragraph::new(str).alignment(Alignment::Center).style( + Style::default() + .fg(Color::Blue) + .add_modifier(Modifier::BOLD), + ) +} + +pub fn center_vertically(chunk: Rect, text: &String) -> String { + let text_lines = text.lines().count(); + let chunk_inner_lines: usize = (chunk.height - 2).into(); + let blank_lines = chunk_inner_lines - text_lines; + let newlines = "\n".repeat(blank_lines / 2); + format!("{}{}", newlines, text) +} |