term now working
This commit is contained in:
parent
4fd4b6eb17
commit
fbe0a4f554
|
@ -194,7 +194,8 @@ fn root() -> impl Element {
|
||||||
match term_open {
|
match term_open {
|
||||||
true =>
|
true =>
|
||||||
El::new()
|
El::new()
|
||||||
.s(Height::fill().max(450))
|
.s(Height::fill().max(400).min(400))
|
||||||
|
.s(Padding::all(5))
|
||||||
.child(term::root()),
|
.child(term::root()),
|
||||||
false =>
|
false =>
|
||||||
El::new()
|
El::new()
|
||||||
|
|
|
@ -8,6 +8,8 @@ use shared::term::{TerminalDownMsg, TerminalScreen, TerminalUpMsg};
|
||||||
// use tokio::time::timeout;
|
// use tokio::time::timeout;
|
||||||
pub static TERM_OPEN: Lazy<Mutable<bool>> = Lazy::new(|| {false.into()});
|
pub static TERM_OPEN: Lazy<Mutable<bool>> = Lazy::new(|| {false.into()});
|
||||||
|
|
||||||
|
pub const TERMINAL_COLOR: Oklch = color!("oklch(20% 0.125 262.26)");
|
||||||
|
|
||||||
pub static TERMINAL_STATE: Lazy<Mutable<TerminalDownMsg>> =
|
pub static TERMINAL_STATE: Lazy<Mutable<TerminalDownMsg>> =
|
||||||
Lazy::new(|| {
|
Lazy::new(|| {
|
||||||
Mutable::new(TerminalDownMsg::TermNotStarted)
|
Mutable::new(TerminalDownMsg::TermNotStarted)
|
||||||
|
@ -19,6 +21,8 @@ pub fn root() -> impl Element {
|
||||||
El::new()
|
El::new()
|
||||||
.s(Width::fill())
|
.s(Width::fill())
|
||||||
.s(Height::fill())
|
.s(Height::fill())
|
||||||
|
.s(Background::new().color(TERMINAL_COLOR))
|
||||||
|
.s(RoundedCorners::all(7))
|
||||||
.s(Font::new().family([
|
.s(Font::new().family([
|
||||||
FontFamily::new("Lucida Console"),
|
FontFamily::new("Lucida Console"),
|
||||||
FontFamily::new("Courier"),
|
FontFamily::new("Courier"),
|
||||||
|
@ -66,16 +70,13 @@ fn send_char(
|
||||||
has_control : bool,
|
has_control : bool,
|
||||||
) {
|
) {
|
||||||
match process_str(s, has_control) {
|
match process_str(s, has_control) {
|
||||||
// TODO : fill this out
|
|
||||||
Some(c) => {
|
Some(c) => {
|
||||||
let send_c = c.clone();
|
let send_c = c.clone();
|
||||||
Task::start(async move {
|
Task::start(async move {
|
||||||
println!("Sending char: {}", &c);
|
|
||||||
crate::platform::send_char(send_c.to_string()).await;
|
crate::platform::send_char(send_c.to_string()).await;
|
||||||
println!("Sent char: {}", &c);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
None => {eprintln!("Not processing: {}", s)}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ impl EventListener for EventProxy {
|
||||||
pub struct ATerm {
|
pub struct ATerm {
|
||||||
pub term: Arc<FairMutex<Term<EventProxy>>>,
|
pub term: Arc<FairMutex<Term<EventProxy>>>,
|
||||||
|
|
||||||
rows : u16,
|
pub rows : u16,
|
||||||
cols : u16,
|
pub cols : u16,
|
||||||
|
|
||||||
/// Use tx to write things to terminal instance from outside world
|
/// Use tx to write things to terminal instance from outside world
|
||||||
pub tx: Notifier,
|
pub tx: Notifier,
|
||||||
|
@ -38,7 +38,7 @@ pub struct ATerm {
|
||||||
|
|
||||||
impl ATerm {
|
impl ATerm {
|
||||||
pub fn new() -> result::Result<ATerm, std::io::Error> {
|
pub fn new() -> result::Result<ATerm, std::io::Error> {
|
||||||
let (rows, cols) = (21, 90);
|
let (rows, cols) = (21, 85);
|
||||||
let id = 1;
|
let id = 1;
|
||||||
let pty_config = tty::Options {
|
let pty_config = tty::Options {
|
||||||
shell: Some(tty::Shell::new("/bin/bash".to_string(), vec![])),
|
shell: Some(tty::Shell::new("/bin/bash".to_string(), vec![])),
|
||||||
|
@ -93,7 +93,7 @@ impl ATerm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn terminal_instance_to_string(terminal_instance: &ATerm) -> String {
|
pub fn terminal_instance_to_string(terminal_instance: &ATerm) -> String {
|
||||||
let (rows, cols) = (terminal_instance.rows, terminal_instance.cols);
|
let (rows, cols) = (terminal_instance.rows, terminal_instance.cols);
|
||||||
let term = terminal_instance.term.lock();
|
let term = terminal_instance.term.lock();
|
||||||
let grid = term.grid().clone();
|
let grid = term.grid().clone();
|
||||||
|
|
|
@ -23,6 +23,7 @@ type DiagramConnectorPath = String;
|
||||||
type DiagramConnectorName = String;
|
type DiagramConnectorName = String;
|
||||||
type ComponentId = String;
|
type ComponentId = String;
|
||||||
use alacritty_terminal::event::Notify;
|
use alacritty_terminal::event::Notify;
|
||||||
|
use shared::term::{TerminalDownMsg, TerminalScreen};
|
||||||
|
|
||||||
mod component_manager;
|
mod component_manager;
|
||||||
mod aterm;
|
mod aterm;
|
||||||
|
@ -156,7 +157,6 @@ async fn unload_signal(signal_ref_index: usize, store: tauri::State<'_, Store>)
|
||||||
|
|
||||||
#[tauri::command(rename_all = "snake_case")]
|
#[tauri::command(rename_all = "snake_case")]
|
||||||
async fn send_char(c : String) -> Result<(), ()> {
|
async fn send_char(c : String) -> Result<(), ()> {
|
||||||
// see if length of c is 1
|
|
||||||
if c.len() == 1 {
|
if c.len() == 1 {
|
||||||
let term = TERM.lock().unwrap();
|
let term = TERM.lock().unwrap();
|
||||||
term.tx.notify(c.into_bytes());
|
term.tx.notify(c.into_bytes());
|
||||||
|
@ -315,12 +315,20 @@ pub fn run() {
|
||||||
|
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
// Simulate emitting a message after a delay
|
// Simulate emitting a message after a delay
|
||||||
std::thread::sleep(std::time::Duration::from_secs(5));
|
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||||
|
|
||||||
// Use APP_HANDLE to emit the event
|
//tart term and send initial update to backend
|
||||||
if let Some(app_handle) = APP_HANDLE.read().unwrap().clone() {
|
if let Some(app_handle) = crate::APP_HANDLE.read().unwrap().clone() {
|
||||||
let payload = serde_json::json!({ "message": "Hello from the backend using APP_HANDLE!" });
|
let term = crate::TERM.lock().unwrap();
|
||||||
app_handle.emit("backend-message", payload).unwrap();
|
let content = crate::aterm::terminal_instance_to_string(&term);
|
||||||
|
let payload = TerminalScreen {
|
||||||
|
cols: term.cols,
|
||||||
|
rows: term.rows,
|
||||||
|
content: content
|
||||||
|
};
|
||||||
|
let payload = TerminalDownMsg::FullTermUpdate(payload);
|
||||||
|
let payload = serde_json::json!(payload);
|
||||||
|
app_handle.emit("term_content", payload).unwrap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue