Class TerminalUI
java.lang.Object
org.springframework.shell.component.view.TerminalUI
- All Implemented Interfaces:
ViewService
TerminalUI
is a main component orchestrating terminal, eventloop,
key/mouse events and view structure to work together. In many ways it can
be think of being a "main application" when terminal ui is shown in
a screen.-
Constructor Summary
ConstructorDescriptionTerminalUI
(org.jline.terminal.Terminal terminal) Constructs a handler with a given terminal. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Gets anEventLoop
.getModal()
Gets a current modal view.Gets atheme name
.Sets aThemeResolver
.Gets aViewService
.void
redraw()
Redraw a whole screen.void
run()
Run and start execution loop.void
Sets a view to be focused.void
setFullScreenViewRect
(BiFunction<org.jline.terminal.Terminal, View, Rectangle> fullScreenViewRect) Sets a view rect function for full screen mode.void
Sets a new modal view.void
setNonfullScreenViewRect
(BiFunction<org.jline.terminal.Terminal, View, Rectangle> nonfullScreenViewRect) Sets a view rect function for full screen mode.void
Sets a root view.void
setThemeName
(String themeName) Sets atheme name
.void
setThemeResolver
(ThemeResolver themeResolver) Sets aThemeResolver
.
-
Constructor Details
-
TerminalUI
public TerminalUI(org.jline.terminal.Terminal terminal) Constructs a handler with a given terminal.- Parameters:
terminal
- the terminal
-
-
Method Details
-
getModal
Description copied from interface:ViewService
Gets a current modal view.- Specified by:
getModal
in interfaceViewService
- Returns:
- current modal view
-
setModal
Description copied from interface:ViewService
Sets a new modal view. Setting modal tonull
clears existing modal.- Specified by:
setModal
in interfaceViewService
- Parameters:
view
- a view to use as modal
-
setRoot
Sets a root view.- Parameters:
root
- the root viewfullScreen
- if root view should request full screen
-
run
public void run()Run and start execution loop. This method blocks until run loop exits. -
getEventLoop
Gets anEventLoop
.- Returns:
- an event loop
-
redraw
public void redraw()Redraw a whole screen. Essentially a message is dispatched to an event loop which is handled as soon as possible. -
setThemeResolver
Sets aThemeResolver
.- Parameters:
themeResolver
- the theme resolver
-
getThemeResolver
Sets aThemeResolver
.- Returns:
- a theme resolver
-
setThemeName
Sets atheme name
.- Parameters:
themeName
- the theme name
-
getThemeName
Gets atheme name
.- Returns:
- a theme name
-
getViewService
Gets aViewService
.- Returns:
- a view service
-
configure
- Parameters:
view
- the view to configure
-
setFocus
Description copied from interface:ViewService
Sets a view to be focused. Setting focus tonull
clears focused view.- Specified by:
setFocus
in interfaceViewService
- Parameters:
view
- a view to be focused
-
setFullScreenViewRect
public void setFullScreenViewRect(BiFunction<org.jline.terminal.Terminal, View, Rectangle> fullScreenViewRect) Sets a view rect function for full screen mode. Default behaviour usesRectangle
area equal to terminal size.- Parameters:
fullScreenViewRect
- the view rect function
-
setNonfullScreenViewRect
public void setNonfullScreenViewRect(BiFunction<org.jline.terminal.Terminal, View, Rectangle> nonfullScreenViewRect) Sets a view rect function for full screen mode. Default behaviour usesRectangle
fromrootView
if it's not empty, otherwise uses zero based area with width matching terminal columns and height matching 5.- Parameters:
nonfullScreenViewRect
- the view rect function
-