### Handterm Configuration File Example Source: https://github.com/1jehuang/handterm/blob/master/README.md Example TOML configuration defining style, window, scrollback, and performance parameters. ```toml [style] font_family = "JetBrainsMono Nerd Font Light" font_size = 11.0 background = "#000000" foreground = "#cdd6f4" cursor = "#f5e0dc" background_opacity = 0.9 [window] columns = 120 rows = 32 # Spawn position: "center" (default; centered on the primary monitor, extra # windows cascade), "auto" (OS decides), or [x, y] physical-pixel offsets # from the monitor origin. Wayland compositors ignore position hints. position = "center" [scrollback] lines = 10000 smooth = false smooth_speed = 3.0 scrollbar = true [performance] repaint_delay_ms = 5 sync_to_monitor = true ``` -------------------------------- ### Install macOS Prerequisites Source: https://github.com/1jehuang/handterm/blob/master/README.md Install required system libraries and fonts using Homebrew on macOS. ```bash brew install pkg-config freetype fontconfig # Recommended default font (matches the bundled config): brew install --cask font-jetbrains-mono-nerd-font ``` -------------------------------- ### Install handterm on Linux Source: https://github.com/1jehuang/handterm/blob/master/README.md Commands to install or build handterm from source on Linux systems with Wayland support. ```bash # From source cargo install --path . # Or build directly cargo build --release ./target/release/handterm ``` -------------------------------- ### Initialize Handterm Configuration Source: https://github.com/1jehuang/handterm/blob/master/README.md Generates the default configuration file at the standard location. ```bash handterm init-config ``` -------------------------------- ### Reproduce Performance Benchmarks Source: https://github.com/1jehuang/handterm/blob/master/README.md Commands to measure startup latency, input deduplication, memory footprint, and internal pipeline throughput. ```bash # Startup time (requires niri compositor) before=$(niri msg windows | grep -c "Window ID") start=$(date +%s%N) & pid=$! while [ $(niri msg windows | grep -c "Window ID") -eq $before ]; do sleep 0.002; done end=$(date +%s%N) echo "$(( (end - start) / 1000000 )) ms" kill $pid # Synthetic frontend input dedupe (GPU by default; uses socket + isolated runtime dir) ./scripts/test_input_dedupe.sh # Memory & pid=$! sleep 1 grep VmRSS /proc/$pid/status # Pipeline throughput handterm bench ``` -------------------------------- ### Handterm CLI Usage Commands Source: https://github.com/1jehuang/handterm/blob/master/OPTIMIZATION.md Demonstrates the available command-line flags for controlling server and standalone execution modes. ```bash handterm # Default: connect to server, or start one and connect handterm --standalone # Force standalone mode (no daemon, current behavior) handterm --server-only # Start server daemon without opening a window ``` -------------------------------- ### Build with CPU rendering only Source: https://github.com/1jehuang/handterm/blob/master/README.md Compile handterm with only the CPU rendering feature enabled. ```bash cargo build --release --features cpu --no-default-features ``` -------------------------------- ### Build handterm on macOS Source: https://github.com/1jehuang/handterm/blob/master/README.md Configure environment variables and build handterm on macOS using Homebrew-provided libraries. ```bash export PKG_CONFIG_PATH="$(brew --prefix freetype)/lib/pkgconfig:$(brew --prefix fontconfig)/lib/pkgconfig" cargo build --release ./target/release/handterm ``` -------------------------------- ### Build with GPU rendering only Source: https://github.com/1jehuang/handterm/blob/master/README.md Compile handterm with only the GPU rendering feature enabled. ```bash cargo build --release --features gpu --no-default-features ``` -------------------------------- ### Development Commands Source: https://github.com/1jehuang/handterm/blob/master/README.md Standard Cargo commands for checking, testing, and running the Handterm project. ```bash cargo check --workspace cargo test --workspace cargo run -- bench cargo run -- print-config ``` -------------------------------- ### Handterm Architecture Diagram Source: https://github.com/1jehuang/handterm/blob/master/README.md Visual representation of the single-process host architecture and shared resources. ```text Single-process host | +-- window #1 | PTY -> parser -> terminal -> grid -> renderer -> Wayland surface | +-- window #2 | PTY -> parser -> terminal -> grid -> renderer -> Wayland surface | +-- window #N PTY -> parser -> terminal -> grid -> renderer -> Wayland surface Shared across windows in the host: - event loop - IPC socket / control plane - CPU or GPU renderer runtime foundation - glyph/font resources per DPI - on the GPU path: shared `wgpu` instance / adapter / device / queue / pipeline cache ``` -------------------------------- ### Server Process Data Structures Source: https://github.com/1jehuang/handterm/blob/master/OPTIMIZATION.md Core structures for managing terminal windows and client connections in the server process. ```rust struct Server { font: GlyphAtlas, windows: HashMap, listener: UnixListener, clients: Vec, } struct WindowState { terminal: Terminal, pty: PtyChild, pty_buf: Vec, } ``` -------------------------------- ### Typeset LaTeX Math in Terminal Source: https://github.com/1jehuang/handterm/blob/master/README.md Render LaTeX math expressions directly into terminal cells using the handterm CLI helper. ```bash handterm latex '\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}' handterm latex '\begin{pmatrix}a & b \\ c & d\end{pmatrix}' ``` -------------------------------- ### Send Key Events via Host Control Source: https://github.com/1jehuang/handterm/blob/master/README.md Use the handterm CLI to send specific key events, including physical key mappings and modifier states, to the terminal instance. ```bash # Context menu / MENU key via host control handterm @ send-key-event '{"key":"menu","physical_key":"context_menu"}' # Keypad center (KP_BEGIN / numpad 5 in navigation mode) handterm @ send-key-event '{"key":"clear","physical_key":"numpad5"}' # Right shift press handterm @ send-key-event '{"key":"shift","physical_key":"shift_right","kind":"press","shift":true}' ``` -------------------------------- ### Handterm Source Layout Source: https://github.com/1jehuang/handterm/blob/master/README.md Directory structure of the Handterm project components. ```text handterm-common/ src/ grid.rs Cell storage / scrollback parser.rs VT parser protocol.rs window/terminal sync protocol types terminal.rs terminal state machine src/ app.rs CPU single-process host runtime gpu_app.rs GPU single-process host runtime gpu_runtime.rs shared/per-window GPU runtime pieces render.rs CPU renderer frontend.rs shared scheduling/input helpers pty.rs PTY spawn and I/O ipc.rs host IPC server ``` -------------------------------- ### Historical Workspace Structure Source: https://github.com/1jehuang/handterm/blob/master/OPTIMIZATION.md The original workspace layout used during the daemon era, which was later simplified to two crates. ```text handterm/ Cargo.toml (workspace root) handterm-server/ Cargo.toml (freetype, fontconfig, rustybuzz, nix) src/main.rs handterm-client/ Cargo.toml (wgpu, winit, bytemuck) src/main.rs handterm-common/ Cargo.toml (protocol types, cell types, grid types) src/lib.rs ``` -------------------------------- ### Define compact RenderCell structure Source: https://github.com/1jehuang/handterm/blob/master/OPTIMIZATION.md Reduces memory footprint for client-side rendering by packing cell data into 8 bytes. ```rust struct RenderCell { ch: u32, // codepoint fg_bg: u16, // palette index (not full RGB) attrs: u8, flags: u8, } ``` -------------------------------- ### Emit LaTeX Protocol Sequence Source: https://github.com/1jehuang/handterm/blob/master/README.md Directly emit the Handterm private APC sequence to render LaTeX math from within any application. ```bash printf '\033_L;%s\033\\' '\sum_{i=0}^{n} i^2' ``` -------------------------------- ### Define CellUpdate structure Source: https://github.com/1jehuang/handterm/blob/master/OPTIMIZATION.md Transmits only modified cells to minimize network traffic. ```rust CellUpdate { window_id: u32, cells: Vec<(u16, u16, RenderCell)>, // (row, col, cell) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.