hello world!

This commit is contained in:
Candifloss 2025-01-12 03:23:00 +05:30
parent a423dd9cdd
commit a8d6a09f72
2 changed files with 40 additions and 2 deletions

View File

@ -4,3 +4,11 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [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"

View File

@ -1,3 +1,33 @@
fn main() { use color_eyre::Result;
println!("Hello, world!"); 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()
} }