Add 98.css and interact.js dependencies

Manos Pitsidianakis 2020-07-09 17:36:35 +03:00
parent 23f2dbb431
commit 67cd36103c
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
4 changed files with 292 additions and 20 deletions

File diff suppressed because one or more lines are too long

View File

@ -415,6 +415,14 @@ async function init(input) {
imports.wbg.__wbg_settabIndex_b3ed60b55f3ff661 = function(arg0, arg1) {
getObject(arg0).tabIndex = arg1;
};
imports.wbg.__wbg_offsetWidth_23360c2e25b49ca5 = function(arg0) {
var ret = getObject(arg0).offsetWidth;
return ret;
};
imports.wbg.__wbg_offsetHeight_12da3cbaaaaefe5d = function(arg0) {
var ret = getObject(arg0).offsetHeight;
return ret;
};
imports.wbg.__wbg_focus_5f74cb245be46131 = handleError(function(arg0) {
getObject(arg0).focus();
});
@ -553,7 +561,7 @@ async function init(input) {
imports.wbg.__wbindgen_rethrow = function(arg0) {
throw takeObject(arg0);
};
imports.wbg.__wbindgen_closure_wrapper514 = function(arg0, arg1, arg2) {
imports.wbg.__wbindgen_closure_wrapper516 = function(arg0, arg1, arg2) {
var ret = makeMutClosure(arg0, arg1, 11, __wbg_adapter_22);
return addHeapObject(ret);
};

Binary file not shown.

View File

@ -39,6 +39,25 @@ use smallvec::SmallVec;
use std::env;
use std::io::Write;
fn get_html_element_size() -> (usize, usize) {
let window = web_sys::window().expect("no global `window` exists");
let document = window.document().expect("should have a document on window");
// Manufacture the element we're gonna append
let val = if let Some(val) = document.get_element_by_id("terminal") {
val
} else {
js_console("COULD NOT GET ELEMENT BY ID #terminal !!!");
panic!("COULD NOT GET ELEMENT BY ID #terminal !!!");
};
let val = wasm_bindgen::JsCast::dyn_ref::<web_sys::HtmlElement>(&val)
.expect("Could not cast to HtmlElement");
(
(val.offset_width().saturating_sub(4) / 8) as usize,
(val.offset_height().saturating_sub(8) / 17) as usize,
)
}
struct InputHandler {
//pipe: (RawFd, RawFd),
//rx: Receiver<InputCommand>,
@ -236,8 +255,7 @@ impl State {
*/
let termsize = (175, 45);
let cols = termsize.0 as usize;
let rows = termsize.1 as usize;
let (cols, rows) = get_html_element_size();
let sender = crate::pool::Sender::new();
let job_executor = Arc::new(JobExecutor::new(sender.clone()));
@ -499,6 +517,9 @@ impl State {
/// On `SIGWNICH` the `State` redraws itself according to the new terminal size.
pub fn update_size(&mut self) {
let term_size = get_html_element_size();
self.cols = term_size.0;
self.rows = term_size.1;
/*
let termsize = termion::terminal_size().ok();
let termcols = termsize.map(|(w, _)| w);
@ -513,11 +534,11 @@ impl State {
}
self.cols = termcols.unwrap_or(72) as usize;
self.rows = termrows.unwrap_or(120) as usize;
*/
self.grid.resize(self.cols, self.rows, Cell::with_char(' '));
self.overlay_grid
.resize(self.cols, self.rows, Cell::with_char(' '));
*/
self.rcv_event(UIEvent::Resize);
self.display_messages_dirty = true;
self.display_messages_initialised = false;
@ -1625,7 +1646,7 @@ impl State {
//self.context.input_thread.check();
}
}
const CSS_STYLE: &'static str = r#"#t{font-family:'DejaVu Sans Mono',monospace;font-style:normal;font-size:14px;} text {dominant-baseline: text-before-edge; white-space: pre;} .f{fill:#e5e5e5;} .b{fill:#000;} .c0 {fill:#000;} .c1 {fill:#cd0000;} .c2 {fill:#00cd00;} .c3 {fill:#cdcd00;} .c4 {fill:#00e;} .c5 {fill:#cd00cd;} .c6 {fill:#00cdcd;} .c7 {fill:#e5e5e5;} .c8 {fill:#7f7f7f;} .c9 {fill:#f00;} .c10 {fill:#0f0;} .c11 {fill:#ff0;} .c12 {fill:#5c5cff;} .c13 {fill:#f0f;} .c14 {fill:#0ff;} .c15 {fill:#fff;}"#;
const CSS_STYLE: &'static str = r#"#t{font-family:var(--terminal-font);font-style:normal;font-size:14px;} text {dominant-baseline: text-before-edge; white-space: pre;} .f{fill:#e5e5e5;} .b{fill:#000;} .c0 {fill:#000;} .c1 {fill:#cd0000;} .c2 {fill:#00cd00;} .c3 {fill:#cdcd00;} .c4 {fill:#00e;} .c5 {fill:#cd00cd;} .c6 {fill:#00cdcd;} .c7 {fill:#e5e5e5;} .c8 {fill:#7f7f7f;} .c9 {fill:#f00;} .c10 {fill:#0f0;} .c11 {fill:#ff0;} .c12 {fill:#5c5cff;} .c13 {fill:#f0f;} .c14 {fill:#0ff;} .c15 {fill:#fff;}"#;
const XTERM_COLORS: &'static [(u8, u8, u8)] = &[
/*0*/ (0, 0, 0),