Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Fixes hello example
Erik Kundt committed 1 year ago
commit 3a36a0391179f6067125b16b477d99e1a666293d
parent 432fff02489b1c3e728a73f00c27524c6b7b226c
1 file changed +18 -77
modified 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<Message> for App {
-
//     type Return = ();
-

-
//     fn update(&mut self, message: Message) -> Option<tui::Exit<()>> {
-
//         match message {
-
//             Message::Quit => Some(Exit { value: None }),
-
//         }
-
//     }
-
// }
-

-
// impl Show<Message> for App {
-
//     fn show(&self, ctx: &Context<Message>, 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<Message> for App {
impl Show<Message> for App {
    fn show(&self, ctx: &Context<Message>, 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<Message> 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?;