Debian Codegraph @

debian/rust-vendor/console/src/wasm_term.rs

raw
1 use std::fmt::Display;
2 use std::io;
3
4 use crate::kb::Key;
5 use crate::term::Term;
6
7 pub(crate) use crate::common_term::*;
8
9 pub(crate) const DEFAULT_WIDTH: u16 = 80;
10
11 #[inline]
12 pub(crate) fn is_a_terminal(_out: &Term) -> bool {
13 #[cfg(all(target_os = "wasi", target_env = "p1"))]
14 {
15 use std::os::fd::AsRawFd;
16 unsafe { libc::isatty(_out.as_raw_fd()) != 0 }
17 }
18 #[cfg(not(all(target_os = "wasi", target_env = "p1")))]
19 {
20 false
21 }
22 }
23
24 #[inline]
25 pub(crate) fn is_a_color_terminal(_out: &Term) -> bool {
26 // We currently never report color terminals. For discussion see
27 // the issue in the WASI repo: https://github.com/WebAssembly/WASI/issues/162
28 false
29 }
30
31 #[inline]
32 pub(crate) fn is_a_true_color_terminal(_out: &Term) -> bool {
33 false
34 }
35
36 #[inline]
37 pub(crate) fn terminal_size(_out: &Term) -> Option<(u16, u16)> {
38 None
39 }
40
41 pub(crate) fn read_secure() -> io::Result<String> {
42 Err(io::Error::new(
43 io::ErrorKind::Other,
44 "unsupported operation",
45 ))
46 }
47
48 pub(crate) fn read_single_key(_ctrlc_key: bool) -> io::Result<Key> {
49 Err(io::Error::new(
50 io::ErrorKind::Other,
51 "unsupported operation",
52 ))
53 }
54
55 #[inline]
56 pub(crate) fn wants_emoji() -> bool {
57 false
58 }
59
60 pub(crate) fn set_title<T: Display>(_title: T) {}