SwingTerminal
Reusable Swing terminal component.
The component consumes published render-cache snapshots from a TerminalSession and paints terminal rows without knowing which transport produced the bytes. Hosts own session creation, process lifecycle, and connector choice outside this component. One controlling view per session is supported: settings, grid dimensions, and the published viewport belong to the session. Binding multiple components does not create independently configured or independently scrolling views.
Component state belongs to the Swing Event Dispatch Thread (EDT). Access it on the EDT unless a method explicitly documents another threading contract. Snapshot access and dispatch to the EDT are specified by each public method.
Component or font/settings changes that resize the bound session's grid clear selection and stop selection dragging. Selection uses physical cell coordinates; unchanged grid dimensions preserve it.
After closure, the view preserves the final grid, active buffer, palette, and selection. Width changes clip columns without reflow. Height changes show a bottom-anchored window over retained rows. Scrolling includes grid rows hidden above a shorter view. Font changes affect only presentation. No transport work or session restart occurs.
A focused terminal paints the application's cursor shape and blink state. Without keyboard focus blocks become steady outlines; bars and underlines stay steady, preserving application cursor visibility and viewport clipping. Focus never changes the session's cursor style.
Parameters
provider for immutable settings snapshots.
host-provided non-render services.
Constructors
Properties
Whether a configured suggestion provider is available. Read on the EDT.
Immutable search state, safe to observe from any thread. UI collectors must use the EDT and cancel collection when their view closes. Counts describe the last completed pass; TerminalSearchState.isSearching marks pending work. Clearing or unbinding cancels obsolete work; disposing cancels the worker.
Functions
Registers a synchronous EDT observer without an initial callback.
Registers an EDT callback for automatic-suggestion eligibility changes.
Registers an EDT callback for shell-bound input invalidation.
Captures the bound session's authoritative command line on the EDT, without mounting a popup.
Captures one command-line editing capability before asynchronous provider work.
Binds rendering and input to the host-owned session.
Requests a foreground-program screen clear/redraw.
Clears the current terminal-buffer search query and highlights.
Clears selection and stops mouse dragging on the EDT.
Returns all currently retained output for recordId.
Copies a displayed cell's visible bounds into caller-owned storage on the EDT.
Copies the displayed cell under component-local Swing pixels x, y into caller-owned destination on the EDT.
Copies all retained output for recordId through the host clipboard service.
Copies captured command text for recordId through the host clipboard service.
Copies the current terminal text selection to the host clipboard.
Writes host-approved text to the configured clipboard service.
Creates a range in the current binding and layout without changing selection.
Returns the current search result snapshot.
Returns the current visible cell selection, or null when nothing is selected. Linear selection columns are logical; block selection columns are visual, as defined by CellSelection.
Returns the complete retained selection on the EDT, or null.
Returns the current shell suggestion popup state.
Hides the shell suggestion popup.
Returns whether automatic suggestions are enabled at the live viewport.
Pastes text from the host clipboard into the active terminal session.
Returns the component size in pixels for the requested grid and screen.
Mounts the standard embedded presentation for an already captured interaction on the EDT. Hosts using detached or native UI can consume the interaction directly instead. Placement belongs to this adapter and is independent of provider request data.
Invalidates automatic request deduplication after host ranking context changes. Call on the EDT. The next eligible automatic request runs after the normal debounce interval.
Applies changed settings, rebuilding geometry only when its inputs change.
Removes a selection observer on the EDT.
Removes a callback previously registered with addShellSuggestionEligibilityListener.
Removes a callback previously registered with addShellSuggestionInvalidationListener.
Queries and presents the bound session's active command line using the configured provider.
Opens a source on the EDT and collects it off the EDT into an existing interaction. This does not mount UI. Its request-specific observer is captured before collection. Closing the interaction cancels collection; final visible results survive stream completion. Each interaction accepts one provider collection. Combine independent sources in the provider.
Captures a host command line, mounts the standard popup, and queries the configured provider. Calls on the EDT take effect immediately; other calls dispatch asynchronously. Automatic requests respect the automatic-popup setting; explicit requests respect the master switch.
Schedules the current visible cell and pixel dimensions for the bound session.
Moves the viewport to scrollbackOffset terminal rows above live output.
Returns to the live terminal viewport.
Scrolls to the nearest next shell command.
Scrolls to the nearest previous shell command.
Scrolls to an absolute scrollback offset.
Applies a signed scrollback delta in presentation slots.
Selects command output for recordId.
Returns the complete retained selection's text on the EDT, or null when unavailable.
Selects the next search result when a search query is active. While searching, navigates the last completed pass; does nothing when no results are available.
Selects the previous search result when a search query is active. While searching, navigates the last completed pass; does nothing when no results are available.
Applies policy after previously accepted view settings and geometry changes.
Configures whether terminal-buffer search is case-sensitive.
Enables Java regular expressions. Disabled by default; changing it restarts the current search. Patterns match one logical line at a time, including soft wraps, with trailing ASCII spaces trimmed. Empty matches are ignored. Invalid patterns are reported through searchState. Matching runs off the EDT and is cancellable. This setting survives clearSearch.
Requires word boundaries around matches. Disabled by default; changing it restarts the current search. Unicode letters, digits, combining marks, connector punctuation and join controls are word characters. Applies to both literal and regex searches; this setting survives clearSearch.
Sets or restores a complete range on the EDT.
Selects provider diagnostics for this view on the EDT; null restores logging.
Installs a host-owned provider or disables configured suggestions with null. Call on the EDT, before or after binding. Replacement cancels existing requests without closing either provider. The provider survives unbinding and rebinding; host metadata must describe the current session when SwingShellSuggestionProvider.open captures it. Automatic observation runs only while a session, provider or custom target, and the automatic-suggestion setting are available. Explicit custom interactions remain independent.
Routes automatic captured interactions to a host-owned surface; null selects embedded presentation. Call on the EDT. Replacement cancels pending requests and hides the old surface. The host owns target resources. Explicit interaction and presentation methods are unaffected.
Triggers this component's visual bell indicator.
Returns the latest presentation scrollback viewport snapshot.
Returns the session grid size for this component's current bounds. Narrow bounds retain at least two columns and one row; painting clips to the component.