-
- All Known Subinterfaces:
WindowBasedTextGUI
- All Known Implementing Classes:
AbstractTextGUI,MultiWindowTextGUI
public interface TextGUIThis is the base interface for advanced text GUIs supported in Lanterna. You may want to use this in combination with a TextGUIThread, that can be created/retrieved by usinggetGUIThread().
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceTextGUI.ListenerListener interface for TextGUI, firing on events related to the overall GUI
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(TextGUI.Listener listener)Adds a listener to this TextGUI to fire events on.InteractablegetFocusedInteractable()Returns the interactable component currently in focusTextGUIThreadgetGUIThread()The first time this method is called, it will create a new TextGUIThread object that you can use to automatically manage this TextGUI instead of manually callingprocessInput()andupdateScreen().ScreengetScreen()Returns theScreenfor thisWindowBasedTextGUIThemegetTheme()Returns the theme currently assigned to thisTextGUIbooleanisPendingUpdate()This method can be used to determine if any component has requested a redraw.booleanprocessInput()Drains the input queue and passes the key strokes to the GUI system for processing.voidremoveListener(TextGUI.Listener listener)Removes a listener from this TextGUI so that it will no longer receive eventsvoidsetTheme(Theme theme)Sets the global theme to be used by this TextGUI.voidsetVirtualScreenEnabled(boolean virtualScreenEnabled)This method controls whether or not the virtual screen should be used.voidupdateScreen()Updates the screen, to make any changes visible to the user.
-
-
-
Method Detail
-
getTheme
Theme getTheme()
Returns the theme currently assigned to thisTextGUI- Returns:
- Currently active
Theme
-
setTheme
void setTheme(Theme theme)
Sets the global theme to be used by this TextGUI. This value will be set on every TextGUIGraphics object created for drawing the GUI, but individual components can override this if they want. If you don't call this method you should assume that a default theme is assigned by the library.- Parameters:
theme- Theme to use as the default theme for this TextGUI
-
processInput
boolean processInput() throws java.io.IOExceptionDrains the input queue and passes the key strokes to the GUI system for processing. For window-based system, it will send each key stroke to the active window for processing. If the input read gives an EOF, it will throw EOFException and this is normally the signal to shut down the GUI (any command coming in before the EOF will be processed as usual before this).- Returns:
trueif at least one key stroke was read and processed,falseif there was nothing on the input queue (only for non-blocking IO)- Throws:
java.io.IOException- In case there was an underlying I/O errorjava.io.EOFException- In the input stream received an EOF marker
-
getScreen
Screen getScreen()
Returns theScreenfor thisWindowBasedTextGUI- Returns:
- the
Screenused by thisWindowBasedTextGUI
-
updateScreen
void updateScreen() throws java.io.IOExceptionUpdates the screen, to make any changes visible to the user.- Throws:
java.io.IOException- In case there was an underlying I/O error
-
isPendingUpdate
boolean isPendingUpdate()
This method can be used to determine if any component has requested a redraw. If this method returnstrue, you may want to callupdateScreen().- Returns:
trueif this TextGUI has a change and is waiting for someone to callupdateScreen()
-
setVirtualScreenEnabled
void setVirtualScreenEnabled(boolean virtualScreenEnabled)
This method controls whether or not the virtual screen should be used. This is what enabled you to make your UI larger than what fits the terminal, as it will expand the virtual area and put in scrollbars. If set tofalse, the virtual screen will be bypassed and any content outside of the screen will be cropped. This property istrueby default.- Parameters:
virtualScreenEnabled- Iftrue, then virtual screen will be used, otherwise it is bypassed
-
getGUIThread
TextGUIThread getGUIThread()
The first time this method is called, it will create a new TextGUIThread object that you can use to automatically manage this TextGUI instead of manually callingprocessInput()andupdateScreen(). After the initial call, it will return the same object as it was originally returning.- Returns:
- A
TextGUIThreadimplementation that can be used to asynchronously manage the GUI
-
getFocusedInteractable
Interactable getFocusedInteractable()
Returns the interactable component currently in focus- Returns:
- Component that is currently in input focus
-
addListener
void addListener(TextGUI.Listener listener)
Adds a listener to this TextGUI to fire events on.- Parameters:
listener- Listener to add
-
removeListener
void removeListener(TextGUI.Listener listener)
Removes a listener from this TextGUI so that it will no longer receive events- Parameters:
listener- Listener to remove
-
-