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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use crate::{init, utils};
use crate::error::AlternateScreenPagingError;
use crate::Pager;
use crossterm::tty::IsTty;
use std::io::{self, Write};
#[derive(Debug, thiserror::Error)]
pub enum PageAllError {
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Paging(#[from] AlternateScreenPagingError),
#[error("Failed to determine terminal size")]
TerminalSize(crossterm::ErrorKind),
}
#[cfg_attr(
feature = "async_std_lib",
doc = "- [`async_std_updating`](crate::async_std_updating)\n"
)]
#[cfg_attr(
feature = "tokio_lib",
doc = "- [`tokio_updating`](crate::tokio_updating)\n"
)]
#[cfg_attr(
not(any(feature = "async_std_lib", feature = "tokio_lib")),
doc = "- Asynchronous features are disabled, see [here](crate#features) for more information.\n"
)]
#[cfg_attr(docsrs, doc(cfg(feature = "static_output")))]
pub fn page_all(mut p: Pager) -> Result<(), PageAllError> {
let stdout = io::stdout();
let line_count = p.num_lines();
{
if !stdout.is_tty() {
let mut out = stdout.lock();
utils::write_lines(&mut out, &mut p)?;
out.flush()?;
return Ok(());
}
}
{
if !p.run_no_overflow && p.rows > line_count {
let mut out = stdout.lock();
utils::write_lines(&mut out, &mut p)?;
out.flush()?;
} else {
init::static_paging(p)?;
}
Ok(())
}
}