keyfork-prompt: redraw screen on events for prompt_message

This commit is contained in:
Ryan Heywood 2023-12-26 18:08:52 -05:00
parent 55b41a49ef
commit b873ef4d5c
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 22 additions and 19 deletions

View File

@ -238,26 +238,27 @@ where
let mut terminal = AlternateScreen::new(&mut self.write)?;
let mut terminal = RawMode::new(&mut terminal)?;
terminal
.queue(terminal::Clear(terminal::ClearType::All))?
.queue(cursor::MoveTo(0, 0))?;
let mut lines = prompt.lines().peekable();
while let Some(line) = lines.next() {
terminal.queue(Print(line))?;
if lines.peek().is_some() {
terminal
.queue(cursor::MoveDown(1))?
.queue(cursor::MoveToColumn(0))?;
}
}
terminal
.queue(cursor::DisableBlinking)?
.queue(cursor::MoveDown(1))?
.queue(cursor::MoveToColumn(0))?
.queue(PrintStyledContent(" OK ".negative()))?
.flush()?;
loop {
// TODO: split on word boundaries
terminal
.queue(terminal::Clear(terminal::ClearType::All))?
.queue(cursor::MoveTo(0, 0))?;
let mut lines = prompt.lines().peekable();
while let Some(line) = lines.next() {
terminal.queue(Print(line))?;
if lines.peek().is_some() {
terminal
.queue(cursor::MoveDown(1))?
.queue(cursor::MoveToColumn(0))?;
}
}
terminal
.queue(cursor::DisableBlinking)?
.queue(cursor::MoveDown(1))?
.queue(cursor::MoveToColumn(0))?
.queue(PrintStyledContent(" OK ".negative()))?
.flush()?;
match read()? {
Event::Key(k) => match k.code {
KeyCode::Enter | KeyCode::Char(' ') => break,
@ -265,6 +266,8 @@ where
},
_ => (),
}
}
terminal.queue(cursor::EnableBlinking)?.flush()?;
Ok(())