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

Cygwin/MSYS support #8

Closed
wants to merge 1 commit into from
Closed

Cygwin/MSYS support #8

wants to merge 1 commit into from

Conversation

RyanGlScott
Copy link
Contributor

Currently, the size command yields Nothing on a Cygwin or MSYS terminal on Windows, which is kind of unfortunate. As a workaround, I use the process library to call stty size if c_GetConsoleScreenBufferInfo fails. stty is a part of coreutils, so it should be installed by default on Cygwin and MSYS (it worked when I tried it on my installations, at least.)

An alternative would be calling tput lines and tput cols processes, but that requires ncurses, which isn't installed by default on recent versions of Cygwin (plus, it kind of defeats the point of this library in the first place).

@dmalikov
Copy link
Member

@RyanGlScott could you please specify a version of ghc that you're running inside a Cygwin?

@RyanGlScott
Copy link
Contributor Author

GHC 7.10.1 (although the GHC version shouldn't matter, since the issue is inherently related to how mintty works, I believe).

@supki
Copy link
Member

supki commented May 28, 2015

First off, I'm very much in favor of adding Cygwin support. There's a couple of questions I have about the implementation though, and without any Windows machines around I can't answer them myself.

Can we use the TIOCGWINSZ ioctl like the POSIX implementation does? Failing that, is it possible to replicate whatever magic stty size does without shelling out to it? I don't expect the way to get tty columns/lines number to change any time soon so even a copy of an existing working solution looks better than relying on an external binary.

@RyanGlScott
Copy link
Contributor Author

Unfortunately, I don't think that the version of MinGW that GHC ships comes with sys/ioctl.h, since I can't compile System.Console.Terminal.Size on Windows (which isn't surprising, given that Win32 doesn't have an ioctl equivalent, at least according to the Cygwin developers):

$ hsc2hs.exe .\Posix.hsc
Posix.hsc:20:23: fatal error: sys/ioctl.h: No such file or directory
compilation terminated.
compiling .\Posix_hsc_make.c failed (exit code 1)

I'll try to look at the source code of stty to see if it can be ported directly to Haskell.

@RyanGlScott
Copy link
Contributor Author

Hm, my searching didn't come up anything promising. Cygwin and MSYS's implementation of stty uses ioctl underneath the surface. However, I don't think the version of MinGW that ships with Windows GHC includes this, so unless we tell users to link against Cygwin/MSYS-specific versions of ioctl, there's not a whole lot one can do about this problem.

@supki
Copy link
Member

supki commented May 29, 2015

Alright.

@supki
Copy link
Member

supki commented May 29, 2015

Pulled (6176787), thanks!

@supki supki closed this May 29, 2015
@supki
Copy link
Member

supki commented May 29, 2015

On Hackage as 0.3.2.

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

Successfully merging this pull request may close these issues.

3 participants