Package com.tonic.vellum.terminal
Interface Terminal
-
- All Superinterfaces:
java.lang.AutoCloseable
public interface Terminal extends java.lang.AutoCloseableThe terminal driver contract. The default implementation is JLine-backed, and any driver that satisfies these methods can replace it without touching the public API.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidclose()voidenterAlternateScreen()Switches to the alternate screen buffer so the user's scrollback is preserved.voidenterRawMode()Switches the terminal into raw (unbuffered, no-echo) mode.voidflush()Flushes queued output to the terminal.voidhideCursor()Hides the cursor.voidmoveCursor(int x, int y)Positions the cursor at a zero-based cell coordinate.KeyEventreadKey(long timeoutMillis)Reads and decodes the next key, blocking up totimeoutMillis.voidrestore()Restores the terminal to the main screen, cooked mode, and shown cursor.voidsetResizeListener(java.lang.Runnable listener)Registers a callback invoked when the terminal resizes.voidshowCursor()Shows the cursor.TerminalSizesize()voidwrite(java.lang.String text)Queues an already-formed ANSI string for output.
-
-
-
Method Detail
-
enterRawMode
void enterRawMode()
Switches the terminal into raw (unbuffered, no-echo) mode.
-
enterAlternateScreen
void enterAlternateScreen()
Switches to the alternate screen buffer so the user's scrollback is preserved.
-
restore
void restore()
Restores the terminal to the main screen, cooked mode, and shown cursor. Idempotent.
-
size
TerminalSize size()
- Returns:
- the current size in cells
-
setResizeListener
void setResizeListener(java.lang.Runnable listener)
Registers a callback invoked when the terminal resizes.- Parameters:
listener- the callback, which may run off the UI thread
-
readKey
KeyEvent readKey(long timeoutMillis)
Reads and decodes the next key, blocking up totimeoutMillis.- Parameters:
timeoutMillis- maximum time to wait in milliseconds- Returns:
- the decoded key event, or
nullwhen the timeout elapses with no input
-
write
void write(java.lang.String text)
Queues an already-formed ANSI string for output.- Parameters:
text- the raw string to write
-
flush
void flush()
Flushes queued output to the terminal.
-
hideCursor
void hideCursor()
Hides the cursor.
-
showCursor
void showCursor()
Shows the cursor.
-
moveCursor
void moveCursor(int x, int y)Positions the cursor at a zero-based cell coordinate.- Parameters:
x- column in cellsy- row in cells
-
close
default void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
-