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

Screen API leaves terminal echo off upon exit #532

Open
Windwoes opened this issue Jan 6, 2021 · 2 comments
Open

Screen API leaves terminal echo off upon exit #532

Windwoes opened this issue Jan 6, 2021 · 2 comments

Comments

@Windwoes
Copy link

Windwoes commented Jan 6, 2021

This looks like a really cool library, but there seems to be a bug with the screen API, where after calling stopScreen(), the terminal will not echo characters as they are typed.

Here is the code I am testing with. I am using GNOME Terminal on Ubuntu 16.04 with v3.1.1 of the library. To reproduce, simply run the JAR from the command line, then attempt to type something in the terminal after it exits.

public class Main
{
    Terminal terminal;
    Screen screen;

    public static void main(String[] args) throws IOException
    {
        new Main().main();
    }

    public void main() throws IOException
    {
        DefaultTerminalFactory factory = new DefaultTerminalFactory();
        terminal = factory.createTerminal();

        screen = factory.createScreen();
        screen.startScreen();

        TextGraphics graphics = screen.newTextGraphics();
        graphics.setBackgroundColor(TextColor.ANSI.WHITE_BRIGHT);
        graphics.drawRectangle(new TerminalPosition(0,0), new TerminalSize(80,1), ' ');

        graphics.setForegroundColor(TextColor.ANSI.BLACK);
        graphics.putString(new TerminalPosition(0,0), "Hello world");

        screen.refresh();

        try
        {
            Thread.sleep(2000);
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }

        screen.stopScreen();
    }
}
@karelantonio
Copy link

You has tried use the enter/exit privateMode in Terminal?

@avl42
Copy link
Contributor

avl42 commented Apr 5, 2021

Not sure if this is still relevant, but you can look at some of the tests (src/test/java/... in the lanterna sources) for how they do it to restore tty-state to normal - maybe you need some "try ... finally ..." to make sure the cleanup still gets called even after an exception...

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

No branches or pull requests

3 participants