mabe02 / lanterna

Java library for creating text-based GUIs
GNU Lesser General Public License v3.0
2.24k stars 243 forks source link

Possible to do multiple termimal windows? #483

Open erikmartinessanches opened 4 years ago

erikmartinessanches commented 4 years ago

Hi, I have the following in two gradle sub-projects, however only one draws correctly and the other one appears black. I'm trying to run these as independent programs with Gradle's subproject feature with "gradle run". This is from their main methods:

Terminal terminal = new DefaultTerminalFactory(System.out, System.in, Charset.forName("UTF8")).createTerminal();
        Screen screen = new DefaultTerminalFactory().createScreen();
        //WindowBasedTextGUI gui = new MultiWindowTextGUI(screen);
        screen.startScreen();

        TextGraphics textGraphics = screen.newTextGraphics();
        textGraphics.setForegroundColor(TextColor.ANSI.GREEN);
        textGraphics.setBackgroundColor(TextColor.ANSI.BLACK);

        screen.refresh();
        //Draw here.... for example using
        screen.setCharacter(column,row, new TextCharacter('#', TextColor.ANSI.GREEN, TextColor.ANSI.BLACK));

        textGraphics.putString(10, 20, "Hi");
        screen.refresh();

        while(true) {
            if(screen.readInput().getKeyType().equals(KeyType.ArrowUp)){

                screen.setCharacter(10, 5, new TextCharacter('?', TextColor.ANSI.GREEN, TextColor.ANSI.BLACK));
                screen.refresh();
                break;
            }
        }
        screen.stopScreen();
    }
}
mabe02 commented 4 years ago

I'm not sure if I understand this correctly... Are you running the same code above in two different JVMs at the same time? That should work. Are you using the bundled Swing terminal emulator or a real one?