summaryrefslogtreecommitdiffstats
path: root/vendor/console/src/wasm_term.rs
blob: 764bc34146be515916be0db5e1d513c8c97e5e34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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<String> {
    Err(io::Error::new(
        io::ErrorKind::Other,
        "unsupported operation",
    ))
}

pub fn read_single_key() -> io::Result<Key> {
    Err(io::Error::new(
        io::ErrorKind::Other,
        "unsupported operation",
    ))
}

#[inline]
pub fn wants_emoji() -> bool {
    false
}

pub fn set_title<T: Display>(_title: T) {}