Skip to main content

claude_code_cli_acp/terminal/
screen.rs

1pub struct TerminalScreen {
2    rows: u16,
3    cols: u16,
4    parser: vt100::Parser,
5}
6
7#[derive(Clone, Debug, PartialEq, Eq)]
8pub struct ScreenSnapshot {
9    pub rows: u16,
10    pub cols: u16,
11    pub text: String,
12}
13
14impl TerminalScreen {
15    pub fn new(rows: u16, cols: u16) -> Self {
16        Self {
17            rows,
18            cols,
19            parser: vt100::Parser::new(rows, cols, 0),
20        }
21    }
22
23    pub fn process(&mut self, bytes: &[u8]) {
24        self.parser.process(bytes);
25    }
26
27    pub fn text(&self) -> String {
28        self.parser.screen().contents()
29    }
30
31    pub fn snapshot(&self) -> ScreenSnapshot {
32        ScreenSnapshot {
33            rows: self.rows,
34            cols: self.cols,
35            text: self.text(),
36        }
37    }
38}