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
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