crate::ix!();
pub struct NoechoInst;
impl NoechoInst {
#[inline]
pub fn new() -> Self {
trace!(target: "compat::stdin", "disabling echo");
set_stdin_echo(false);
NoechoInst
}
}
impl Drop for NoechoInst {
#[inline]
fn drop(&mut self) {
trace!(target: "compat::stdin", "re‑enabling echo");
set_stdin_echo(true);
}
}
#[macro_export]
macro_rules! no_stdin_echo {
() => {
let _no_echo = $crate::stdin::NoechoInst::new();
};
}
#[inline]
pub fn set_stdin_echo(enable: bool) {
#[cfg(target_os = "windows")]
windows_impl::set_echo(enable);
#[cfg(unix)]
unix_impl::set_echo(enable);
}
#[inline]
pub fn stdin_terminal() -> bool {
#[cfg(target_os = "windows")]
{
windows_impl::is_tty()
}
#[cfg(unix)]
{
unix_impl::is_tty()
}
}
#[inline]
pub fn stdin_ready() -> bool {
if !stdin_terminal() {
debug!(target: "compat::stdin", "STDIN is not a TTY – assuming ready");
return true;
}
#[cfg(target_os = "windows")]
{
false
}
#[cfg(unix)]
{
unix_impl::is_ready()
}
}