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

Support Windows in extra::term #2807

Closed
catamorphism opened this issue Jul 5, 2012 · 12 comments
Closed

Support Windows in extra::term #2807

catamorphism opened this issue Jul 5, 2012 · 12 comments
Labels
O-windows Operating system: Windows

Comments

@catamorphism
Copy link
Contributor

Do it. Do it now. (Or at least sometime.)

@emberian
Copy link
Member

emberian commented Jul 3, 2013

This is easier to do now that it has been refactored to support 8-color terminals and handle terminfo properly. Aetherspawn in IRC started work on this.

@emberian
Copy link
Member

emberian commented Aug 8, 2013

Updated issue title to reflect std->extra

@vadimcn
Copy link
Contributor

vadimcn commented Dec 6, 2013

Windows console does not support escape codes. In order to change colors one must use console API functions, such as SetConsoleTextAttribute. Unfortunately these require console handle, but there no obvious way to extract a file handle from io::Writer. I suppose we could implement Terminal<StdWriter> instead of Terminal<Writer> and add a get_fd() method to the former...

@alexcrichton: any other ideas?

jhasse added a commit to jhasse/rust that referenced this issue Dec 17, 2013
@jhasse
Copy link
Contributor

jhasse commented Dec 17, 2013

Hi! I tried to fix this and noticed that the msys terminal supports ANSI colors but msys doesn't come with terminfo. So this patch tries to figure out if it is run from a msys terminal (env var TERM is cygwin, since msys is a modified fork of an older cygwin version) and then enables colors.

Here is a screenshot of my patch in action: https://www.dropbox.com/s/mi7gxp94ilkis60/Screenshot%202013-12-17%2008.39.48.png

Strangely this also works with cmd.exe on my system. Maybe because I have msysgit installed? I don't know how to detect this though: https://www.dropbox.com/s/tvk5hd3n8ur4cnd/Screenshot%202013-12-17%2008.42.09.png

Sorry if there are issues in my patch, I'm very new to Rust and unfamiliar with the language.

@klutzy
Copy link
Contributor

klutzy commented Dec 17, 2013

@jhasse rust's stdio uses libuv's tty interface. libuv implements some ANSI color parser, so I guess that extra::term worked via libuv, not via msys support.

@jhasse
Copy link
Contributor

jhasse commented Dec 17, 2013

@klutzy Cool, so this means it should work on all Windows systems out of the box, right?

@emberian
Copy link
Member

We only use libuv in M:N mode, with libgreen. We shouldn't depend on the
specific runtime in extra::term.

On Tue, Dec 17, 2013 at 3:36 AM, Jan Niklas Hasse
notifications@github.comwrote:

@klutzy https://github.com/klutzy Cool, so this means it should work on
all Windows systems out of the box, right?


Reply to this email directly or view it on GitHubhttps://github.com//issues/2807#issuecomment-30733941
.

jhasse added a commit to jhasse/rust that referenced this issue Dec 17, 2013
@jhasse
Copy link
Contributor

jhasse commented Dec 17, 2013

Okay I've reverted the change for cmd.exe. This new patch should now only change something for the msys terminal on windows.

jhasse added a commit to jhasse/rust that referenced this issue Dec 20, 2013
bors added a commit that referenced this issue Dec 21, 2013
Enable ANSI colors if TERM is set to cygwin and terminfo is not available (msys terminal on Windows). See #2807
@jhasse
Copy link
Contributor

jhasse commented Dec 21, 2013

Okay my patch has been merged, here are some of the things I found out, if anyone wants to work on cmd.exe/cygwin support:

  • cmd.exe / PowerShell: isatty == 0, TERM is not set. Supports ansi colors though (maybe cause of msysgit?)
  • cygwin: isatty == 0, TERM is set to "xterm" and terminfo is supported.
  • msys: isatty == 64, TERM is set to "cygwin" and terminfo is not supported.

Colored output in cygwin doesn't work because of this check: https://github.com/mozilla/rust/blob/master/src/libsyntax/diagnostic.rs#L205

Side note: I just opened up this awesome PowerShell: An ugly looking window came up with non anti-aliased text and no colors at all. I can't even resize it properly - LOL. Microsoft == failure.

My advice for anyone: Use ConEmu with msys ;)

@alexcrichton
Copy link
Member

Closed by 5cf2f54

@vadimcn
Copy link
Contributor

vadimcn commented Jan 16, 2014

Strictly speaking MSys terminal != Windows console. The fix in 5cf2f54 won't work, unless one uses mingw shell.

@alexcrichton
Copy link
Member

Ah, I take it back then!

@alexcrichton alexcrichton reopened this Jan 16, 2014
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Versions of clippy that come with newer toolchains report a large number
of needless_borrows_for_generic_args. We can address these now so that
we don't have to make these changes as part of a toolchain update.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants