Initial cockpit commit
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
537774f120
commit
21d93f7073
17 changed files with 177 additions and 22 deletions
50
thecockpit/src/app.rs
Normal file
50
thecockpit/src/app.rs
Normal file
|
@ -0,0 +1,50 @@
|
|||
#[cfg(target_arch = "wasm32")]
|
||||
use ratzilla::ratatui;
|
||||
|
||||
use ratatui::{
|
||||
style::{Color, Stylize},
|
||||
widgets::{Block, Borders, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct App {}
|
||||
|
||||
const SPLASH: &str = r#"
|
||||
!~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
!~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
!!~~~~~~!J5PPPPPPPPPPP?^^^^7PPPPPPPPPPPPPPPPY~^^^^
|
||||
!!!!!!~~~!JB&@@@@@@@@@5^^^^Y@@@@@@@@@@@@@@@@#~^^^^
|
||||
!!!!!5?!~~~!JG&@@@@@@@5^^^^Y@@@@@@@@@@@@@@@@#~^^^^
|
||||
!!!!7#&GJ!~~~!?G&@@@@@5^^^^Y@@@@@@@@@@@@@@@@#~^^^^
|
||||
7!!!7#@@&BJ!~~~!?G&@@@5^^^^Y@@@@@@@@@@@@@@@@#~^^^^
|
||||
7!!!7#@@@@@BY!~~~~?P&@5~^^^Y@@@@@@@@@@@@@@@@#~^^^^
|
||||
777!7#@@@@@@@BY!~~~~7PY~~~^Y@@@@@@@@@@@@@@@@#~^^^^
|
||||
7777?#@@@@@@@@@#Y7~~~~!~~~~Y@@@@@@@@@@@@@@@@#~^^^^
|
||||
7777?#@@@@@@@@@@@#57~~~~~~~Y@@@@@@@@@@@@@@@@#~^^^^
|
||||
?777?#@@@@@@@@@@@@@#57~~~~~?#@@@@@@@@@@@@@@@#~^^^^
|
||||
?777?#@@@@@@@@@@@@@@@#J~~~~~!Y#@@@@@@@@@@@@@#~^^^^
|
||||
???7?#@@@@@@@@@@@@@@@@P!!~~~~~!YB@@@@@@@@@@@#~^^^^
|
||||
?????#@@@@@@@@@@@@@@@@P!!!!!!~~~!YB@@@@@@@@@#~^^^^
|
||||
????J&@@@@@@@@@@@@@@@@P!!!!YG?!~~~!JB&@@@@@@#~^^^^
|
||||
????J&@@@@@@@@@@@@@@@@P!!!!5@&G?!~~~!JG&@@@@#~^^^^
|
||||
J???J&@@@@@@@@@@@@@@@@P!!!!5@@@&GJ!~~~!?G&@@#!^^^^
|
||||
J???J&@@@@@@@@@@@@@@@@P7!!!5@@@@@&BJ!~~~!?G&#!^^^~
|
||||
JJJ?J&@@@@@@@@@@@@@@@@P777!5@@@@@@@@BY!~~~~?5!~~^~
|
||||
JJJJJ&@@@@@@@@@@@@@@@@P77775@@@@@@@@@@BY!~~~~~~~~~
|
||||
JJJJJGBBGGGGGGGGGGGGGGY7777JGGGGGGGPPPPPY!~~~~~~~~
|
||||
YJJJJJJJJJ????????????77777777777!!!!!!!!!!!~~~~~~
|
||||
YJJJJJJJJJJJ???????????77777777777!!!!!!!!!!!~~~~~
|
||||
"#;
|
||||
|
||||
impl App {
|
||||
pub fn draw(&mut self, frame: &mut Frame) {
|
||||
frame.render_widget(
|
||||
Paragraph::new(SPLASH)
|
||||
.alignment(ratatui::layout::Alignment::Center)
|
||||
.fg(Color::Rgb(226, 190, 89))
|
||||
.block(Block::new().borders(Borders::all()).title("Coming soon")),
|
||||
frame.area(),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,3 @@
|
|||
mod utils;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
fn alert(s: &str);
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn greet() {
|
||||
alert("Hello, thecockpit!");
|
||||
}
|
||||
pub mod app;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
mod web;
|
||||
|
|
25
thecockpit/src/main.rs
Normal file
25
thecockpit/src/main.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use ratatui::crossterm::event;
|
||||
use thecockpit::app::App;
|
||||
|
||||
fn main() {
|
||||
let mut terminal = ratatui::init();
|
||||
let mut app = App::default();
|
||||
|
||||
loop {
|
||||
terminal.draw(|frame| app.draw(frame));
|
||||
|
||||
if event::poll(Duration::from_secs(0)).unwrap() {
|
||||
match event::read().unwrap() {
|
||||
event::Event::Key(event::KeyEvent {
|
||||
code: event::KeyCode::Char('q'),
|
||||
..
|
||||
}) => break,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ratatui::restore();
|
||||
}
|
36
thecockpit/src/web/mod.rs
Normal file
36
thecockpit/src/web/mod.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use ratzilla::{
|
||||
backend::canvas::CanvasBackendOptions,
|
||||
ratatui::{
|
||||
widgets::{Block, Borders},
|
||||
Terminal,
|
||||
},
|
||||
web_sys, CanvasBackend, WebRenderer,
|
||||
};
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
mod utils;
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
fn alert(s: &str);
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn run(grid_id: &str) {
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
let backend =
|
||||
CanvasBackend::new_with_options(CanvasBackendOptions::new().grid_id(grid_id)).unwrap();
|
||||
let terminal = Terminal::new(backend).unwrap();
|
||||
|
||||
let app = Rc::new(RefCell::new(App::default()));
|
||||
|
||||
terminal.draw_web({
|
||||
let app = Rc::clone(&app);
|
||||
move |frame| app.borrow_mut().draw(frame)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue