From 1b6a04ca5504955c571d1c97504fb45ea0befee4 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 8 Jan 2024 01:21:28 +0400 Subject: Initial vendor packages Signed-off-by: Valentin Popov --- vendor/console/src/wasm_term.rs | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 vendor/console/src/wasm_term.rs (limited to 'vendor/console/src/wasm_term.rs') diff --git a/vendor/console/src/wasm_term.rs b/vendor/console/src/wasm_term.rs new file mode 100644 index 0000000..764bc34 --- /dev/null +++ b/vendor/console/src/wasm_term.rs @@ -0,0 +1,54 @@ +use std::fmt::Display; +use std::io; + +use crate::kb::Key; +use crate::term::Term; + +pub use crate::common_term::*; + +pub const DEFAULT_WIDTH: u16 = 80; + +#[inline] +pub fn is_a_terminal(_out: &Term) -> bool { + #[cfg(target = "wasm32-wasi")] + { + unsafe { libc::isatty(out.as_raw_fd()) != 0 } + } + #[cfg(not(target = "wasm32-wasi"))] + { + false + } +} + +#[inline] +pub fn is_a_color_terminal(_out: &Term) -> bool { + // We currently never report color terminals. For discussion see + // the issue in the WASI repo: https://github.com/WebAssembly/WASI/issues/162 + false +} + +#[inline] +pub fn terminal_size(_out: &Term) -> Option<(u16, u16)> { + None +} + +pub fn read_secure() -> io::Result { + Err(io::Error::new( + io::ErrorKind::Other, + "unsupported operation", + )) +} + +pub fn read_single_key() -> io::Result { + Err(io::Error::new( + io::ErrorKind::Other, + "unsupported operation", + )) +} + +#[inline] +pub fn wants_emoji() -> bool { + false +} + +pub fn set_title(_title: T) {} -- cgit v1.2.3