From 7431fbab65ced7cb99bd442d03a4bf697fb160f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 5 Aug 2021 00:30:23 +0400 Subject: [PATCH] vte: handle input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau --- qemu-vte/src/main.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qemu-vte/src/main.rs b/qemu-vte/src/main.rs index 1b64326..7465c5c 100644 --- a/qemu-vte/src/main.rs +++ b/qemu-vte/src/main.rs @@ -1,11 +1,11 @@ +use futures::prelude::*; use glib::{clone, MainContext}; use qemu_display_listener::Chardev; use std::os::unix::io::AsRawFd; use std::os::unix::net::UnixStream; use vte::prelude::*; -use vte::{glib, gtk, gio}; +use vte::{gio, glib, gtk}; use zbus::azync::Connection; -use futures::prelude::*; fn main() { pretty_env_logger::init(); @@ -23,17 +23,20 @@ fn main() { MainContext::default().spawn_local(clone!(@strong window => async move { let conn = Connection::new_session().await - .expect("Failed to connect to DBus") - .into(); + .expect("Failed to connect to DBus"); if let Ok(c) = Chardev::new(&conn, "serial").await { let (p0, p1) = UnixStream::pair().unwrap(); if c.proxy.register(p1.as_raw_fd().into()).await.is_ok() { log::info!("ok"); + let ostream = unsafe { gio::UnixOutputStream::with_fd(p0.as_raw_fd()) }; let istream = unsafe { gio::UnixInputStream::take_fd(p0) } .dynamic_cast::() .unwrap(); let mut read = istream.into_async_read().unwrap(); + term.connect_commit(move |_, text, _| { + let _res = ostream.write(text.as_bytes(), gio::NONE_CANCELLABLE); // TODO cancellable and error + }); loop { let mut buffer = [0u8; 8192]; match read.read(&mut buffer[..]).await {