-
- All Known Subinterfaces:
WindowBasedTextGUI
- All Known Implementing Classes:
AbstractTextGUI
,MultiWindowTextGUI
public interface TextGUI
This 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 interface
TextGUI.Listener
Listener interface for TextGUI, firing on events related to the overall GUI
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addListener(TextGUI.Listener listener)
Adds a listener to this TextGUI to fire events on.Interactable
getFocusedInteractable()
Returns the interactable component currently in focusTextGUIThread
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()
.Screen
getScreen()
Returns theScreen
for thisWindowBasedTextGUI
Theme
getTheme()
Returns the theme currently assigned to thisTextGUI
boolean
isPendingUpdate()
This method can be used to determine if any component has requested a redraw.boolean
processInput()
Drains the input queue and passes the key strokes to the GUI system for processing.void
removeListener(TextGUI.Listener listener)
Removes a listener from this TextGUI so that it will no longer receive eventsvoid
setTheme(Theme theme)
Sets the global theme to be used by this TextGUI.void
setVirtualScreenEnabled(boolean virtualScreenEnabled)
This method controls whether or not the virtual screen should be used.void
updateScreen()
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.IOException
Drains 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:
true
if at least one key stroke was read and processed,false
if 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 theScreen
for thisWindowBasedTextGUI
- Returns:
- the
Screen
used by thisWindowBasedTextGUI
-
updateScreen
void updateScreen() throws java.io.IOException
Updates 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:
true
if 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 istrue
by 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
TextGUIThread
implementation 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
-
-