at least we're now sending a character
This commit is contained in:
parent
24710414bd
commit
f992a24719
9 changed files with 203 additions and 32 deletions
|
@ -25,6 +25,7 @@ pub mod theme;
|
|||
use theme::*;
|
||||
|
||||
pub mod term;
|
||||
use shared::term::{TerminalDownMsg, TerminalScreen};
|
||||
|
||||
#[derive(Clone, Copy, Default)]
|
||||
enum Layout {
|
||||
|
@ -101,8 +102,11 @@ fn main() {
|
|||
.unwrap_throw()
|
||||
.set_component_text(&component_id, &text),
|
||||
}
|
||||
})
|
||||
.await
|
||||
}).await;
|
||||
platform::listen_term_update(|down_msg| {
|
||||
term::TERMINAL_STATE.set(down_msg);
|
||||
}).await;
|
||||
zoon::println!("Printing on line 106");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -188,11 +192,15 @@ fn root() -> impl Element {
|
|||
TERM_OPEN.signal_cloned().map(
|
||||
|term_open| {
|
||||
match term_open {
|
||||
true => {El::new().child("Terminal")}
|
||||
false => {El::new().child("")}
|
||||
true =>
|
||||
El::new()
|
||||
.s(Height::fill().max(450))
|
||||
.child(term::root()),
|
||||
false =>
|
||||
El::new()
|
||||
.child("")
|
||||
}
|
||||
}
|
||||
)
|
||||
// El::new()
|
||||
)
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ type DiagramConnectorPath = String;
|
|||
type DiagramConnectorName = String;
|
||||
type ComponentId = String;
|
||||
|
||||
use shared::term::{TerminalDownMsg, TerminalScreen};
|
||||
|
||||
pub async fn show_window() {
|
||||
platform::show_window().await
|
||||
}
|
||||
|
@ -72,6 +74,10 @@ pub async fn unload_signal(signal_ref: wellen::SignalRef) {
|
|||
platform::unload_signal(signal_ref).await
|
||||
}
|
||||
|
||||
pub async fn send_char() {
|
||||
platform::send_char().await
|
||||
}
|
||||
|
||||
pub async fn add_decoders(decoder_paths: Vec<DecoderPath>) -> AddedDecodersCount {
|
||||
let count = platform::add_decoders(decoder_paths).await;
|
||||
if count > 0 {
|
||||
|
@ -112,6 +118,12 @@ pub async fn listen_diagram_connectors_messages(
|
|||
platform::listen_diagram_connectors_messages(on_message).await;
|
||||
}
|
||||
|
||||
pub async fn listen_term_update(
|
||||
on_message: impl FnMut(TerminalDownMsg) + 'static,
|
||||
) {
|
||||
platform::listen_term_update(on_message).await;
|
||||
}
|
||||
|
||||
pub async fn notify_diagram_connector_text_change(
|
||||
diagram_connector: DiagramConnectorName,
|
||||
component_id: ComponentId,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use shared::DiagramConnectorMessage;
|
||||
use shared::term::{TerminalDownMsg, TerminalScreen};
|
||||
use zoon::*;
|
||||
|
||||
pub(super) async fn show_window() {
|
||||
|
@ -57,6 +58,12 @@ pub(super) async fn unload_signal(signal_ref: wellen::SignalRef) {
|
|||
.unwrap_throw()
|
||||
}
|
||||
|
||||
pub(super) async fn send_char() {
|
||||
tauri_glue::send_char()
|
||||
.await
|
||||
.unwrap_throw()
|
||||
}
|
||||
|
||||
pub(super) async fn add_decoders(
|
||||
decoder_paths: Vec<super::DecoderPath>,
|
||||
) -> super::AddedDecodersCount {
|
||||
|
@ -97,6 +104,14 @@ pub(super) async fn listen_diagram_connectors_messages(
|
|||
tauri_glue::listen_diagram_connectors_messages(Closure::new(on_message).into_js_value()).await
|
||||
}
|
||||
|
||||
pub(super) async fn listen_term_update(
|
||||
mut on_message: impl FnMut(TerminalDownMsg) + 'static,
|
||||
) {
|
||||
let on_message =
|
||||
move |message: JsValue| on_message(serde_wasm_bindgen::from_value(message).unwrap_throw());
|
||||
tauri_glue::listen_term_update(Closure::new(on_message).into_js_value()).await
|
||||
}
|
||||
|
||||
pub(super) async fn notify_diagram_connector_text_change(
|
||||
diagram_connector: super::DiagramConnectorName,
|
||||
component_id: super::ComponentId,
|
||||
|
@ -142,6 +157,9 @@ mod tauri_glue {
|
|||
#[wasm_bindgen(catch)]
|
||||
pub async fn unload_signal(signal_ref_index: usize) -> Result<(), JsValue>;
|
||||
|
||||
#[wasm_bindgen(catch)]
|
||||
pub async fn send_char() -> Result<(), JsValue>;
|
||||
|
||||
#[wasm_bindgen(catch)]
|
||||
pub async fn add_decoders(
|
||||
decoder_paths: Vec<super::super::DecoderPath>,
|
||||
|
@ -160,6 +178,8 @@ mod tauri_glue {
|
|||
|
||||
pub async fn listen_diagram_connectors_messages(on_event: JsValue);
|
||||
|
||||
pub async fn listen_term_update(on_event: JsValue);
|
||||
|
||||
#[wasm_bindgen(catch)]
|
||||
pub async fn notify_diagram_connector_text_change(
|
||||
diagram_connector: super::super::DiagramConnectorName,
|
||||
|
|
|
@ -8,24 +8,11 @@ use shared::term::{TerminalDownMsg, TerminalScreen, TerminalUpMsg};
|
|||
// use tokio::time::timeout;
|
||||
pub static TERM_OPEN: Lazy<Mutable<bool>> = Lazy::new(|| {false.into()});
|
||||
|
||||
static TERMINAL_STATE: Lazy<Mutable<TerminalDownMsg>> =
|
||||
pub static TERMINAL_STATE: Lazy<Mutable<TerminalDownMsg>> =
|
||||
Lazy::new(|| {
|
||||
Mutable::new(TerminalDownMsg::TermNotStarted)
|
||||
});
|
||||
|
||||
// static CONNECTION: Lazy<Connection<UpMsg, DownMsg>> = Lazy::new(|| {
|
||||
// Connection::new(
|
||||
// |down_msg, _| {
|
||||
// match down_msg {
|
||||
// DownMsg::TerminalDownMsg(terminal_msg) => {
|
||||
// TERMINAL_STATE.set(terminal_msg);
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
// )
|
||||
// });
|
||||
|
||||
pub fn root() -> impl Element {
|
||||
term_request();
|
||||
let terminal =
|
||||
|
@ -39,7 +26,6 @@ pub fn root() -> impl Element {
|
|||
]))
|
||||
.update_raw_el(|raw_el| {
|
||||
raw_el.global_event_handler(|event: events::KeyDown| {
|
||||
println!("Pressed key: {}", &event.key());
|
||||
send_char(
|
||||
(&event).key().as_str(),
|
||||
(&event).ctrl_key(),
|
||||
|
@ -82,7 +68,13 @@ fn send_char(
|
|||
match process_str(s, has_control) {
|
||||
// TODO : fill this out
|
||||
Some(c) => {
|
||||
eprintln!("Sending char: {}", c);
|
||||
let send_c = c.clone();
|
||||
Task::start(async move {
|
||||
println!("Sending char: {}", &c);
|
||||
crate::platform::send_char().await;
|
||||
// crate::platform::unload_signal().await;
|
||||
println!("Sent char: {}", &c);
|
||||
});
|
||||
}
|
||||
None => {eprintln!("Not processing: {}", s)}
|
||||
}
|
||||
|
@ -94,7 +86,7 @@ fn make_grid_with_newlines(term : &TerminalScreen) -> String {
|
|||
let mut formatted = String::new();
|
||||
for (i, c) in term.content.chars().enumerate() {
|
||||
formatted.push(c);
|
||||
if (i + 1) % term.cols == 0 {
|
||||
if ((i + 1) as u16) % term.cols == 0 {
|
||||
formatted.push('\n');
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -38,20 +38,20 @@ export async function get_hierarchy(): Promise<WellenHierarchy> {
|
|||
}
|
||||
|
||||
export async function load_signal_and_get_timeline(
|
||||
signal_ref_index: number,
|
||||
signal_ref_index: number,
|
||||
timeline_zoom: number,
|
||||
timeline_viewport_width: number,
|
||||
timeline_viewport_x: number,
|
||||
timeline_viewport_x: number,
|
||||
block_height: number,
|
||||
var_format: VarFormat,
|
||||
): Promise<Timeline> {
|
||||
return await invoke("load_signal_and_get_timeline", {
|
||||
signal_ref_index,
|
||||
timeline_zoom,
|
||||
return await invoke("load_signal_and_get_timeline", {
|
||||
signal_ref_index,
|
||||
timeline_zoom,
|
||||
timeline_viewport_width,
|
||||
timeline_viewport_x,
|
||||
block_height,
|
||||
var_format
|
||||
block_height,
|
||||
var_format
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,11 @@ export async function unload_signal(signal_ref_index: number): Promise<void> {
|
|||
return await invoke("unload_signal", { signal_ref_index });
|
||||
}
|
||||
|
||||
export async function send_char(): Promise<void> {
|
||||
const char = "a";
|
||||
return await invoke("send_char", { char });
|
||||
}
|
||||
|
||||
export async function add_decoders(decoder_paths: Array<DecoderPath>): Promise<AddedDecodersCount> {
|
||||
return await invoke("add_decoders", { decoder_paths });
|
||||
}
|
||||
|
@ -79,6 +84,10 @@ export async function listen_diagram_connectors_messages(on_message: (message: a
|
|||
return await listen("diagram_connector_message", (message) => on_message(message.payload));
|
||||
}
|
||||
|
||||
export async function listen_term_update(on_message: (message: any) => void) {
|
||||
return await listen("term_content", (message) => on_message(message.payload));
|
||||
}
|
||||
|
||||
export async function notify_diagram_connector_text_change(diagram_connector: DiagramConnectorName, component_id: ComponentId, text: string): Promise<void> {
|
||||
return await invoke("notify_diagram_connector_text_change", { diagram_connector, component_id, text });
|
||||
}
|
||||
|
|
Reference in a new issue