Zig parses config values (cli/args.zig, Config.zig field parsers, config/string.zig) from raw byte slices, and each field type decides whether it requires UTF-8 (InvalidValue otherwise) or stores bytes. The port escape-encoded raw bytes into Strings at the line reader and let fields parse the escaped text, so fields could observe encoding artifacts; successive audits kept finding such leaks (RV5-RV8). Field parsers now receive the original bytes: text fields validate UTF-8 where Zig does, byte/path fields store bytes (EncodedOs/OsString). This resolves all 9 RV8 findings (docs/rewrite/notes/review-rv8-codex.md), each with a regression test: Windows path conversion fails with BadPathName instead of substituting U+FFFD; Windows process launch uses strict UTF-8 like Zig's Command; the WTF-8 decoder accepts paired- surrogate encodings like Zig; literal U+FDD0 Unicode key triggers; selection-word-chars and clipboard-codepoint-map reject invalid UTF-8; font style / codepoint-map family names use original bytes; C title actions forward bytes; D-Bus new-window/Flatpak conversions match Zig. Design, sweep and validation: docs/rewrite/notes/final-bytes-refactor.md. Also moves the bundled iTerm2-Color-Schemes license out of resources/themes/ so +list-themes no longer lists it as a theme (output is now byte-identical to Ghostty 1.3.1). Done by Codex (gpt-6-astra), reviewed and verified by the orchestrator. Test Plan: - cargo test --workspace --no-fail-fast (3428 passed, exit 0) - just check-macos (both), just check-windows, just check-wasm - +show-config --default --docs, +list-keybinds, +list-actions --docs, +list-themes --plain compared with /usr/bin/ghostty
65 lines
1.7 KiB
Rust
65 lines
1.7 KiB
Rust
//! `+list-actions` (ZIG/src/cli/list_actions.zig).
|
|
|
|
use std::io::Write;
|
|
|
|
use ghostty_config::config_struct;
|
|
|
|
use crate::error::Error;
|
|
|
|
config_struct! {
|
|
pub struct Options {
|
|
/// If `true`, print out documentation about the action associated with the
|
|
/// keybinds.
|
|
"docs" => docs: bool = false,
|
|
}
|
|
}
|
|
cli_options!(Options, help);
|
|
|
|
/// The `list-actions` command is used to list all the available keybind
|
|
/// actions for Ghostty. These are distinct from the CLI Actions which can
|
|
/// be listed via `+help`
|
|
///
|
|
/// Flags:
|
|
///
|
|
/// * `--docs`: will print out the documentation for each action.
|
|
pub fn run(args: &[impl AsRef<[u8]>]) -> Result<u8, Error> {
|
|
let mut opts = Options::default();
|
|
crate::parse_options(&mut opts, args)?;
|
|
|
|
let out = generate_plaintext(opts.docs);
|
|
let mut stdout = std::io::stdout().lock();
|
|
stdout.write_all(out.as_bytes())?;
|
|
stdout.flush()?;
|
|
Ok(0)
|
|
}
|
|
|
|
/// `helpgen_actions.generate(.plaintext, show_docs)`.
|
|
#[must_use]
|
|
pub fn generate_plaintext(show_docs: bool) -> String {
|
|
ghostty_input::helpgen_actions::generate_string(
|
|
ghostty_input::helpgen_actions::Format::Plaintext,
|
|
show_docs,
|
|
)
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
#![allow(clippy::unwrap_used)]
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn names_only() {
|
|
let s = generate_plaintext(false);
|
|
assert!(s.starts_with("ignore\nunbind\ncsi\n"));
|
|
assert!(!s.contains(':'));
|
|
}
|
|
|
|
#[test]
|
|
fn docs_have_no_stray_blank_lines_between_actions() {
|
|
let s = generate_plaintext(true);
|
|
assert!(s.starts_with("\nignore:\n Ignore this key combination.\n"));
|
|
assert!(s.contains(" respectively.\n\njump_to_prompt:\n"));
|
|
assert!(s.ends_with('\n'));
|
|
}
|
|
}
|