Text Selection
On iOS, UITerminalView selects text inline by default: it paints a selection overlay over the terminal cells and presents the native edit menu. Mac Catalyst uses pointer selection instead.
Gestures
- Long press (0.7 seconds) opens the edit menu.
- Double tap selects a word; triple tap selects a row.
- Select on whitespace selects the nearest visible row's text, excluding surrounding whitespace. Both handles can then adjust the selection character by character.
- A single tap clears a selection or closes the menu; otherwise it clicks the terminal and toggles the software keyboard.
- With a selection active, one finger drags its handles or extends it; two fingers scroll local history.
Menus
Override touchMenuItems(for:) and touchSelectionMenuItems(for:) in a TerminalView subclass to localize, reorder or extend the menu. The default actions carry the identifiers terminal.copy, terminal.paste, terminal.select and terminal.selectAll.
final class HostTerminalView: TerminalView {
override func touchSelectionMenuItems(for context: TerminalTouchSelectionMenuContext) -> [UIMenuElement] {
super.touchSelectionMenuItems(for: context) + [
UIAction(title: "Share") { _ in share(context.selectedText) },
]
}
}
Opting out
Set usesInlineTextSelection = false to turn touch selection off. A long press then does nothing and a tap only clicks and toggles the keyboard.
The long-press sheet API (TerminalTextSelectionRequest, TerminalSurfaceTextSelectionRequestDelegate, TerminalViewState.onTextSelectionRequest) has been removed.