Search in sources :

Example 1 with TerminalSize

use of com.googlecode.lanterna.TerminalSize in project narchy by automenta.

the class TextUI method session.

public DefaultVirtualTerminal session(float fps) {
    DefaultVirtualTerminal vt = new DefaultVirtualTerminal(new TerminalSize(80, 25));
    TextGUI session = new TextGUI(nar, vt, fps);
    sessions.add(session);
    return vt;
}
Also used : DefaultVirtualTerminal(com.googlecode.lanterna.terminal.virtual.DefaultVirtualTerminal) TerminalSize(com.googlecode.lanterna.TerminalSize)

Example 2 with TerminalSize

use of com.googlecode.lanterna.TerminalSize in project narchy by automenta.

the class ConsoleGUI method resize.

@Override
public void resize(int cols, int rows) {
    cols = Math.min(cols, MAX_COLS);
    rows = Math.min(rows, MAX_ROWS);
    super.resize(cols, rows);
    if (screen != null) {
        screen.doResizeIfNecessary();
        if (gui != null) {
            Window win = gui.getActiveWindow();
            if (win != null) {
                win.setSize(new TerminalSize(cols, rows));
            }
        }
    }
}
Also used : TerminalSize(com.googlecode.lanterna.TerminalSize)

Example 3 with TerminalSize

use of com.googlecode.lanterna.TerminalSize in project narchy by automenta.

the class ConsoleGUI method start.

@Override
public void start(@Nullable SurfaceBase parent) {
    synchronized (this) {
        super.start(parent);
        // thr.start();
        try {
            screen = new TerminalScreen(term);
            screen.startScreen();
            gui = new MultiWindowTextGUI(MyStupidGUIThread::new, screen);
            // TODO try to avoid wrapping it in Window
            window = new BasicWindow();
            window.setPosition(new TerminalPosition(0, 0));
            TerminalSize size = term.getTerminalSize();
            window.setSize(new TerminalSize(size.getColumns(), size.getRows()));
            window.setHints(List.of(Window.Hint.FULL_SCREEN, Window.Hint.NO_DECORATIONS));
            window.setTheme(DARK);
            window.setEnableDirectionBasedMovements(true);
            gui.addWindow(window);
            gui.setActiveWindow(window);
            gui.setEOFWhenNoWindows(true);
            init(window);
            TextGUIThread guiThread = gui.getGUIThread();
            updates = root().onUpdate((s) -> {
                try {
                    guiThread.processEventsAndUpdate();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            });
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : TerminalScreen(com.googlecode.lanterna.screen.TerminalScreen) TerminalSize(com.googlecode.lanterna.TerminalSize) DefaultVirtualTerminal(com.googlecode.lanterna.terminal.virtual.DefaultVirtualTerminal) com.googlecode.lanterna.gui2(com.googlecode.lanterna.gui2) IOException(java.io.IOException) TextColor(com.googlecode.lanterna.TextColor) EOFException(java.io.EOFException) Nullable(org.jetbrains.annotations.Nullable) TerminalScreen(com.googlecode.lanterna.screen.TerminalScreen) List(java.util.List) SurfaceBase(spacegraph.space2d.SurfaceBase) SimpleTheme(com.googlecode.lanterna.graphics.SimpleTheme) On(jcog.event.On) TerminalPosition(com.googlecode.lanterna.TerminalPosition) Theme(com.googlecode.lanterna.graphics.Theme) TerminalPosition(com.googlecode.lanterna.TerminalPosition) TerminalSize(com.googlecode.lanterna.TerminalSize) IOException(java.io.IOException)

Example 4 with TerminalSize

use of com.googlecode.lanterna.TerminalSize in project narchy by automenta.

the class ConsoleTerminal method resize.

public void resize(int cols, int rows) {
    term.setTerminalSize(new TerminalSize(cols, rows));
    text.resize(cols, rows);
    layout();
}
Also used : TerminalSize(com.googlecode.lanterna.TerminalSize)

Aggregations

TerminalSize (com.googlecode.lanterna.TerminalSize)4 DefaultVirtualTerminal (com.googlecode.lanterna.terminal.virtual.DefaultVirtualTerminal)2 TerminalPosition (com.googlecode.lanterna.TerminalPosition)1 TextColor (com.googlecode.lanterna.TextColor)1 SimpleTheme (com.googlecode.lanterna.graphics.SimpleTheme)1 Theme (com.googlecode.lanterna.graphics.Theme)1 com.googlecode.lanterna.gui2 (com.googlecode.lanterna.gui2)1 TerminalScreen (com.googlecode.lanterna.screen.TerminalScreen)1 EOFException (java.io.EOFException)1 IOException (java.io.IOException)1 List (java.util.List)1 On (jcog.event.On)1 Nullable (org.jetbrains.annotations.Nullable)1 SurfaceBase (spacegraph.space2d.SurfaceBase)1