feat(tui): expand App state with file loading and scroll
This commit is contained in:
@@ -11,7 +11,7 @@ struct Cli {
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let _cli = Cli::parse();
|
||||
let cli = Cli::parse();
|
||||
|
||||
crossterm::terminal::enable_raw_mode()?;
|
||||
let mut stdout = std::io::stdout();
|
||||
@@ -21,12 +21,21 @@ fn main() -> anyhow::Result<()> {
|
||||
|
||||
let mut app = app::App::new();
|
||||
|
||||
if let Some(file) = cli.files.first()
|
||||
&& let Err(e) = app.load_file(file)
|
||||
{
|
||||
eprintln!("Error loading file: {e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
while !app.should_quit {
|
||||
terminal.draw(|frame| ui::render(frame, &app))?;
|
||||
if crossterm::event::poll(std::time::Duration::from_millis(100))?
|
||||
&& let crossterm::event::Event::Key(key) = crossterm::event::read()?
|
||||
{
|
||||
app.handle_key(key);
|
||||
if crossterm::event::poll(std::time::Duration::from_millis(100))? {
|
||||
match crossterm::event::read()? {
|
||||
crossterm::event::Event::Key(key) => app.handle_key(key),
|
||||
crossterm::event::Event::Resize(_w, _h) => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user