-
Notifications
You must be signed in to change notification settings - Fork 255
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
lanterna assumes that Cygwin is installed in the root directory #421
Comments
The topic of cygwin and /bin/stty has been raised a couple of times in the past. The problem is, that so far, about all who reported a problem with "/bin/stty and Cygwin" turned out not to have anything to do with cygwin, and just accidentally stumbled into the error, because they started the lanterna app from command line with java.exe (rather than for plain windows correctly with javaw.exe). If you happen to be the first one who really has cygwin installed, and intends to run a lanterna app in cygwin's terminal, please let us know! And also let us know if accessing stty that way will really result in a working cygwin-terminal application. What I also have gathered from different sources is, that it wouldn't even help calling the right stty.exe from within a java application, as the stty.exe would not have access to the terminal running the java application. My expectation is, that to run Lanterna under cygwin will really require a shell-script that calls stty.exe, then the Lanterna-app, and finally restore the tty to original settings. Lanterna's CygwinTerminal is in desperate search for someone working with Cygwin and knowing what needs to be done there to let lanterna read single keystrokes in "raw" mode. |
Well I have cygwin installed and I'm hoping to use lanterna and the workaround does fix the problem. I think it would be a good idea for lanterna to use CYGWIN_HOME to locate stty.
I've noticed other oddities under cygwin, especially when using the GUI components.
This is what I've deduced too. Lanterna doesn't really work under cygwin. Unfortunately I'm no cygwin expert so I don't think I can be of much use here. What I can say is that lanterna's telnet Terminal seems to work fine. So if you install telnet under cygwin ( This isn't ideal but it's good enough for show business. I would perhaps make it clearer in the docs that cygwin is indeed not really supported. It might save people some time. |
This really makes it look like the call to stty.exe is just effectless. I don't even have Windows on my machines, so can't test Cygwin.
If you can try out some things (like running stty in a script before java), then you'd be of great use here. |
Just to be clear you’re saying, invoke ‘stty.exe raw’:
$ stty.exe raw
Then launch the lanterna program which is hardcoded to use the Cygwin terminal?
final Terminal terminal = new CygwinTerminal(System.in, System.out, Charset.defaultCharset());
final Screen terminalScreen = new TerminalScreen(terminal);
terminalScreen.startScreen();
final MultiWindowTextGUI textGui = new MultiWindowTextGUI(terminalScreen);
…-- Won’t the CygwinTerminal just call stty.exe again itself?
-- Does it have to be from a single bash script? Can I do this from a bash shell?
From: Andreas Leitgeb
Sent: Friday, June 7, 2019 5:22 PM
To: mabe02/lanterna
Cc: buko; Author
Subject: Re: [mabe02/lanterna] lanterna assumes that Cygwin is installed inthe root directory (#421)
I've noticed other oddities under cygwin, especially when using the GUI components.
This really makes it look like the call to stty.exe is just effectless.
Please try to run a (textgui-based) lanterna application from a script, which calls "stty.exe raw" before starting java-lanterna-app.
I don't even have Windows on my machines, so can't test Cygwin.
Unfortunately I'm no cygwin expert so I don't think I can be of much use here.
If you can try out some things (like running stty in a script before java), then you'd be of great use here.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Yes, like: write it all in one line, or the shell might reset the terminal inbetween. |
(that CygwinTerminal class also calls stty doesn't matter here) |
Well, I tried what you said. I ran:
The result was a blank screen that was totally unresponsive. I couldn't even Ctrl-C out. I had to switch to another window and kill the process. Maybe @adammurdoch can weigh in? His https://github.com/adammurdoch/native-platform project looks very interesting. It seems to provide a facility for detecting the presence of a CygwinTerminal? If so, this could simplify things quite a bit. Though the user would still need to specify exactly where CYGWIN is installed by setting CYGWIN_HOME (environment variable) or cygwin.home (System property). What's interesting is that as I've mentioned before Lanterna works great in Cygwin if I use the telnet terminal. cygwin+mintty are clearly capable of rendering the Lanterna output. The problem seems to lie in what lanterna thinks the Cygwin terminal can do and how itinitialized it. |
native-platform does detect the Cygwin terminal, but at this stage it does not support setting the Cygwin terminal input to raw mode, which I'm guessing might be a problem. It does support detection and raw mode input for other platforms and plus the Windows console. At some point I'd like to figure out how to make this work with the Cygwin terminal too. |
Did some more research into this. After much testing it was possible to get lanterna mostly working under Cygwin and mintty. I had thought winpty might help but it only made things worse. After some more poking about @avl42's suggestion to run stty and launch the java program in a single shell command basically worked but it was necessary to pass some additional parameters to stty. This basically does the trick:
The With these two options lanterna+cygwin+mintty seem to work but much more testing is necessary. I should mention that if you do this and then Ctrl-C out of the program your terminal will be in a bad state. Therefore it is necessary to run the
Not sure why this happens and it would be nice if it didn't. Maybe this is a matter of closing lanterna properly. As mentioned above @adammurdoch 's native-platform project contains code for detecting if you're dealing with a Terminal. I think it may also have a method to query if the terminal is specifically Cygwin? Though it's not clear what the API is we could in theory use such a lib to detect if cygwin is the terminal and then look for a CYGWIN_HOME variable and this might be enough to automatically select the CygwinTerminal. We would also need to modify |
Very interesting, this is probably the furtherst anyone has ever got with Cygwin! I'd be ok to make use of adammurdoch/native-platform if it could help us with controlling the terminal. But let's say we detect Cygwin by looking for CYGWIN_HOME, should we then assume that the user has put the terminal in |
This would indeed be a step in the right direction. I don't think there's any reason why you couldn't call The solution we settled on was to require the user set two environment variables:
If both these variables are set we assume the user is running Cygwin inside mintty. It's not perfect but it's a step in the right direction. |
I'll try this out and let's see if I can get it working |
…again Also use CYGWIN_HOME to find where the binaries are
Alright, with the latest commit, I got it working somewhat. Enter key is still not working, but most of the other keys do. |
Why do you say the enter key isn't working?
Is there a way I can test your latest changes via Maven?
…On Sat, Feb 1, 2020, 13:36 mabe02 ***@***.***> wrote:
Alright, with the latest commit, I got it working somewhat. Enter key is
still not working, but most of the other keys do.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#421?email_source=notifications&email_token=ADA2Y2KTN2LUN5WWXAE442TRAUJ67A5CNFSM4HVBSWXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKQVZ2A#issuecomment-581000424>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADA2Y2K3IUHDIZIUZHU2DJDRAUJ67ANCNFSM4HVBSWXA>
.
|
Unfortunately not, you'll have to clone and compile from source... |
Running a lanterna program using the Cygwin terminal results in the well-known issue:
The program /bin/stty.exe exists but it won't be there unless Cygwin was installed in the root directory.
Workaround
You can work around this problem by putting stty.exe where Lanterna expects it. Create the directory
C:\bin\
and copystty.exe
toC:\bin\stty.exe
.Once the fie has been copied over the lanterna program will work.
Proposed Solution
lanterna should check the environment variable
CYGWIN_HOME
. If this environment variable is set then lanterna should (1) Automatically use the Cygwin Terminal and (2) Change all paths to be relative to this base directory.The text was updated successfully, but these errors were encountered: