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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//! Dynamic information within a pager window.
//!
//! See [`tokio_updating`] and [`async_std_updating`] for more information.
use crateAlternateScreenPagingError;
use crateinit;
use cratePagerMutex;
use Arc;
/// Run the pager inside a [`tokio task`](tokio::task).
///
/// This function is only available when `tokio_lib` feature is enabled.
/// It takes a [`PagerMutex`] and updates the page with new information when `PagerMutex`
/// is updated.
///
/// This function switches to the [`Alternate Screen`] of the TTY and switches
/// to [`raw mode`].
///
/// [`Alternate Screen`]: crossterm::terminal#alternate-screen
/// [`raw mode`]: crossterm::terminal#raw-mode
///
/// ## Errors
///
/// Several operations can fail when outputting information to a terminal, see
/// the [`Result`] type.
///
/// ## Example
///
/// ```rust,no_run
/// use futures::join;
/// use tokio::time::sleep;
/// use std::fmt::Write;
/// use std::time::Duration;
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let output = minus::Pager::new().finish();
///
/// let increment = async {
/// for i in 0..=30_u32 {
/// let mut output = output.lock().await;
/// writeln!(output.lines, "{}", i)?;
/// drop(output);
/// sleep(Duration::from_millis(100)).await;
/// }
/// Result::<_, std::fmt::Error>::Ok(())
/// };
///
/// let (res1, res2) = join!(minus::tokio_updating(output.clone()), increment);
/// res1?;
/// res2?;
/// Ok(())
/// }
/// ```
///
/// **Please do note that you should never lock the output data, since this
/// will cause the paging thread to be paused. Only borrow it when it is
/// required and drop it if you have further asynchronous blocking code.**
pub async
/// Run the pager inside an [`async_std task`](async_std::task).
///
/// This function is only available when `async_std_lib` feature is enabled
/// It takes a [`PagerMutex`] and updates the page with new information when `PagerMutex`
/// is updated.
///
/// This function switches to the [`Alternate Screen`] of the TTY and switches
/// to [`raw mode`].
///
/// [`Alternate Screen`]: crossterm::terminal#alternate-screen
/// [`raw mode`]: crossterm::terminal#raw-mode
///
/// ## Errors
///
/// Several operations can fail when outputting information to a terminal, see
/// the [`Result`] type.
///
/// ## Example
///
/// ```rust,no_run
/// use async_std::task::sleep;
/// use futures::join;
/// use std::fmt::Write;
/// use std::time::Duration;
/// #[async_std::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let output = minus::Pager::new().finish();
///
/// let increment = async {
/// for i in 0..=30_u32 {
/// let mut output = output.lock().await;
/// writeln!(output.lines, "{}", i)?;
/// drop(output);
/// sleep(Duration::from_millis(100)).await;
/// }
/// Result::<_, std::fmt::Error>::Ok(())
/// };
/// let (res1, res2) = join!(minus::async_std_updating(output.clone()), increment);
/// res1?;
/// res2?;
/// Ok(())
/// }
/// ```
///
/// **Please do note that you should never lock the output data, since this
/// will cause the paging thread to be paused. Only borrow it when it is
/// required and drop it if you have further asynchronous blocking code.**
pub async
/// Private function that contains the implemenation for the async display.
async