LocalProcessTerminalView

public class LocalProcessTerminalView : TerminalView, TerminalViewDelegate, LocalProcessDelegate

LocalProcessTerminalView is an AppKit NSView that can be used to host a local process the process is launched inside a pseudo-terminal.

Call the startProcess to launch the underlying process inside a pseudo terminal.

Generally, for the LocalProcessTerminalView to be useful, you will want to disable the sandbox for your application, otherwise the underlying shell will not have access to much - not the majority of commands, not assorted places on the file systems and so on. For this, you need to disable for your target in “Signing and Capabilities” the sandbox entirely.

Note: instances of LocalProcessTerminalView will set the TerminalView‘s delegate property and capture and consume the messages. The messages that are most likely needed for consumer applications are reposted to the LocalProcessTerminalViewDelegate in processDelegate. If you override the delegate directly, you might inadvertently break the internal working of LocalProcessTerminalView. If you must change the delegate make sure that you proxy the values in your implementation to the values set after initializing this instance

  • Undocumented

    Declaration

    Swift

    public override init(frame: CGRect)
  • Undocumented

    Declaration

    Swift

    public required init?(coder: NSCoder)
  • The processDelegate is used to deliver messages and information relevant t

    Declaration

    Swift

    public var processDelegate: LocalProcessTerminalViewDelegate?
  • This method is invoked to notify the client of the new columsn and rows that have been set by the UI

    Declaration

    Swift

    public func sizeChanged(source: TerminalView, newCols: Int, newRows: Int)
  • Invoke this method to notify the processDelegate of the new title for the terminal window

    Declaration

    Swift

    public func setTerminalTitle(source: TerminalView, title: String)
  • Declaration

    Swift

    public func hostCurrentDirectoryUpdate(source: TerminalView, directory: String?)
  • This method is invoked when input from the user needs to be sent to the client

    Declaration

    Swift

    public func send(source: TerminalView, data: ArraySlice<UInt8>)
  • Use this method to toggle the logging of data coming from the host, or pass nil to stop

    Declaration

    Swift

    public func setHostLogging(directory: String?)
  • Declaration

    Swift

    public func scrolled(source: TerminalView, position: Double)
  • Launches a child process inside a pseudo-terminal.

    Declaration

    Swift

    public func startProcess(executable: String = "/bin/bash", args: [String] = [], environment: [String]? = nil, execName: String? = nil)

    Parameters

    executable

    The executable to launch inside the pseudo terminal, defaults to /bin/bash

    args

    an array of strings that is passed as the arguments to the underlying process

    environment

    an array of environment variables to pass to the child process, if this is null, this picks a good set of defaults from Terminal.getEnvironmentVariables.

    execName

    If provided, this is used as the Unix argv[0] parameter, otherwise, the executable is used as the args [0], this is used when the intent is to set a different process name than the file that backs it.

  • Implements the LocalProcessDelegate method.

    Declaration

    Swift

    public func processTerminated(_ source: LocalProcess, exitCode: Int32?)
  • Implements the LocalProcessDelegate.dataReceived method

    Declaration

    Swift

    public func dataReceived(slice: ArraySlice<UInt8>)
  • Implements the LocalProcessDelegate.getWindowSize method

    Declaration

    Swift

    public func getWindowSize() -> winsize