hello world!
This commit is contained in:
parent
a423dd9cdd
commit
a8d6a09f72
@ -4,3 +4,11 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
crossterm = "0.28.1"
|
||||
ratatui = "0.29.0"
|
||||
color-eyre = "0.6.3"
|
||||
#tokio = { version = "1", features = ["full"] }
|
||||
|
||||
[[bin]]
|
||||
name = "breadm"
|
||||
path = "src/main.rs"
|
||||
|
34
src/main.rs
34
src/main.rs
@ -1,3 +1,33 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use color_eyre::Result;
|
||||
use crossterm::event::{self, Event};
|
||||
use ratatui::{DefaultTerminal, Frame};
|
||||
|
||||
fn render(frame: &mut Frame) {
|
||||
// Render the "hello world" widget to the terminal using the available area
|
||||
frame.render_widget("hello world", frame.area());
|
||||
}
|
||||
|
||||
fn run(mut terminal: DefaultTerminal) -> Result<()> {
|
||||
// The main loop
|
||||
loop {
|
||||
// Draw the TUI by passing the render function to the terminal's draw method
|
||||
terminal.draw(render)?;
|
||||
|
||||
// Listen for keypress events
|
||||
if matches!(event::read()?, Event::Key(_)) {
|
||||
// Break the loop on key-press and return Ok(())
|
||||
break Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
color_eyre::install()?; // Colorful error messages
|
||||
|
||||
let terminal = ratatui::init(); // Initialize the terminal to render the TUI
|
||||
let result = run(terminal); // The TUI app's main logic. The run() function above.
|
||||
|
||||
ratatui::restore(); // Clear the terminal and return to the previous state
|
||||
|
||||
result // Result of main()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user