-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
172 additions
and
99 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod tui; | ||
pub mod listbox; | ||
pub mod tui_structs; | ||
pub mod tui_structs; | ||
pub mod statebar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use std::fmt::Display; | ||
|
||
use console_engine::{Color, crossterm::terminal::size, pixel, pixel::Pixel, screen::Screen}; | ||
|
||
const BASE_HEADER: &str = "▶ BandcampOnlinePlayer RS | "; | ||
|
||
#[derive(Clone)] | ||
pub struct StateBar { | ||
header_text: String, | ||
bottom_text: String, | ||
error: bool, | ||
screen: Screen, | ||
pub y: u32, | ||
} | ||
|
||
impl StateBar { | ||
pub fn new() -> Self { | ||
let (cols, rows) = size().expect("Unable to get terminal size continue work is not available!"); | ||
|
||
Self { | ||
header_text: BASE_HEADER.to_string(), | ||
bottom_text: String::from("Loading..."), | ||
error: false, | ||
screen: Screen::new(cols.into(), 2), | ||
y: (rows as u32) - 2, | ||
} | ||
} | ||
|
||
pub fn error<T: Display>(&mut self, item: &T) { | ||
self.error = true; | ||
self.header_text = item.to_string(); | ||
} | ||
|
||
pub fn information<T: Display>(&mut self, item: &T) { | ||
self.error = false; | ||
self.header_text = item.to_string(); | ||
} | ||
|
||
pub fn draw(&mut self) -> &Screen { | ||
self.screen.fill(pixel::pxl_bg(' ', Color::Blue)); | ||
self.screen.print_fbg(0, 0, self.header_text.as_str(), Color::White, Color::Blue); | ||
self.screen.print_fbg(0, 1, self.bottom_text.as_str(), Color::White, Color::Blue); | ||
&self.screen | ||
} | ||
|
||
pub fn resize(&mut self, w: u16, h: u16) { | ||
self.screen.clear(); | ||
self.screen.resize(w as u32, 2); | ||
self.y = (h as u32) - 2; | ||
} | ||
} |
Oops, something went wrong.