Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for show and hide cursor? #25

Closed
DevinR528 opened this issue Jun 19, 2019 · 2 comments
Closed

Add support for show and hide cursor? #25

DevinR528 opened this issue Jun 19, 2019 · 2 comments

Comments

@DevinR528
Copy link
Contributor

Would a pull request to add the ability to hide/show the cursor be welcome, something like this?

impl Term {
	...
	fn cursor_hide(&mut self) -> io::Result<()> {
        let esc = "\u{001B}";
        let hide = format!("{}[?25l", esc);
        self.write(hide.as_bytes())?;
        Ok(())
    }

    fn cursor_show(&mut self) -> io::Result<()> {
        let esc = "\u{001B}";
        let show = format!("{}[0H{}[0J{}[?25h", esc, esc, esc);
        self.write(show.as_bytes())?;
        Ok(())
    }
}
@DevinR528
Copy link
Contributor Author

Sorry to conform to how your internal design is it would make more sense for hide and show to be implemented in common_term.rs:

pub fn show_cursor(out: &Term) -> io::Result<()> {
	let esc = "\u{001B}";
    out.write_str(&format!("{}[0H{}[0J{}[?25h", esc, esc, esc))
}
and so on...

then just call the func in the Term method
this does work on both windows and linux. Hope this is helpful, thanks for a great lib!

@mitsuhiko
Copy link
Collaborator

This is implemented now.

Archina pushed a commit to Archina/console that referenced this issue Apr 5, 2021
When using a crate like `textwrap` to wrap ridiculously long lines to
use with a select prompt, the rendering mechanism would still clear a
few lines too much.
dtolnay pushed a commit to dtolnay-contrib/console that referenced this issue Feb 4, 2022
…s#89)

This branch replaces the "kind" column in the tasks list view with a new
"state" column that indicates whether the task is currently running,
idle, or terminated. The "kind" column was initially intended to
distinguish between Tokio's blocking tasks and async tasks, but the
task's fields column also conveys this information, so the "kind" column
was really just useful for indicating whether the task was active or
terminated. Distinguishing vs sleeping and idle tasks here makes this
column somewhat more useful.

The task list can also be sorted by the state column. We may want to
consider making this the default sorting in the future...

This currently uses the Unicode "play", "pause", and "stop" symbols, as
proposed in console-rs#25, to display the different task states. In a subsequent
change, I'll add support for detecting and determining whether UTF-8 is
supported by the terminal.

![image](https://user-images.githubusercontent.com/2796466/129458704-a5643d93-6fe1-492f-aafe-6f70a8338b78.png)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
dtolnay pushed a commit to dtolnay-contrib/console that referenced this issue Feb 4, 2022
…e-rs#91)

This branch implements a bit more of the design proposed by @pcwalton in
issue console-rs#25. I haven't implemented everything in the mockups linked in
that issue, because some features in the mocks depend on _data_ we don't
currently have. However, I've brought the design closer in line with the
proposal.

## Before

![image](https://user-images.githubusercontent.com/2796466/129774678-f1c0e5c5-7bb0-4d1c-a9e6-e0cbf679c523.png)
![image](https://user-images.githubusercontent.com/2796466/129774762-9a1c14de-4ad0-4678-9923-13971cb3a48b.png)

## After

![image](https://user-images.githubusercontent.com/2796466/129774465-7bd2ad2f-f1a3-4830-a8fa-f72667028fa1.png)
![image](https://user-images.githubusercontent.com/2796466/129774524-288c967b-6066-4f98-973d-099b3e6a2c55.png)


Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants