diff --git a/examples/hello.rs b/examples/hello.rs index 368813a..2dbb437 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -1,77 +1,3 @@ -// use anyhow::Result; - -// use termion::event::Key; - -// use ratatui::{Frame, Viewport}; - -// use radicle_tui as tui; - -// use tui::store; -// use tui::ui::im::widget::Window; -// use tui::ui::im::Show; -// use tui::ui::im::{Borders, Context}; -// use tui::{Channel, Exit}; - -// const ALIEN: &str = r#" -// /// /// ,---------------------------------. -// /// /// | Hey there, press (q) to quit... | -// // // '---------------------------------' -// //,,,///,,,// .. -// /////////////////// . -// //////@@@@@//////@@@@@/// -// //////@@###//////@@###/// -// ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -// ,,, /// /// ,,, -// ,,, /// /// ,,, -// /// /// -// ///// ///// -// "#; - -// #[derive(Clone, Debug)] -// struct App { -// alien: String, -// } - -// #[derive(Clone, Debug)] -// enum Message { -// Quit, -// } - -// impl store::Update for App { -// type Return = (); - -// fn update(&mut self, message: Message) -> Option> { -// match message { -// Message::Quit => Some(Exit { value: None }), -// } -// } -// } - -// impl Show for App { -// fn show(&self, ctx: &Context, frame: &mut Frame) -> Result<()> { -// Window::default().show(ctx, |ui| { -// ui.text_view(frame, self.alien.clone(), &mut (0, 0), Some(Borders::None)); - -// if ui.input_global(|key| key == Key::Char('q')) { -// ui.send_message(Message::Quit); -// } -// }); - -// Ok(()) -// } -// } - -// #[tokio::main] -// pub async fn main() -> Result<()> { -// let app = App { -// alien: ALIEN.to_string(), -// }; - -// tui::im(app, Viewport::default(), Channel::default()).await?; - -// Ok(()) -// } - use anyhow::Result; use termion::event::Key; @@ -86,9 +12,24 @@ use tui::ui::im::Show; use tui::ui::im::{Borders, Context}; use tui::{Channel, Exit}; +const ALIEN: &str = r#" + /// /// ,---------------------------------. + /// /// | Hey there, press (q) to quit... | + // // '---------------------------------' + //,,,///,,,// .. + /////////////////// . + //////@@@@@//////@@@@@/// + //////@@###//////@@###/// +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + ,,, /// /// ,,, + ,,, /// /// ,,, + /// /// + ///// ///// +"#; + #[derive(Clone, Debug)] struct App { - hello: String, + alien: String, } #[derive(Clone, Debug)] @@ -109,7 +50,7 @@ impl store::Update for App { impl Show for App { fn show(&self, ctx: &Context, frame: &mut Frame) -> Result<()> { Window::default().show(ctx, |ui| { - ui.text_view(frame, self.hello.clone(), &mut (0, 0), Some(Borders::None)); + ui.text_view(frame, self.alien.clone(), &mut (0, 0), Some(Borders::None)); if ui.input_global(|key| key == Key::Char('q')) { ui.send_message(Message::Quit); @@ -123,7 +64,7 @@ impl Show for App { #[tokio::main] pub async fn main() -> Result<()> { let app = App { - hello: "Hello World!".to_string(), + alien: ALIEN.to_string(), }; tui::im(app, Viewport::default(), Channel::default()).await?;