From 18f91f2c9ea47b10c014443b4234ca96382032a5 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 28 Dec 2023 09:01:13 +0000 Subject: [PATCH] Delete some of my commented-out prototype code. The new Tui structure now replicates almost all the useful functionality of that. The only exception is the extra loop where we re-split each line returned from render() to the screen width, in case it's overlong. But that can't be centralised into the current code: it will have to live in the draw() method of ActivityState types that need it (particularly, those rendering paragraphs), because they'll need to know when it happened in order to count screen lines correctly. --- src/main.rs | 57 ----------------------------------------------------- 1 file changed, 57 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3c2e5cb..402a502 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,64 +49,7 @@ fn streaming() -> Result<(), mastodonochrome::OurError> { } */ -/* -#[allow(unused)] -fn tui(paras: Vec) -> std::io::Result<()> { - stdout().execute(EnterAlternateScreen)?; - enable_raw_mode()?; - let mut terminal = Terminal::new(CrosstermBackend::new(stdout()))?; - terminal.clear()?; - - loop { - terminal.draw(|frame| { - let area = frame.size(); - let buf = frame.buffer_mut(); - buf.reset(); - let mut y = 0; - for para in ¶s { - for line in para.render(area.width as usize) { - for line in line.split(area.width as usize) { - ratatui_set_string(buf, y, 0, &line); - y += 1; - } - } - } - })?; - - match receiver.recv() { - Err(_) => break, - Ok(ev) => { - dbg!(&ev); - match ev { - Event::Key(key) => { - if key.kind == KeyEventKind::Press { - if key.code == KeyCode::Char('q') { - break; - } else if key.code == KeyCode::Char('b') { - stdout().write(b"\x07")?; - } - } - }, - _ => (), - } - }, - } - } - stdout().execute(LeaveAlternateScreen)?; - disable_raw_mode()?; - Ok(()) -} -*/ - fn main() -> ExitCode { - /* - let mut client = Client::new().unwrap(); - if let Some(st) = client.status_by_id("111602135142646031") { - let paras = parse_html(&st.content); - tui(paras).unwrap(); - } - */ - match Tui::run() { Ok(_) => ExitCode::from(0), Err(e) => { -- 2.30.2