Jaeyo / lanterna

Automatically exported from code.google.com/p/lanterna
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Unexpected output when creating a screen. #78

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When using the text terminal on an OSX shell, creating a new screen instance 
seems to return unexpected output.

The following code: 

Terminal terminal = TerminalFacade.createTextTerminal();
Screen screen = new Screen(terminal);

Returns:

$ java -jar test.jar 
                                                                                                        ^[[24;166R $ 4;166R

Calling terminal.enterPrivateMode() and terminal.exitPrivateMode() seems to fix 
this output, but this leads to user input not showing to the user after the 
program terminates.

Original issue reported on code.google.com by Mathijss...@gmail.com on 24 Jul 2013 at 8:16

GoogleCodeExporter commented 9 years ago
Do you have a complete code example which reproduces this? I don't have access 
to a Mac but I can check on some other terminal applications.

Original comment by mab...@gmail.com on 3 Aug 2013 at 5:55

GoogleCodeExporter commented 9 years ago
public static void main(String[] args) {
    Terminal terminal = TerminalFacade.createTextTerminal();
    Screen screen = new Screen(terminal);
}

Is all I need to create the issue on my machine. 

Original comment by Mathijss...@gmail.com on 6 Aug 2013 at 9:24

GoogleCodeExporter commented 9 years ago
Okay, I've tracked down what this is. It's actually the initial terminal size 
query done when you create the Screen. Please note that if you want to use the 
Screen class, you probably want to be in private mode since the Screen knows 
nothing of what is currently on the terminal when the application starts. 
Screen is essentially designed with being in private mode in mind. 

Original comment by mab...@gmail.com on 21 Aug 2013 at 1:36

GoogleCodeExporter commented 9 years ago
First of all, thanks a lot for looking into this. 

As I mentioned in the first post, using private mode does indeed solve the 
output problem, but it causes other problems to occur (after exiting, terminal 
input isn't shown to the user until the terminal is reset).

Are there any other workarounds available, or is a there a fix coming up in the 
next release now that you found the source? 

Original comment by Mathijss...@gmail.com on 21 Aug 2013 at 1:43

GoogleCodeExporter commented 9 years ago
Okay, there could be some way it's not restoring the terminal input correctly 
after closing. Sorry, but could you give me a code sample where you run in 
private mode and after exiting the input isn't visible until you manually reset 
the terminal?

Original comment by mab...@gmail.com on 24 Aug 2013 at 1:35

GoogleCodeExporter commented 9 years ago
    public static void main(String[] args) {
        Terminal t = TerminalFacade.createTextTerminal();
        t.enterPrivateMode();
        Screen s = new Screen(t);
        s.startScreen();
        s.stopScreen();
        t.exitPrivateMode();
    }

Reproduces the issue on my machine. 

I found a discussion which looked like a similar issue, which turned out to be 
a problem where exitPrivateMode was not called, perhaps I'm doing something 
wrong in a similar way?
https://groups.google.com/forum/#!topic/lanterna-discuss/pTYc5sxfUgQ

Original comment by Mathijss...@gmail.com on 24 Aug 2013 at 8:35

GoogleCodeExporter commented 9 years ago
Okay, I can get this to reproduce. I've now done a few changes that may solve 
this, please try with the latest 2.1.x snapshot (to be pushed in a few minutes) 
and let me know how it works.

Original comment by mab...@gmail.com on 1 Dec 2013 at 2:32

GoogleCodeExporter commented 9 years ago
Snapshot pushed, but if you don't have the snapshot repository available, 
here's a direct link:
https://oss.sonatype.org/content/repositories/snapshots/com/googlecode/lanterna/
lanterna/2.1.7-SNAPSHOT/lanterna-2.1.7-20131201.143922-2.jar

If you can verify this, I'll make a proper release.

Original comment by mab...@gmail.com on 1 Dec 2013 at 2:41

GoogleCodeExporter commented 9 years ago
The snapshot seems to work just fine on my system. Thanks for fixing this!

Original comment by Mathijss...@gmail.com on 1 Dec 2013 at 4:42

GoogleCodeExporter commented 9 years ago
Great, thank you!

Original comment by mab...@gmail.com on 2 Dec 2013 at 12:20