TerminalDelegate

public protocol TerminalDelegate : AnyObject

The terminal delegate is a protocol that must be implemented by a class that would provide a user interface for the terminal, and it is used by the Terminal to notify of important changes on the underlying terminal

  • showCursor(source:) Default implementation

    Invoked to request that the cursor be shown

    Default Implementation

    Declaration

    Swift

    func showCursor(source: Terminal)
  • hideCursor(source:) Default implementation

    Invoked to request that the cursor be shown

    Default Implementation

    Declaration

    Swift

    func hideCursor(source: Terminal)
  • setTerminalTitle(source:title:) Default implementation

    This method is invoked when the terminal needs to set the title for the window, a UI toolkit would react by setting the terminal title in the window or any other user visible element.

    The default implementation does nothing.

    Default Implementation

    Declaration

    Swift

    func setTerminalTitle(source: Terminal, title: String)
  • setTerminalIconTitle(source:title:) Default implementation

    This method is invoked when the terminal needs to set the title for the minimized icon, a UI toolkit would react by setting the terminal title in the icon or any other user visible element

    The default implementation does nothing.

    Default Implementation

    Declaration

    Swift

    func setTerminalIconTitle(source: Terminal, title: String)
  • windowCommand(source:command:) Default implementation

    These are various commands that are sent by the client. They are rare, and if you do not know what to return, just return nil, the terminal will return a suitable value.

    The response string needs to be suitable for the Xterm CSI Ps ; Ps ; Ps t command see the WindowManipulationCommand enumeration for those that need to return values

    The default implementation does nothing.

    Default Implementation

    Declaration

    Swift

    @discardableResult
    func windowCommand(source: Terminal, command: Terminal.WindowManipulationCommand) -> [UInt8]?
  • sizeChanged(source:) Default implementation

    This method is invoked when the terminal dimensions have changed in response to an escape sequence that triggers a terminal resize, the user interface toolkit should attempt to accomodate the new window size

    TODO: This is not wired up

    The default implementation does nothing.

    Default Implementation

    Declaration

    Swift

    func sizeChanged(source: Terminal)
  • Sends the byte data to the client connected to the terminal (in terminal emulation documentation, this is the “host”)

    Declaration

    Swift

    func send(source: Terminal, data: ArraySlice<UInt8>)
  • scrolled(source:yDisp:) Default implementation

    Callback - the window was scrolled, new yDisplay passed The default implementation does nothing.

    Default Implementation

    Declaration

    Swift

    func scrolled(source: Terminal, yDisp: Int)
  • linefeed(source:) Default implementation

    Callback a newline was generated The default implementation does nothing.

    Default Implementation

    Declaration

    Swift

    func linefeed(source: Terminal)
  • bufferActivated(source:) Default implementation

    This method is invoked when the buffer changes from Normal to Alternate, or Alternate to Normal The default implementation does nothing.

    Default Implementation

    Declaration

    Swift

    func bufferActivated(source: Terminal)
  • bell(source:) Default implementation

    Should raise the bell The default implementation does nothing.

    Default Implementation

    Declaration

    Swift

    func bell(source: Terminal)
  • selectionChanged(source:) Default implementation

    This is invoked when the selection has changed, or has been turned on. The status is available in terminal.selection.active, and the range relative to the buffer is in terminal.selection.start and terminal.selection.end

    The default implementation does nothing.

    Default Implementation

    Declaration

    Swift

    func selectionChanged(source: Terminal)
  • isProcessTrusted(source:) Default implementation

    This method should return true if operations that can read the buffer back should be allowed, otherwise, return false. This is useful to run some applications that attempt to checksum the contents of the screen (unit tests)

    The default implementation returns true

    Default Implementation

    Declaration

    Swift

    func isProcessTrusted(source: Terminal) -> Bool
  • mouseModeChanged(source:) Default implementation

    This method is invoked when the mouseMode property has changed, and gives the UI a chance to update any tracking capabilities that are required in the toolkit or no longer required to provide the events.

    The default implementation ignores the mouse change

    Default Implementation

    Declaration

    Swift

    func mouseModeChanged(source: Terminal)
  • cursorStyleChanged(source:newStyle:) Default implementation

    This method is invoked when a request to change the cursor style has been issued by client application.

    Default Implementation

    Declaration

    Swift

    func cursorStyleChanged(source: Terminal, newStyle: CursorStyle)
  • hostCurrentDirectoryUpdated(source:) Default implementation

    This method is invoked when the client application has issued a command to report its current working directory (this is done with the OSC 7 command). The value can be read by accessing the hostCurrentDirectory property.

    The default implementaiton does nothing.

    Default Implementation

    Declaration

    Swift

    func hostCurrentDirectoryUpdated(source: Terminal)
  • hostCurrentDocumentUpdated(source:) Default implementation

    This method is invoked when the client application has issued a command to report its current document (this is done with the OSC 6 command). The value can be read by accessing the hostCurrentDocument property.

    The default implementaiton does nothing.

    Default Implementation

    Declaration

    Swift

    func hostCurrentDocumentUpdated(source: Terminal)
  • colorChanged(source:idx:) Default implementation

    This method is invoked when a color in the 0..255 palette has been redefined, if the front-end keeps a cache or uses indexed rendering, it should update the color with the new values. If the value of idx is nil, this means all the ansi colors changed

    Default Implementation

    Declaration

    Swift

    func colorChanged(source: Terminal, idx: Int?)
  • setForegroundColor(source:color:) Default implementation

    The view should try to set the foreground color to the provided color

    Default Implementation

    Declaration

    Swift

    func setForegroundColor(source: Terminal, color: Color)
  • setBackgroundColor(source:color:) Default implementation

    The view should try to set the background color to the provided color

    Default Implementation

    Declaration

    Swift

    func setBackgroundColor(source: Terminal, color: Color)
  • getColors(source:) Default implementation

    This should return the current foreground and background colors to report.

    Default Implementation

    Declaration

    Swift

    func getColors(source: Terminal) -> (foreground: Color, background: Color)
  • iTermContent(source:content:) Default implementation

    This method is invoked when the client application (iTerm2) has issued a OSC 1337 and SwiftTerm did not handle a handler for it.

    The default implementaiton does nothing.

    Default Implementation

    Declaration

    Swift

    func iTermContent(source: Terminal, content: ArraySlice<UInt8>)
  • clipboardCopy(source:content:) Default implementation

    This method is invoked when the client application has issued a OSC 52 to put data on the clipboard.

    Default Implementation

    Declaration

    Swift

    func clipboardCopy(source: Terminal, content: Data)
  • notify(source:title:body:) Default implementation

    Invoked when client application issues OSC 777 to show notification.

    The default implementation does nothing.

    Default Implementation

    Declaration

    Swift

    func notify(source: Terminal, title: String, body: String)
  • Invoked to create an image from an RGBA buffer at the current cursor position

    The default implementation does nothing.

    Default Implementation

    Declaration

    Swift

    func createImageFromBitmap(source: Terminal, bytes: inout [UInt8], width: Int, height: Int)
  • Invoked to create an image from a byte blob that might be encoded in one of the various compressed file formats (unlike the other option that gets an RGBA buffer already decoded). It also included requests for the desired dimensions.

    Default Implementation

    Declaration

    Swift

    func createImage(source: Terminal, data: Data, width: ImageSizeRequest, height: ImageSizeRequest, preserveAspectRatio: Bool)