From a6654e1c5fb41db53cd2bc8ec6e06f2adf02f388 Mon Sep 17 00:00:00 2001 From: Maksym Vorobiov Date: Mon, 18 Nov 2019 23:24:01 +0200 Subject: [PATCH] add elementary wasi support --- src/tty/mod.rs | 5 +++++ src/tty/wasi.rs | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/tty/wasi.rs diff --git a/src/tty/mod.rs b/src/tty/mod.rs index db9dfa55..edc41ed8 100644 --- a/src/tty/mod.rs +++ b/src/tty/mod.rs @@ -17,6 +17,11 @@ mod unix; #[cfg(unix)] pub use self::unix::*; +#[cfg(target_os="wasi")] +mod wasi; +#[cfg(target_os="wasi")] +pub use self::wasi::*; + #[cfg(windows)] mod windows; #[cfg(windows)] diff --git a/src/tty/wasi.rs b/src/tty/wasi.rs new file mode 100644 index 00000000..8bb756f9 --- /dev/null +++ b/src/tty/wasi.rs @@ -0,0 +1,16 @@ +extern crate libc; +use super::{Width, Height}; + +/// For WASI so far it will return none +/// +/// For background https://github.com/WebAssembly/WASI/issues/42 +pub fn terminal_size() -> Option<(Width, Height)> { + return None; +} + +/// This is inherited from unix and will work only when wasi executed on unix. +/// +/// For background https://github.com/WebAssembly/WASI/issues/42 +pub fn move_cursor_up(n: usize) -> String { + format!("\x1B[{}A", n) +}