Classes

The following classes are available globally.

  • TerminalView provides an AppKit front-end to the Terminal termininal emulator. It is up to a subclass to either wire the terminal emulator to a remote terminal via some socket, to an application that wants to run with terminal emulation, or wiring this up to a pseudo-terminal.

    Users are notified of interesting events in their implementation of the TerminalViewDelegate methods - an instance must be provided to the constructor of TerminalView.

    Developers might want to surface UIs for optionAsMetaKey and allowMouseReporting in their application. They both default to true, but this means that Option-Letter is hijacked for terminal purposes to send the sequence ESC-Letter, instead of the macOS specific character` and means that when mouse-aware applications are running, they hijack the normal selection process.

    Call the getTerminal method to get a reference to the underlying Terminal that backs this view.

    Use the configureNativeColors() to set the defaults colors for the view to match the OS defaults, otherwise, this uses its own set of defaults colors.

    See more

    Declaration

    Swift

    open class TerminalView : NSView, NSTextInputClient, NSUserInterfaceValidations
    extension TerminalView: TerminalDelegate
  • Undocumented

    See more

    Declaration

    Swift

    public class BufferLine : CustomDebugStringConvertible
  • Undocumented

    See more

    Declaration

    Swift

    public class ImageCell
  • This represents the colors used in SwiftTerm, in particular for cells and backgrounds in 16-bit RGB mode

    See more

    Declaration

    Swift

    public class Color : Hashable
  • A HeadlessTerminal provides a terminal emulator that runs a local process, but the output does not go anywhere. You can use this to script applications and screen scrape the output for example, by accessing the terminal from this class.

    See more

    Declaration

    Swift

    public class HeadlessTerminal : TerminalDelegate, LocalProcessDelegate
  • This class provides the capabilities to launch a local Unix process, and connect it to a Terminal class or subclass.

    The MacLocalTerminalView is an example of this, it is a subclass of the MacTerminalView NSView, and it connects that view to the local system, providing a complete terminal emulator connected to running local commands.

    When you create an instance of LocalProcess, you provide a delegate that is used to notify your application when data is received from the lcoal process, to request the desired window size that you would like to give to the child process, and when the process terminates.

    Once you create this instance, you can start a child process by calling the startProcess method which will start the process. You can then send data to this underlying process using the send(data:) method, and you will receive the output on the provided delegate with the dataReceived(slice:) method.

    Received data is dispatched via the queue that you provide in the LocalProcess constructor, if none is provided, this will default to DispatchQueue.main. Generally, this is a good default, but if you have your own main loop or a different dispatching system, you will need to pass your own (for example, the HeadlessTerminal implementation in the test suite does this.

    See more

    Declaration

    Swift

    public class LocalProcess
  • Undocumented

    See more

    Declaration

    Swift

    public class TerminalDebugView : NSView
  • 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

    See more

    Declaration

    Swift

    public class LocalProcessTerminalView : TerminalView, TerminalViewDelegate, LocalProcessDelegate
  • APIs to assist in controlling a Unix pseudo-terminal from Swift, it provides a wrapper for the libc forkptyAPI in the form of fork(andExec:args:env:desiredWindowSize: method, setWinSize and availableBytes

    See more

    Declaration

    Swift

    public class PseudoTerminalHelpers
  • The Terminal class provides the terminal emulation engine, and can be used to feed data to the terminal emulator. Typically users will intereact with a higher-level implementation that provides a UI toolkit-specific rendering and connects the input to the UI toolkit.

    A front-end would draw the contents of the terminal, and take input from the user, which is in turn either mapped to one of the public APIs here, or if it is user input is passed to the feed methods here.

    The terminal is also connected to a backend that is conneted to the client, and data from this client is fed into the emulator by calling the sendResponse method

    The behavior of the terminal is configured by implementing the TerminalDelegate protocol that is provided in the constructor call.

    See more

    Declaration

    Swift

    open class Terminal
  • This class provides an input accessory for the terminal on iOS, you can access this via the inputAccessoryView property in the TerminalView and casting the result to TerminalAccessory.

    This class surfaces some state that the terminal might want to poke at, you should at least support the following properties; controlModifer should be set if the control key is pressed

    See more
  • TerminalView provides an UIKit front-end to the Terminal termininal emulator. It is up to a subclass to either wire the terminal emulator to a remote terminal via some socket, to an application that wants to run with terminal emulation, or wiring this up to a pseudo-terminal.

    Users are notified of interesting events in their implementation of the TerminalViewDelegate methods - an instance must be provided to the constructor of TerminalView.

    Call the getTerminal method to get a reference to the underlying Terminal that backs this view.

    Use the configureNativeColors() to set the defaults colors for the view to match the OS defaults, otherwise, this uses its own set of defaults colors.

    See more

    Declaration

    Swift