Interface Terminal

All Superinterfaces:
AutoCloseable

public interface Terminal extends AutoCloseable
A handle to a terminal window in the UI.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addTerminalListener(ghidra.app.plugin.core.terminal.TerminalListener listener)
    Add a listener for terminal events
    void
     
    int
    Get the maximum number of characters in each row
    int
    Get the cursor's current column
    int
    Get the cursor's current line
    Get the text in the terminal, excluding the scroll-back buffer
    Get all the text in the terminal, including the scroll-back buffer
    getLineText(int line)
    Get the given line's text
    getRangeText(int startCol, int startLine, int endCol, int endLine)
    Get the text in the given range
    int
    Get the maximum number of rows in the display (not counting scroll-back)
    int
    Get the number of lines in the scroll-back buffer
    Get the pane's current sub title
    default void
    injectDisplayOutput(byte[] arr)
     
    void
    Process the given buffer as if it were output by the terminal's application.
    boolean
    Check whether the terminal is terminated or active
    void
    removeTerminalListener(ghidra.app.plugin.core.terminal.TerminalListener listener)
    Remove a listener for terminal events
    void
    Fit the terminal's dimensions to the containing window.
    default void
    setFixedSize(int cols, int rows)
     
    void
    setFixedSize(short cols, short rows)
    Set the terminal size to the given dimensions, and do not resize it to the window.
    void
    Set the maximum size of the scroll-back buffer in lines
    void
    Set the pane's sub title
    void
    Allow the user to terminate the session forcefully
    void
    Notify the terminal that its session has terminated
    void
    Bring the terminal to the front of the UI
  • Method Details

    • addTerminalListener

      void addTerminalListener(ghidra.app.plugin.core.terminal.TerminalListener listener)
      Add a listener for terminal events
      Parameters:
      listener - the listener
    • removeTerminalListener

      void removeTerminalListener(ghidra.app.plugin.core.terminal.TerminalListener listener)
      Remove a listener for terminal events
      Parameters:
      listener - the listener
    • injectDisplayOutput

      void injectDisplayOutput(ByteBuffer bb)
      Process the given buffer as if it were output by the terminal's application.

      Warning: While implementations may synchronize to ensure the additional buffer is not processed at the same time as actual application input, there may not be any effort to ensure that the buffer is not injected in the middle of an escape sequence. Even if the injection is outside an escape sequence, this may still lead to unexpected behavior, since the injected output may be affected by or otherwise interfere with the application's control of the terminal's state. Generally, this should only be used for testing, or other cases when the caller knows it has exclusive control of the terminal.

      Parameters:
      bb - the buffer of bytes to inject
    • injectDisplayOutput

      default void injectDisplayOutput(byte[] arr)
      Parameters:
      arr - the array of bytes to inject
      See Also:
    • setSubTitle

      void setSubTitle(String title)
      Set the pane's sub title

      The application may also set this sub title using an escape sequence.

      Parameters:
      title - the new sub title
    • getSubTitle

      String getSubTitle()
      Get the pane's current sub title
      Returns:
      the sub title
    • setFixedSize

      void setFixedSize(short cols, short rows)
      Set the terminal size to the given dimensions, and do not resize it to the window.
      Parameters:
      cols - the number of columns
      rows - the number of rows
    • setFixedSize

      default void setFixedSize(int cols, int rows)
      Parameters:
      cols - the number of columns
      rows - the number of rows
      See Also:
    • setDynamicSize

      void setDynamicSize()
      Fit the terminal's dimensions to the containing window.
    • setMaxScrollBackRows

      void setMaxScrollBackRows(int rows)
      Set the maximum size of the scroll-back buffer in lines

      This only affects the primary buffer. The alternate buffer has no scroll-back.

      Parameters:
      rows - the number of scroll-back rows
    • getColumns

      int getColumns()
      Get the maximum number of characters in each row
      Returns:
      the column count
    • getRows

      int getRows()
      Get the maximum number of rows in the display (not counting scroll-back)
      Returns:
      the row count
    • getScrollBackRows

      int getScrollBackRows()
      Get the number of lines in the scroll-back buffer
      Returns:
      the size of the buffer in lines
    • getFullText

      String getFullText()
      Get all the text in the terminal, including the scroll-back buffer
      Returns:
      the full text
    • getDisplayText

      String getDisplayText()
      Get the text in the terminal, excluding the scroll-back buffer
      Returns:
      the display text
    • getLineText

      String getLineText(int line)
      Get the given line's text

      The line at the top of the display has index 0. Lines in the scroll-back buffer have negative indices.

      Parameters:
      line - the index, 0 up
      Returns:
      the text in the line
    • getRangeText

      String getRangeText(int startCol, int startLine, int endCol, int endLine)
      Get the text in the given range

      The line at the top of the display has index 0. Lines in the scroll-back buffer have negative indices.

      Parameters:
      startCol - the first column to include in the starting line
      startLine - the first line to include
      endCol - the first column to exclude in the ending line
      endLine - the last line to include
      Returns:
      the text in the given range
    • getCursorRow

      int getCursorRow()
      Get the cursor's current line

      Lines are indexed 0 up where the top line of the display is 0. The cursor can never be in the scroll-back buffer.

      Returns:
      the line, 0 up, top to bottom
    • getCursorColumn

      int getCursorColumn()
      Get the cursor's current column
      Returns:
      the column, 0 up, left to right
    • close

      void close()
      Specified by:
      close in interface AutoCloseable
    • terminated

      void terminated()
      Notify the terminal that its session has terminated

      The title and sub title are adjust and all listeners are removed. If/when the terminal is closed, it is permanently removed from the tool.

    • setTerminateAction

      void setTerminateAction(Runnable action)
      Allow the user to terminate the session forcefully
      Parameters:
      action - the action to terminate the session, or null to remove the action
    • isTerminated

      boolean isTerminated()
      Check whether the terminal is terminated or active
      Returns:
      true for terminated, false for active
    • toFront

      void toFront()
      Bring the terminal to the front of the UI