use lv_tui::prelude::*;
use lv_tui::widgets::*;
const DIFF: &str = "\
--- old.txt
+++ new.txt
@@ -1,6 +1,7 @@
fn main() {
- let x = 1;
+ let x = 2;
println!(\"hello\");
+ println!(\"world\");
- // old comment
+ // new comment
}
@@ -10,3 +11,3 @@
fn other() {
- let y = 10;
+ let y = 20;
}
";
struct App { view: DiffView }
impl App {
fn new() -> Self { Self { view: DiffView::new(DIFF) } }
}
impl Component for App {
fn render(&self, cx: &mut RenderCx) { self.view.render(cx); }
fn event(&mut self, e: &Event, cx: &mut EventCx) {
if e.is_key(Key::Char('q')) { cx.quit(); return; }
self.view.event(e, cx);
}
fn layout(&mut self, r: lv_tui::geom::Rect, cx: &mut lv_tui::component::LayoutCx) { self.view.layout(r, cx); }
fn measure(&self, c: lv_tui::layout::Constraint, _cx: &mut lv_tui::component::MeasureCx) -> lv_tui::geom::Size {
lv_tui::geom::Size { width: c.max.width, height: c.max.height }
}
fn focusable(&self) -> bool { false }
}
fn main() -> lv_tui::Result<()> {
lv_tui::app::App::new(App::new()).run()
}