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

More shortcut functions in crate term #11

Open
rust-highfive opened this issue Jan 19, 2015 · 4 comments
Open

More shortcut functions in crate term #11

rust-highfive opened this issue Jan 19, 2015 · 4 comments

Comments

@rust-highfive
Copy link

Issue by derekdreery
Sunday Nov 02, 2014 at 20:49 GMT

For earlier discussion, see rust-lang/rust#18548

This issue was labelled with: in the Rust repository


Just wondering if there are plans to add some more shortcut functionality in the term crate.

I.e. currently there is fg and bg functions to change color, but no functions for clearing part of the screen, changing cursor location etc.

All the machinery is already there (for reading terminfo etc), just need to implement the functions.

I don't know if this 'core' enough for the main lib, but it's very simple (a few short functions like the fg and bg ones) and avoids having to link to libcurses etc. At the moment I implement the stuff I need as a separate custom Trait, but it feels like it belongs in the term traits.

Don't know windows so don't know how complex terminal stuff works there.

@retep998
Copy link
Contributor

As stated in the earlier discussion, I'll be glad to cover the Windows side of things.

@asolove
Copy link
Contributor

asolove commented Apr 24, 2015

I am new to contributing to Rust and interested in filling in some of these holes as part of a small project to add a pretty progress indicator to the compiler: rust-lang/rust#24335

I started a branch that implements cursor_up and delete_line for terminfo here: https://github.com/asolove/term/tree/more-shortcuts I am going to do some research and try to implement those for Windows as well.

I would appreciate any feedback, and especially any ideas about how to write tests for this. Also, what is the chance these two functions would land by themselves, rather than as part of a larger effort to add many more of the missing ones?

@retep998
Copy link
Contributor

To implement cursor_up, use GetConsoleScreenBufferInfo to get the current position of the cursor and then SetConsoleCursorPosition to set its position above that. delete_line, which I assume simply blanks the current line can be implemented by using WriteConsoleOutput to write a rectangular region of spaces, using GetConsoleScreenBufferInfo to figure out the current line and width and then SetConsoleCursorPosition to reset the cursor position if needed.

@retep998
Copy link
Contributor

If you just submit a PR with the new features implemented for terminfo only with documentation clearly stating what the function is expected to do, then I can easily fill in the Windows implementation afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants