1#![cfg_attr(nightly, feature(never_type))]
2
3#![allow(dead_code)]
4
5macro_rules! flush {
6 ($stream:expr) => {
7 {
8 #![allow(unused_imports)]
9 use std::io::Write;
10 let _ = $stream.flush();
11 }
12 };
13 () => {
14 use std::io::Write;
15 let _ = ::std::io::stdout().flush();
16 };
17 (? $stream:expr) => {
18 {
19 #[allow(unused_imports)]
20 use std::io::Write;
21 $stream.flush()
22 }
23 };
24 (?) => {
25 use std::io::Write;
26 ::std::io::stdout().flush()
27 };
28}
29
30pub(crate) type DefaultOutputDevice = std::io::Stdout;
32pub(crate) const CREATE_DEFAULT_OUTPUT_DEVICE_FUNC: fn () -> DefaultOutputDevice = std::io::stdout;
37
38#[inline]
40pub(crate) fn create_default_output_device() -> DefaultOutputDevice
41{
42 CREATE_DEFAULT_OUTPUT_DEVICE_FUNC()
43}
44
45#[cfg(feature="size")]
46#[inline(always)]
47fn terminal_size_of(f: &(impl AsRawFd + ?Sized)) -> Option<(terminal_size::Width, terminal_size::Height)>
48{
49 terminal_size::terminal_size_using_fd(f.as_raw_fd())
50}
51
52use atomic_refcell::AtomicRefCell;
53
54use std::os::unix::io::*;
56
57mod util;
58mod inter;
59pub use inter::*;
60
61pub mod progress;
62pub mod wheel;
63pub mod spinner;
64pub mod silent;
65
66#[cfg(feature="size")]
70pub fn has_terminal_output_default() -> bool
71{
72 terminal_size::terminal_size().is_some()
73}
74
75#[cfg(feature="size")]
79pub fn has_terminal_output(f: &(impl AsRawFd + ?Sized)) -> bool
80{
81 terminal_size::terminal_size_using_fd(f.as_raw_fd()).is_some()
82}
83
84pub mod prelude {
86 pub use super::inter::*;
87 pub use super::{
88 spinner::Spin,
89 progress::Bar,
90 silent::Silent,
91 };
92}