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 ofTerminalView
.Developers might want to surface UIs for
optionAsMetaKey
andallowMouseReporting
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 underlyingTerminal
that backs this view.Use the
See moreconfigureNativeColors()
to set the defaults colors for the view to match the OS defaults, otherwise, this uses its own set of defaults colors.Declaration
Swift
open class TerminalView : NSView, NSTextInputClient, NSUserInterfaceValidations
extension TerminalView: TerminalDelegate
-
Undocumented
See moreDeclaration
Swift
public class BufferLine : CustomDebugStringConvertible
-
Undocumented
See moreDeclaration
Swift
public class ImageCell
-
This represents the colors used in SwiftTerm, in particular for cells and backgrounds in 16-bit RGB mode
See moreDeclaration
Swift
public class Color : Hashable
-
A
See moreHeadlessTerminal
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 theterminal
from this class.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 theMacTerminalView
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 thesend(data:)
method, and you will receive the output on the provided delegate with thedataReceived(slice:)
method.Received data is dispatched via the queue that you provide in the LocalProcess constructor, if none is provided, this will default to
See moreDispatchQueue.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, theHeadlessTerminal
implementation in the test suite does this.Declaration
Swift
public class LocalProcess
-
Undocumented
See moreDeclaration
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
See moreLocalProcessTerminalView
will set theTerminalView
‘sdelegate
property and capture and consume the messages. The messages that are most likely needed for consumer applications are reposted to theLocalProcessTerminalViewDelegate
inprocessDelegate
. If you override thedelegate
directly, you might inadvertently break the internal working ofLocalProcessTerminalView
. If you must change thedelegate
make sure that you proxy the values in your implementation to the values set after initializing this instanceDeclaration
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
See moreforkpty
API in the form offork(andExec:args:env:desiredWindowSize:
method,setWinSize
andavailableBytes
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
See moreTerminalDelegate
protocol that is provided in the constructor call.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 theTerminalView
and casting the result toTerminalAccessory
.This class surfaces some state that the terminal might want to poke at, you should at least support the following properties;
See morecontrolModifer
should be set if the control key is pressed -
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 ofTerminalView
.Call the
getTerminal
method to get a reference to the underlyingTerminal
that backs this view.Use the
See moreconfigureNativeColors()
to set the defaults colors for the view to match the OS defaults, otherwise, this uses its own set of defaults colors.Declaration
Swift