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
|
// this is a bit of a hack:
// the TUI backend used by this app changes stdout to raw byte mode.
// this is not desired when we do not use it (in our --raw mode),
// since it makes writing to stdout overly complex
//
// so what we do here is provide a fake backend (RawTerminalBackend)
// that implements the Backend TUI trait, but does nothing
// this way, we don't need to create the TermionBackend
// and thus skew our stdout when we don't need it
use std::io;
use ratatui::{backend::Backend, buffer::Cell, layout::Rect};
pub struct RawTerminalBackend {}
impl Backend for RawTerminalBackend {
fn clear(&mut self) -> io::Result<()> {
Ok(())
}
fn hide_cursor(&mut self) -> io::Result<()> {
Ok(())
}
fn show_cursor(&mut self) -> io::Result<()> {
Ok(())
}
fn get_cursor(&mut self) -> io::Result<(u16, u16)> {
Ok((0, 0))
}
fn set_cursor(&mut self, _x: u16, _y: u16) -> io::Result<()> {
Ok(())
}
fn draw<'a, I>(&mut self, _content: I) -> io::Result<()>
where
I: Iterator<Item = (u16, u16, &'a Cell)>,
{
Ok(())
}
fn size(&self) -> io::Result<Rect> {
Ok(Rect::new(0, 0, 0, 0))
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
|