mirror of
https://github.com/openai/codex.git
synced 2026-11-03 19:53:25 +00:00
Use saved cursor for progress redraw
This commit is contained in:
@@ -83,6 +83,7 @@ pub(crate) struct EventProcessorWithHumanOutput {
|
||||
progress_last_len: usize,
|
||||
use_ansi_cursor: bool,
|
||||
progress_wrapped: bool,
|
||||
progress_saved: bool,
|
||||
}
|
||||
|
||||
impl EventProcessorWithHumanOutput {
|
||||
@@ -115,6 +116,7 @@ impl EventProcessorWithHumanOutput {
|
||||
progress_last_len: 0,
|
||||
use_ansi_cursor: cursor_ansi,
|
||||
progress_wrapped: false,
|
||||
progress_saved: false,
|
||||
}
|
||||
} else {
|
||||
Self {
|
||||
@@ -137,6 +139,7 @@ impl EventProcessorWithHumanOutput {
|
||||
progress_last_len: 0,
|
||||
use_ansi_cursor: cursor_ansi,
|
||||
progress_wrapped: false,
|
||||
progress_saved: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -938,6 +941,10 @@ impl EventProcessorWithHumanOutput {
|
||||
self.progress_last_len = 0;
|
||||
if self.use_ansi_cursor {
|
||||
if self.progress_wrapped {
|
||||
if self.progress_saved {
|
||||
eprint!("\u{1b}[u\u{1b}[2K");
|
||||
self.progress_saved = false;
|
||||
}
|
||||
eprint!("\u{1b}[?25h\u{1b}[?7h");
|
||||
self.progress_wrapped = false;
|
||||
}
|
||||
@@ -982,19 +989,21 @@ impl EventProcessorWithHumanOutput {
|
||||
return;
|
||||
}
|
||||
if !self.progress_active {
|
||||
eprint!("\u{1b}[?25l\u{1b}[?7l");
|
||||
eprint!("\u{1b}[?25l\u{1b}[?7l\u{1b}[s");
|
||||
self.progress_wrapped = true;
|
||||
self.progress_saved = true;
|
||||
}
|
||||
let mut output = String::new();
|
||||
output.push('\r');
|
||||
output.push_str("\u{1b}[2K");
|
||||
output.push_str("\u{1b}[u\u{1b}[2K");
|
||||
output.push_str(&line);
|
||||
if done {
|
||||
if self.progress_wrapped {
|
||||
output.push_str("\u{1b}[?25h\u{1b}[?7h");
|
||||
self.progress_wrapped = false;
|
||||
}
|
||||
eprintln!("{output}");
|
||||
output.push('\n');
|
||||
self.progress_saved = false;
|
||||
eprint!("{output}");
|
||||
self.progress_active = false;
|
||||
self.progress_last_len = 0;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user