Class TerminalUI

java.lang.Object
org.springframework.shell.component.view.TerminalUI
All Implemented Interfaces:
ViewService

public class TerminalUI extends Object implements 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 Details

    • TerminalUI

      public TerminalUI(org.jline.terminal.Terminal terminal)
      Constructs a handler with a given terminal.
      Parameters:
      terminal - the terminal
  • Method Details

    • getModal

      public View getModal()
      Description copied from interface: ViewService
      Gets a current modal view.
      Specified by:
      getModal in interface ViewService
      Returns:
      current modal view
    • setModal

      public void setModal(View view)
      Description copied from interface: ViewService
      Sets a new modal view. Setting modal to null clears existing modal.
      Specified by:
      setModal in interface ViewService
      Parameters:
      view - a view to use as modal
    • setRoot

      public void setRoot(View root, boolean fullScreen)
      Sets a root view.
      Parameters:
      root - the root view
      fullScreen - if root view should request full screen
    • run

      public void run()
      Run and start execution loop. This method blocks until run loop exits.
    • getEventLoop

      public EventLoop getEventLoop()
      Gets an EventLoop.
      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

      public void setThemeResolver(ThemeResolver themeResolver)
      Parameters:
      themeResolver - the theme resolver
    • getThemeResolver

      public ThemeResolver getThemeResolver()
      Returns:
      a theme resolver
    • setThemeName

      public void setThemeName(String themeName)
      Sets a theme name.
      Parameters:
      themeName - the theme name
    • getThemeName

      public String getThemeName()
      Gets a theme name.
      Returns:
      a theme name
    • getViewService

      public ViewService getViewService()
      Gets a ViewService.
      Returns:
      a view service
    • configure

      public void configure(View view)
      Configure view for EventLoop, ThemeResolver, theme name and ViewService.
      Parameters:
      view - the view to configure
    • setFocus

      public void setFocus(@Nullable View view)
      Description copied from interface: ViewService
      Sets a view to be focused. Setting focus to null clears focused view.
      Specified by:
      setFocus in interface ViewService
      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 uses Rectangle 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 uses Rectangle from rootView 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