console-rs / console-rs/console
Cursor hides when pressing Ctrl + C during an active progress bar.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 144
- Avg merge
- 8h 24m
- Merged PRs (30d)
- 4
Description
Description:
While a progress bar from the console crate is running, pressing Ctrl + C interrupts the program but leaves the terminal cursor hidden. The cursor is not restored automatically, so the terminal stays in a broken state until manually reset.
This is the sample code i am testing
use console::Term;
use std::thread;
use std::time::Duration;
fn main() -> std::io::Result<()> {
let term = Term::stderr();
term.hide_cursor()?;
let mut last_lines = 0usize;
let mut a = 0;
let mut b = 0;
loop {
let bar1 = format!("Download A: [{}{}] {}%", "#".repeat(a), " ".repeat(20 - a), a * 5);
let bar2 = format!("Download B: [{}{}] {}%", "#".repeat(b), " ".repeat(20 - b), b * 5);
let frame = vec![bar1, bar2];
if last_lines > 0 {
term.move_cursor_up(last_lines)?;
}
for line in &frame {
term.clear_line()?;
term.write_line(line)?;
}
term.flush()?;
last_lines = frame.len();
if a < 20 { a += 1; }
if b < 20 { b += 1; }
if a == 20 && b == 20 {
break;
}
thread::sleep(Duration::from_millis(200));
}
term.show_cursor()?;
Ok(())
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Rust sample with the console crate and reproduce the hidden-cursor state after Ctrl+C. Trace the Term cursor visibility behavior used by the sample; done means interrupting an active progress display restores the terminal cursor without requiring a manual reset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100