-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Support ANSI colors in msys terminals. See #2807 #11031
Conversation
pub struct Terminal<T> { | ||
priv num_colors: u16, | ||
priv out: T, | ||
priv ti: ~TermInfo | ||
priv ti: Option<~TermInfo> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be cleaner to synthesize a TermInfo entry for ANSI terminals,- rather than hard-coding escapes into this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The escapes would have to be hard coded in this TermInfo entry then anyway, wouldn't they?
It would probably be a cleaner solution, but I don't know enough Rust to implement that (correctly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, TermInfo would be hard-coded, but at least all information would be in one place, not scattered across the Terminal class.
Also, this would open the door for other custom-detected terminal types, depending on the OS perhaps. For example, you could detect if Rust is running on top of libuv-based IO stack and have a TermInfo variant corresponding to escapes that libuv supports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I have a (much shorter) patch ready which uses this approach.
I will push it tomorrow after some more testing ;)
I'm more or less ok with this PR. But, could we convince upstream cygwin to include a terminfo entry? I'd like to remove this hack eventually. Hardcoding terminals is no good. |
Agreed. Keep in my mind that this is msys only (cygwin has terminfo Also wait for tomorrow, my new patch (using TermInfo struct) is cleaner :) |
Ok, sounds good. Thanks for taking this up! On Thu, Dec 19, 2013 at 10:23 AM, Jan Niklas Hasse <[email protected]
|
Done :) This time I force pushed instead of creating a new PR. This new patch also enables bold text and disables 16 colors (they were emulated using bold text). |
Enable ANSI colors if TERM is set to cygwin and terminfo is not available (msys terminal on Windows). See #2807
New lint [`needless_return_with_try`] Closes rust-lang#10902 Rather than having a config option, this will just suggest removing the "return"; if `try_err` is used as well, then it'll be added again but without the `?`. changelog: New lint [`needless_return_with_try`]
Enable ANSI colors if TERM is set to cygwin and terminfo is not available (msys terminal on Windows). See #2807