### Basic Headless Terminal Setup Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/HeadlessUsage.md Create a HeadlessTerminal, start a process, and wait for its completion using a semaphore. ```swift import SwiftTerm let semaphore = DispatchSemaphore(value: 0) let headless = HeadlessTerminal( options: TerminalOptions(cols: 80, rows: 24) ) { exitCode in semaphore.signal() } headless.process.startProcess( executable: "/usr/bin/env", args: ["ls", "-la"] ) semaphore.wait() ``` -------------------------------- ### SSH Configuration Example Source: https://github.com/dodo-reach/hermes-desktop/blob/main/README.md Example of an SSH configuration entry in ~/.ssh/config file. This defines the HostName, User, and other parameters for a specific SSH alias. ```sshconfig Host hermes-home HostName vps.example.com User alex ``` -------------------------------- ### Headless Terminal for Scripting Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GettingStarted.md Use HeadlessTerminal to run a terminal emulator without a UI for scripting and programmatic inspection of terminal output. This example starts an 'ls -la' process and captures its output. ```swift import SwiftTerm let semaphore = DispatchSemaphore(value: 0) let headless = HeadlessTerminal(options: TerminalOptions.default) { exitCode in print("Process exited with code: \(exitCode ?? -1)") semaphore.signal() } headless.process.startProcess(executable: "/bin/ls", args: ["-la"]) semaphore.wait() let output = headless.terminal.getBufferAsData() print(String(data: output, encoding: .utf8) ?? "") ``` -------------------------------- ### Install Custom 256-Color Palette Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Customization.md Replace the default ANSI color palette with a custom set of 256 Color values. The array must contain exactly 256 colors. ```swift let terminal = terminalView.getTerminal() terminal.installPalette(colors: myCustomPalette) ``` -------------------------------- ### Get Environment Variables for SSH Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/SSHIntegration.md Use Terminal.getEnvironmentVariables() to construct an environment suitable for the remote shell. Pass the returned dictionary when opening the SSH channel. ```swift let env = Terminal.getEnvironmentVariables(termName: "xterm-256color", trueColor: true) // Pass env when opening the SSH channel ``` -------------------------------- ### Embed TerminalView in iOS Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GettingStarted.md Implement TerminalViewDelegate and wire up the send and feed methods for iOS integration. This setup is similar to the custom data source pattern on macOS. ```swift import SwiftTerm import UIKit class TerminalViewController: UIViewController, TerminalViewDelegate { var terminalView: TerminalView! override func viewDidLoad() { super.viewDidLoad() terminalView = TerminalView(frame: view.bounds) terminalView.terminalDelegate = self terminalView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(terminalView) } func send(source: TerminalView, data: ArraySlice) { // Forward to your SSH connection or other backend } func sizeChanged(source: TerminalView, newCols: Int, newRows: Int) {} func setTerminalTitle(source: TerminalView, title: String) {} func hostCurrentDirectoryUpdate(source: TerminalView, directory: String?) {} func scrolled(source: TerminalView, position: Double) {} func requestOpenLink(source: TerminalView, link: String, params: [String: String]) {} func clipboardCopy(source: TerminalView, content: Data) {} func rangeChanged(source: TerminalView, startY: Int, endY: Int) {} } ``` -------------------------------- ### Open Built App Source: https://github.com/dodo-reach/hermes-desktop/blob/main/README.md After building the app, use this command to open the generated application bundle. ```bash dist/HermesDesktop.app ``` -------------------------------- ### Creating a Terminal Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Initializes a new Terminal instance with a delegate and optional configuration options. ```APIDOC ## init(delegate: options:) ### Description Initializes a new Terminal instance. ### Parameters #### Parameters - **delegate** (TerminalDelegate) - The delegate to receive terminal events. - **options** (TerminalOptions?) - Optional configuration options for the terminal. ``` -------------------------------- ### Creating a Headless Terminal Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/HeadlessTerminal.md Initializes a new HeadlessTerminal instance. ```APIDOC ## init(queue: options: onEnd:) ### Description Initializes a new `HeadlessTerminal` instance. ### Parameters - **queue** (DispatchQueue) - The dispatch queue to use for terminal operations. - **options** (Terminal.Options) - Configuration options for the terminal. - **onEnd** ( ( (Int) -> Void)? ) - A closure to be called when the terminal process ends, receiving the exit status. ``` -------------------------------- ### Run Release Support Tests Source: https://github.com/dodo-reach/hermes-desktop/blob/main/README.md Execute the release support test suite for Hermes Desktop. ```bash ./scripts/run-tests.sh ``` -------------------------------- ### Run Local Release Verification Script Source: https://github.com/dodo-reach/hermes-desktop/blob/main/docs/distribution.md Execute the repository's verification script to replicate CI checks on a downloaded release zip and its manifest. ```bash ./scripts/verify-release.sh \ /path/to/HermesDesktop.app.zip \ /path/to/HermesDesktop.app.zip.manifest.json ``` -------------------------------- ### Connect using Host Details Source: https://github.com/dodo-reach/hermes-desktop/blob/main/README.md Use this command format to connect to a remote host by specifying the hostname, user, and port directly. This is an alternative to using SSH aliases. ```bash ssh alex@vps.example.com ``` -------------------------------- ### Build Hermes Desktop App Locally Source: https://github.com/dodo-reach/hermes-desktop/blob/main/docs/distribution.md Build the Hermes Desktop application bundle from the source code within the repository. This produces a local, ad-hoc signed, non-notarized app. ```bash ./scripts/build-macos-app.sh ``` -------------------------------- ### Create GitHub Releases Archive Source: https://github.com/dodo-reach/hermes-desktop/blob/main/README.md Package the application for GitHub Releases. ```bash ./scripts/package-github-release.sh ``` -------------------------------- ### Create Release Candidate Package with Version Source: https://github.com/dodo-reach/hermes-desktop/blob/main/README.md Package a release candidate with an explicitly stamped version number. ```bash HERMES_VERSION=1.2.3 ./scripts/package-github-release.sh ``` -------------------------------- ### Runtime Configuration Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/HeadlessTerminal.md Allows for runtime configuration of the terminal. ```APIDOC ## changeScrollback(_:) ### Description Changes the scrollback buffer size of the terminal. ### Parameters - **newSize** (Int) - The new desired size for the scrollback buffer. ``` -------------------------------- ### Display Image using timg with Kitty Output Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GraphicsSupport.md Use the `timg` utility with the `-pk` option to convert and display an image using the Kitty graphics protocol. ```bash timg -pk image.png ``` -------------------------------- ### Display Image using Kitty Graphics Protocol Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GraphicsSupport.md Employ the `kitten icat` command from the Kitty terminal emulator to render images using the Kitty graphics protocol. ```bash kitten icat image.png ``` -------------------------------- ### Resize and Layout Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Methods for resizing the terminal and managing its layout. ```APIDOC ## resize(cols:rows:) ### Description Resizes the terminal to the specified number of columns and rows. ### Parameters #### Parameters - **cols** (Int) - The new number of columns. - **rows** (Int) - The new number of rows. ``` ```APIDOC ## getDims() ### Description Returns the current dimensions (columns and rows) of the terminal. ``` ```APIDOC ## changeScrollback(_:) ### Description Changes the scrollback buffer size. ### Parameters #### Parameters - **size** (Int) - The new scrollback size. ``` ```APIDOC ## changeHistorySize(_:) ### Description Changes the history buffer size. ### Parameters #### Parameters - **size** (Int) - The new history size. ``` -------------------------------- ### Inspect App Bundle Signature Details Source: https://github.com/dodo-reach/hermes-desktop/blob/main/docs/distribution.md Obtain detailed information about the code signature of an application bundle, useful for deeper inspection. ```bash codesign -dv --verbose=4 /Applications/HermesDesktop.app ``` -------------------------------- ### Convert Image to Sixel Format Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GraphicsSupport.md Use the `img2sixel` command-line tool to convert an image file into the Sixel graphics format for display in compatible terminals. ```bash img2sixel image.png ``` -------------------------------- ### Verify Release Zip Checksum Source: https://github.com/dodo-reach/hermes-desktop/blob/main/docs/distribution.md Calculate the SHA-256 checksum of the downloaded release zip file to compare against the published checksum. ```bash shasum -a 256 HermesDesktop.app.zip ``` -------------------------------- ### Configuring Custom Terminal Size Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/HeadlessUsage.md Initialize HeadlessTerminal with custom dimensions and scrollback buffer size using TerminalOptions. ```swift let options = TerminalOptions(cols: 132, rows: 50, scrollback: 5000) let headless = HeadlessTerminal(options: options) { _ in } ``` -------------------------------- ### Titles Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Methods for setting the terminal window title and icon title. ```APIDOC ## setTitle(text:) ### Description Sets the terminal window title. ### Parameters #### Parameters - **text** (String) - The new window title. ``` ```APIDOC ## setIconTitle(text:) ### Description Sets the terminal window icon title. ### Parameters #### Parameters - **text** (String) - The new icon title. ``` -------------------------------- ### Enable Metal Rendering Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GPURendering.md Call `setUseMetal(_:)` after the view is added to a window to enable Metal rendering. This method can throw a `MetalError` if the GPU pipeline cannot be created. ```swift do { try terminalView.setUseMetal(true) } catch { print("Metal not available: \(error)") // The view continues using CoreGraphics — no action needed. } ``` -------------------------------- ### Environment Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Method for retrieving environment variables. ```APIDOC ## getEnvironmentVariables(termName:trueColor:) ### Description Retrieves environment variables relevant to the terminal. ### Parameters #### Parameters - **termName** (String) - The terminal name. - **trueColor** (Bool) - Whether to include true color information. ``` -------------------------------- ### Configure Terminal Options Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Customization.md Create a custom TerminalOptions struct to control engine-level settings like dimensions, scrollback, and cursor style. Pass this struct when initializing a Terminal or HeadlessTerminal. ```swift let options = TerminalOptions( cols: 120, rows: 40, scrollback: 10_000, tabStopWidth: 4, cursorStyle: .steadyBar, termName: "xterm-256color", ansi256PaletteStrategy: .base16Lab ) ``` -------------------------------- ### Configure Option Key as Meta Key Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Customization.md On macOS and iOS with external keyboards, set `optionAsMetaKey` to `true` to make the Option key send an ESC prefix instead of special characters. This is crucial for applications like Emacs. ```swift terminalView.optionAsMetaKey = true ``` -------------------------------- ### Recording a Terminal Session Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/HeadlessUsage.md Use the `termcast` command-line tool to record a terminal session to a .cast file. ```bash swift run termcast record session.cast swift run termcast record -c "top -l 5" top-demo.cast swift run termcast record --timeout 30 timed.cast ``` -------------------------------- ### Feeding Input Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Methods for feeding input data into the terminal emulator. ```APIDOC ## feed(byteArray:) ### Description Feeds a byte array into the terminal. ### Parameters #### Parameters - **byteArray** (Data) - The byte array to feed into the terminal. ``` ```APIDOC ## feed(text:) ### Description Feeds a string into the terminal. ### Parameters #### Parameters - **text** (String) - The text string to feed into the terminal. ``` ```APIDOC ## feed(buffer:) ### Description Feeds a buffer into the terminal. ### Parameters #### Parameters - **buffer** (Data) - The buffer to feed into the terminal. ``` ```APIDOC ## parse(buffer:) ### Description Parses a buffer, processing escape sequences and updating terminal state. ### Parameters #### Parameters - **buffer** (Data) - The buffer to parse. ``` -------------------------------- ### Focus Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Method for setting the terminal focus. ```APIDOC ## setTerminalFocus(_:) ### Description Sets the focus state of the terminal. ### Parameters #### Parameters - **focus** (Bool) - True to set focus, false to remove focus. ``` -------------------------------- ### Handle iTerm2 and Kitty Image Data Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GraphicsSupport.md Implement the `createImage` delegate method to process encoded image data (PNG, JPEG, GIF) and sizing instructions for iTerm2 and Kitty graphics protocols. ```swift func createImage(source: TerminalImageSource, data: Data, width: Int, height: Int, preserveAspectRatio: Bool) -> TerminalImage ``` -------------------------------- ### Playing Back a Terminal Session Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/HeadlessUsage.md Use the `termcast` command-line tool to play back a recorded terminal session from a .cast file. ```bash swift run termcast playback session.cast ``` -------------------------------- ### Providing a Custom Dispatch Queue Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/HeadlessUsage.md Specify a custom DispatchQueue for process I/O operations instead of the default private queue. ```swift let queue = DispatchQueue(label: "com.example.terminal") let headless = HeadlessTerminal(queue: queue, options: .default) { _ in } ``` -------------------------------- ### Customize Rendering Glyphs and Colors Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Customization.md Enable SwiftTerm's built-in box-drawing and block-element glyphs for potentially more accurate rendering. Optionally, use bright colors for bold text to achieve traditional terminal behavior. ```swift // Use SwiftTerm's built-in box-drawing and block-element glyphs // instead of the font's glyphs (often more accurate) terminalView.customBlockGlyphs = true terminalView.antiAliasCustomBlockGlyphs = true // Use bright colors for bold text (traditional terminal behavior) terminalView.useBrightColors = true ``` -------------------------------- ### Set Initial Cursor Style Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Customization.md Define the initial cursor style using TerminalOptions. This can be overridden by remote applications via escape sequences. ```swift let options = TerminalOptions(cursorStyle: .steadyBar) ``` -------------------------------- ### Housekeeping Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Internal method for garbage collection. ```APIDOC ## garbageCollectPayload() ### Description Performs garbage collection on internal payload data. ``` -------------------------------- ### Enable GPU-Accelerated Metal Rendering Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Customization.md Switch to a Metal-based rendering path for GPU acceleration on macOS, iOS, and visionOS. Configure buffering strategies and check if Metal rendering is active. ```swift // Enable Metal rendering try terminalView.setUseMetal(true) // Choose a buffering strategy terminalView.metalBufferingMode = .perRowPersistent // default terminalView.metalBufferingMode = .perFrameAggregated // for full-screen TUIs // Check current renderer if terminalView.isUsingMetalRenderer { print("GPU rendering active") } ``` -------------------------------- ### Connect to Hermes Host via SSH Source: https://github.com/dodo-reach/hermes-desktop/blob/main/README.md Verify SSH access to your Hermes host. This command should work without interactive prompts for password or host key confirmation. ```bash ssh your-host ``` -------------------------------- ### Basic Body Styling for Hermes Desktop Source: https://github.com/dodo-reach/hermes-desktop/blob/main/site/index.html Applies base styles to the HTML body, including margin, background gradient, text color, font family, and line height. Ensures a consistent look and feel. ```css body { margin: 0; background: linear-gradient(180deg, rgba(239, 64, 35, 0.06), transparent 16rem), var(--bg); color: var(--ink); font-family: var(--font-sans); line-height: 1.62; font-variant-numeric: tabular-nums; } ``` -------------------------------- ### Handle Sixel Image Data Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GraphicsSupport.md Implement the `createImageFromBitmap` delegate method in your custom front-end to receive raw RGBA pixel data from Sixel streams and render it as a `TerminalImage`. ```swift func createImageFromBitmap(source: TerminalImageSource, bytes: UnsafeRawPointer, width: Int, height: Int) -> TerminalImage ``` -------------------------------- ### Connect using SSH alias Source: https://github.com/dodo-reach/hermes-desktop/blob/main/README.md Use this command to connect to a remote host via SSH using a pre-configured alias. Ensure the alias is defined in your SSH config file. ```bash ssh hermes-home ``` -------------------------------- ### Colors Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Methods for managing terminal color palettes. ```APIDOC ## installPalette(colors:) ### Description Installs a custom color palette for the terminal. ### Parameters #### Parameters - **colors** (Palette) - The palette to install. ``` -------------------------------- ### Embed Local Terminal View on macOS Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GettingStarted.md Use LocalProcessTerminalView to connect the terminal to a local Unix process. It launches /bin/bash by default. You can customize the executable and arguments using startProcess(executable:args:environment:). ```swift import SwiftTerm import AppKit class ViewController: NSViewController, LocalProcessTerminalViewDelegate { var terminalView: LocalProcessTerminalView! override func viewDidLoad() { super.viewDidLoad() terminalView = LocalProcessTerminalView(frame: view.bounds) terminalView.processDelegate = self terminalView.autoresizingMask = [.width, .height] view.addSubview(terminalView) terminalView.startProcess() } func sizeChanged(source: LocalProcessTerminalView, newCols: Int, newRows: Int) {} func setTerminalTitle(source: LocalProcessTerminalView, title: String) { view.window?.title = title } func hostCurrentDirectoryUpdate(source: TerminalView, directory: String?) {} func processTerminated(source: TerminalView, exitCode: Int32?) { // Handle process exit } } ``` -------------------------------- ### Define CSS Variables for Hermes Desktop Source: https://github.com/dodo-reach/hermes-desktop/blob/main/site/index.html Sets up custom CSS properties for theming Hermes Desktop, including colors, fonts, and spacing. These variables are used throughout the application's styling. ```css :root { --bg: #f3efe7; --paper: #ece5d9; --ink: #111111; --muted: #5f5a54; --line: #111111; --accent: #ef4023; --accent-ink: #fff8f1; --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; --font-mono: "Geist Mono", "SF Mono", "Cascadia Code", monospace; } ``` -------------------------------- ### Verify App Bundle Integrity Source: https://github.com/dodo-reach/hermes-desktop/blob/main/docs/distribution.md Perform a deep and strict verification of the code signature for an extracted application bundle. ```bash codesign --verify --deep --strict /Applications/HermesDesktop.app ``` -------------------------------- ### Check Metal Renderer Status Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GPURendering.md Use `isUsingMetalRenderer` to determine the current rendering path. ```swift if terminalView.isUsingMetalRenderer { print("Using Metal") } ``` -------------------------------- ### Display Image using iTerm2 Protocol Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GraphicsSupport.md Utilize the `imgcat` script, commonly associated with iTerm2, to display images directly in the terminal using its inline image protocol. ```bash imgcat image.png ``` -------------------------------- ### Terminal and Process Access Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/HeadlessTerminal.md Provides access to the underlying terminal and the running process. ```APIDOC ## terminal ### Description Access the underlying terminal engine to read buffer contents and inspect terminal state. ### Type `Terminal` ``` ```APIDOC ## process ### Description Access the running subprocess to control its execution. ### Type `LocalProcess` ``` -------------------------------- ### Set Selection and Cursor Colors Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Customization.md Customize the background color for selected text and the color of the terminal cursor. Optionally set the text color that appears under the cursor. ```swift terminalView.selectedTextBackgroundColor = NSColor.systemBlue.withAlphaComponent(0.3) ``` ```swift terminalView.caretColor = NSColor.systemGreen ``` ```swift terminalView.caretTextColor = NSColor.black // optional: text color under cursor ``` -------------------------------- ### Sending Input to the Process Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/HeadlessUsage.md Send string data or raw bytes, such as control characters, to the running process through the terminal. ```swift // Send a string headless.send("hello\n") // Send raw bytes (e.g., control characters) headless.send(data: [0x03][...]) // Ctrl-C ``` -------------------------------- ### TerminalOptions Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/TerminalOptions.md Configuration options for the terminal engine. ```APIDOC ## TerminalOptions Configuration options for the terminal engine. ### Overview `TerminalOptions` controls the initial dimensions, scrollback size, cursor style, and feature flags for a ``Terminal`` instance. Pass an options struct when constructing a terminal or a ``HeadlessTerminal``. Use ``TerminalOptions/default`` for sensible defaults (80x25, 500-line scrollback, blinking block cursor). For a guide on customization, see . ## Topics ### Getting Default Options - ``default`` ### Terminal Dimensions - ``cols`` - ``rows`` ### Scrollback - ``scrollback`` ### Appearance - ``cursorStyle`` - ``tabStopWidth`` ### Terminal Identity - ``termName`` ### Behavior - ``convertEol`` - ``screenReaderMode`` ### Graphics - ``enableSixelReported`` - ``kittyImageCacheLimitBytes`` ### Colors - ``ansi256PaletteStrategy`` ``` -------------------------------- ### Diagnose Remote Service Issues Source: https://github.com/dodo-reach/hermes-desktop/blob/main/docs/releases/RELEASE-v0.9.0.md Run these commands on the SSH target to diagnose issues with Python services or the hermes CLI. Ensure python3 and hermes are in the non-interactive PATH. ```bash command -v python3 python3 --version command -v hermes hermes --version ``` -------------------------------- ### Control Link Reporting Mode Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Customization.md Use `linkReporting` to specify how links are discovered: `.none` to disable, `.explicit` for OSC 8 links only, or `.implicit` for explicit links with an implicit fallback. ```swift terminalView.linkReporting = .none // Disable link tracking ``` ```swift terminalView.linkReporting = .explicit // Track OSC 8 links only ``` ```swift terminalView.linkReporting = .implicit // Default: explicit first, then implicit fallback ``` -------------------------------- ### Mouse Events Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Methods for handling and encoding mouse events. ```APIDOC ## encodeButton(button:release:shift:meta:control:) ### Description Encodes mouse button state into a format suitable for terminal events. ### Parameters #### Parameters - **button** (Int) - The mouse button code. - **release** (Bool) - True if the button is being released. - **shift** (Bool) - True if the Shift key is pressed. - **meta** (Bool) - True if the Meta key is pressed. - **control** (Bool) - True if the Control key is pressed. ``` ```APIDOC ## sendEvent(buttonFlags:x:y:) ### Description Sends a mouse event with button flags and coordinates. ### Parameters #### Parameters - **buttonFlags** (Int) - Flags indicating the mouse button state. - **x** (Int) - The X coordinate of the mouse event. - **y** (Int) - The Y coordinate of the mouse event. ``` ```APIDOC ## sendEvent(buttonFlags:x:y:pixelX:pixelY:) ### Description Sends a mouse event with button flags, coordinates, and pixel coordinates. ### Parameters #### Parameters - **buttonFlags** (Int) - Flags indicating the mouse button state. - **x** (Int) - The X coordinate of the mouse event. - **y** (Int) - The Y coordinate of the mouse event. - **pixelX** (Int) - The X pixel coordinate. - **pixelY** (Int) - The Y pixel coordinate. ``` ```APIDOC ## sendMotion(buttonFlags:x:y:pixelX:pixelY:) ### Description Sends a mouse motion event with button flags, coordinates, and pixel coordinates. ### Parameters #### Parameters - **buttonFlags** (Int) - Flags indicating the mouse button state. - **x** (Int) - The X coordinate of the mouse event. - **y** (Int) - The Y coordinate of the mouse event. - **pixelX** (Int) - The X pixel coordinate. - **pixelY** (Int) - The Y pixel coordinate. ``` -------------------------------- ### Parser Extension Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Methods for interacting with the terminal's parser and registering handlers. ```APIDOC ## registerOscHandler(code:handler:) ### Description Registers a handler for Operating System Command (OSC) sequences. ### Parameters #### Parameters - **code** (Int) - The OSC code to handle. - **handler** (OscHandler) - The handler function to execute. ``` -------------------------------- ### Sending Responses Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Methods for sending responses from the terminal. ```APIDOC ## sendResponse(text:) ### Description Sends a text response from the terminal. ### Parameters #### Parameters - **text** (String) - The text response to send. ``` ```APIDOC ## sendResponse(_:) ### Description Sends a data response from the terminal. ### Parameters #### Parameters - **data** (Data) - The data response to send. ``` -------------------------------- ### Shell Container Styling Source: https://github.com/dodo-reach/hermes-desktop/blob/main/site/index.html Styles the main content container to center it and limit its width, ensuring responsiveness across different screen sizes. Uses viewport width and a maximum width. ```css .shell { width: min(1200px, calc(100vw - 2rem)); margin: 0 auto; } ``` -------------------------------- ### Implement Custom Data Source for Terminal on macOS Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GettingStarted.md Use TerminalView directly and implement TerminalViewDelegate to connect to custom data sources like SSH or network sockets. Forward user input using send(source:data:) and feed incoming data with feed(byteArray:). ```swift class MyTerminalController: NSViewController, TerminalViewDelegate { var terminalView: TerminalView! override func viewDidLoad() { super.viewDidLoad() terminalView = TerminalView(frame: view.bounds) terminalView.terminalDelegate = self view.addSubview(terminalView) } func send(source: TerminalView, data: ArraySlice) { // Send data to your backend (SSH channel, socket, etc.) } // Feed incoming data from the backend into the terminal: func onDataReceived(_ data: ArraySlice) { terminalView.feed(byteArray: data) } func sizeChanged(source: TerminalView, newCols: Int, newRows: Int) {} func setTerminalTitle(source: TerminalView, title: String) {} func hostCurrentDirectoryUpdate(source: TerminalView, directory: String?) {} func scrolled(source: TerminalView, position: Double) {} func requestOpenLink(source: TerminalView, link: String, params: [String: String]) {} func clipboardCopy(source: TerminalView, content: Data) {} func rangeChanged(source: TerminalView, startY: Int, endY: Int) {} } ``` -------------------------------- ### Display Updates Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Methods for managing display updates and refresh operations. ```APIDOC ## refresh(startRow:endRow:) ### Description Refreshes a specific range of rows on the display. ### Parameters #### Parameters - **startRow** (Int) - The starting row for the refresh. - **endRow** (Int) - The ending row for the refresh. ``` ```APIDOC ## updateFullScreen() ### Description Triggers a full-screen update of the terminal display. ``` ```APIDOC ## getUpdateRange() ### Description Returns the range of rows that require updating. ``` ```APIDOC ## getScrollInvariantUpdateRange() ### Description Returns the update range, considering scroll-invariant content. ``` ```APIDOC ## clearUpdateRange() ### Description Clears the update range, indicating that all changes have been processed. ``` -------------------------------- ### Sending Data Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/HeadlessTerminal.md Methods for sending data to the terminal process. ```APIDOC ## send(data:) ### Description Sends raw data to the terminal process. ### Parameters - **data** (Data) - The data to send. ``` ```APIDOC ## send(_:) ### Description Sends a string to the terminal process. ### Parameters - **string** (String) - The string to send. ``` -------------------------------- ### Hero Section Layout Source: https://github.com/dodo-reach/hermes-desktop/blob/main/site/index.html Defines the grid layout for the hero section, positioning the main content and a side panel. Uses a two-column structure with a defined gap. ```css .hero { padding: 3rem 0 1.5rem; display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 1.2rem; } ``` -------------------------------- ### Cursor Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Methods for controlling the terminal cursor. ```APIDOC ## getCursorLocation() ### Description Returns the current cursor location (column and row). ``` ```APIDOC ## setCursorStyle(_:) ### Description Sets the cursor style. ### Parameters #### Parameters - **style** (CursorStyle) - The desired cursor style. ``` ```APIDOC ## showCursor() ### Description Shows the terminal cursor. ``` ```APIDOC ## hideCursor() ### Description Hides the terminal cursor. ``` -------------------------------- ### Programmatically Control Terminal Search Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Customization.md Drive the built-in find bar programmatically or supply your own search UI using TerminalView's public helpers. This allows for custom search interactions and options like case sensitivity. ```swift terminalView.findNext("term") terminalView.findPrevious("term", options: SearchOptions(caseSensitive: true)) terminalView.clearSearch() ``` -------------------------------- ### Sticky Topbar Styling Source: https://github.com/dodo-reach/hermes-desktop/blob/main/site/index.html Implements a sticky top navigation bar that remains visible at the top of the viewport. It includes a background with a blur effect and a bottom border. ```css .topbar { position: sticky; top: 0; z-index: 10; backdrop-filter: blur(8px); background: rgba(243, 239, 231, 0.86); border-bottom: 3px solid var(--line); } ``` -------------------------------- ### Kicker and Micro Text Styling Source: https://github.com/dodo-reach/hermes-desktop/blob/main/site/index.html Defines styles for small, uppercase text elements like 'kicker' and 'micro' tags, using a monospace font and specific letter spacing. The 'kicker' has an accent color. ```css .kicker, .micro { font-family: var(--font-mono); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.08em; } .kicker { color: #ff9d8d; } ``` -------------------------------- ### Configure Backspace Behavior Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Customization.md Toggle `backspaceSendsControlH` to `true` if the system expects the Backspace key to send `Control-H` (0x08) instead of DEL (0x7f). ```swift terminalView.backspaceSendsControlH = true ``` -------------------------------- ### Configure Metal Buffering Mode Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/GPURendering.md Set the `metalBufferingMode` property to control how the renderer builds and caches GPU buffers each frame. The default is `.perRowPersistent`. ```swift terminalView.metalBufferingMode = .perFrameAggregated ``` -------------------------------- ### Terminal Text Color Classes Source: https://github.com/dodo-reach/hermes-desktop/blob/main/site/index.html Defines specific color styles for different types of terminal output: commands, ready status, and reloading messages. Aids in visually distinguishing output types. ```css .terminal-command { color: #ff9d8d; } .terminal-ready { color: #f2b84b; } .terminal-reloading { color: #9f988f; } ``` -------------------------------- ### Heading Styles (H1, H2, H3) Source: https://github.com/dodo-reach/hermes-desktop/blob/main/site/index.html Applies impactful styling to headings, using a bold, uppercase font with a condensed appearance and minimal line height. Designed for strong visual hierarchy. ```css h1, h2, h3 { margin: 0; font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif; font-weight: 900; text-transform: uppercase; line-height: 0.9; letter-spacing: 0.02em; } h1 { font-size: clamp(3.8rem, 10vw, 7.6rem); margin-top: 1rem; } ``` -------------------------------- ### Hero Action Buttons Layout Source: https://github.com/dodo-reach/hermes-desktop/blob/main/site/index.html Styles the container for action buttons in the hero section, using flexbox to arrange them horizontally with a gap. Allows for responsive wrapping. ```css .hero-actions { margin-top: 1.6rem; display: flex; gap: 1rem; flex-wrap: wrap; } ``` -------------------------------- ### Section Head Layout Source: https://github.com/dodo-reach/hermes-desktop/blob/main/site/index.html Styles the header area for sections, using CSS Grid to create a two-column layout with a gap. Ensures alignment and consistent padding. ```css .section-head { display: grid; grid-template-columns: 0.7fr 1.3fr; gap: 1.2rem; align-items: stretch; margin-bottom: 1.2rem; } .section-head > * { padding: 1.3rem; } ``` -------------------------------- ### Reading Terminal Output as Text Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/HeadlessUsage.md Extract the entire terminal buffer as UTF-8 encoded text after a process has finished. ```swift let data = headless.terminal.getBufferAsData() let text = String(data: data, encoding: .utf8) ?? "" ``` -------------------------------- ### SSH Data Flow Pattern Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/SSHIntegration.md Implement TerminalViewDelegate.send() to forward user input to the SSH channel. When data arrives from SSH, call TerminalView.feed() to display it. Notify the SSH channel of terminal size changes via sizeChanged(). ```swift func send(source: TerminalView, data: ArraySlice) { sshChannel.write(data) } sshChannel.onData { data in DispatchQueue.main.async { self.terminalView.feed(byteArray: data) } } func sizeChanged(source: TerminalView, newCols: Int, newRows: Int) { sshChannel.requestPtyResize(cols: newCols, rows: newRows) } ``` -------------------------------- ### Hero Copy Paragraph Styling Source: https://github.com/dodo-reach/hermes-desktop/blob/main/site/index.html Styles paragraphs within the hero copy section, setting margins, maximum width, and text color. Aims for readability and complements the hero's design. ```css .hero-copy p { margin: 1.3rem 0 0; max-width: 42rem; font-size: 1.05rem; color: #efe4d7; } ``` -------------------------------- ### Terminal State Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Methods for managing and resetting the terminal's state. ```APIDOC ## setup(isReset:) ### Description Sets up the terminal, optionally performing a reset. ### Parameters #### Parameters - **isReset** (Bool) - Whether to perform a reset during setup. ``` ```APIDOC ## softReset() ### Description Performs a soft reset of the terminal. ``` ```APIDOC ## resetToInitialState() ### Description Resets the terminal to its initial state. ``` ```APIDOC ## resetNormalBuffer() ### Description Resets the normal buffer of the terminal. ``` -------------------------------- ### Scrolling Source: https://github.com/dodo-reach/hermes-desktop/blob/main/Vendor/SwiftTerm/Sources/SwiftTerm/Documentation.docc/Extensions/Terminal.md Methods related to terminal scrolling. ```APIDOC ## scroll(isWrapped:) ### Description Performs a scroll operation. ### Parameters #### Parameters - **isWrapped** (Bool) - Indicates if the scroll should wrap. ``` ```APIDOC ## emitLineFeed() ### Description Emits a line feed character, causing the terminal to scroll if necessary. ``` ```APIDOC ## getTopVisibleRow() ### Description Returns the row number of the top visible line in the terminal. ``` -------------------------------- ### Card, Quote, and Panel Styling Source: https://github.com/dodo-reach/hermes-desktop/blob/main/site/index.html Applies consistent styling to various content elements like hero panels, cards, quotes, and footer boxes. Features a border, background, and a prominent shadow effect. ```css .hero-panel, .card, .quote, .footer-box { border: 3px solid var(--line); background: var(--paper); box-shadow: 10px 10px 0 var(--line); } ```