refactor: resolve cross-crate integration TODOs and resources discovery
Cleanup pass over items collected in docs/rewrite/INTEGRATION_TODO.md: - OSC 133 printf-q / percent decoders live once in ghostty_vt::string_encoding; ghostty-os re-exports them. - CursorStyle and clipboard codepoint map entries have one definition (ghostty-terminal); ghostty-config now depends on ghostty-terminal. - ActionKey::docs() trailing blank lines fixed at the source; cli's workaround removed (+list-actions --docs still byte-identical). - x11_color exposes names in original case; cli no longer re-parses rgb.txt. - One cgroup scope wait loop (ghostty_os::cgroup::wait_for_scope). - Flatpak passwd lookup implemented in ghostty-os via a local pty. - +version shows the rustc version captured at build time. Resources: dev builds find <workspace>/resources automatically (keeping Ghostty's sentinel-file detection and GHOSTTY_RESOURCES_DIR); scripts/gen-terminfo.sh (just terminfo) regenerates the compiled terminfo; `just install [PREFIX]` installs binary, share/ghostty, terminfo, desktop/D-Bus/systemd/metainfo files and icons. Test Plan: - cargo test for vt, os, config, input, cli - diff `+list-keybinds`, `+list-actions --docs`, `+show-config --default` against /usr/bin/ghostty
This commit is contained in:
1 parent
062c643ea8
commit
7868e56273
24 files changed
+656
-513
No files matched your search
@@ -11,6 +11,7 @@ ghostty-config.workspace = true
|
||||
ghostty-font.workspace = true
|
||||
ghostty-input.workspace = true
|
||||
ghostty-os.workspace = true
|
||||
ghostty-vt.workspace = true
|
||||
log = "0.4.34"
|
||||
ratatui = "0.30.2"
|
||||
thiserror = "2.0.21"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//! Captures the compiler version for `+version` (Zig: `builtin.zig_version_string`).
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-env-changed=RUSTC");
|
||||
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
|
||||
let version = Command::new(rustc)
|
||||
.arg("--version")
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|o| String::from_utf8(o.stdout).ok())
|
||||
// "rustc 1.99.0 (b940084d7 2026-09-28)" -> "1.99.0"
|
||||
.and_then(|s| s.split_whitespace().nth(1).map(str::to_owned))
|
||||
.unwrap_or_else(|| "unknown".into());
|
||||
println!("cargo:rustc-env=GHOSTTY_RUSTC_VERSION={version}");
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
use std::io::Write;
|
||||
|
||||
use ghostty_config::config_struct;
|
||||
use ghostty_input::binding::ActionKey;
|
||||
|
||||
use crate::error::Error;
|
||||
|
||||
@@ -35,44 +34,12 @@ pub fn run(args: &[String]) -> Result<u8, Error> {
|
||||
}
|
||||
|
||||
/// `helpgen_actions.generate(.plaintext, show_docs)`.
|
||||
///
|
||||
/// TODO(integration): this is a local copy of
|
||||
/// `ghostty_input::helpgen_actions::generate`. The embedded docs of a few
|
||||
/// actions in ghostty-input (`adjust_selection`, ...) end with an extra blank
|
||||
/// line compared to Ghostty's `help_strings`, which adds a stray `" "` line
|
||||
/// to `--docs` output. Trailing newlines are normalised here; once the data
|
||||
/// is fixed in ghostty-input this should call `helpgen_actions::generate`.
|
||||
#[must_use]
|
||||
pub fn generate_plaintext(show_docs: bool) -> String {
|
||||
let mut writer = String::new();
|
||||
let mut stream = String::new();
|
||||
for &key in ActionKey::ALL {
|
||||
let name = key.name();
|
||||
if name.starts_with('_') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Write previously stored doc comment below all related actions
|
||||
if show_docs {
|
||||
writer.push_str(&stream);
|
||||
writer.push('\n');
|
||||
stream.clear();
|
||||
writer.push_str(name);
|
||||
writer.push_str(":\n");
|
||||
for line in key.docs().trim_end_matches('\n').split('\n') {
|
||||
stream.push_str(" ");
|
||||
stream.push_str(line);
|
||||
stream.push('\n');
|
||||
}
|
||||
} else {
|
||||
writer.push_str(name);
|
||||
writer.push('\n');
|
||||
}
|
||||
}
|
||||
|
||||
// Write any remaining buffered documentation
|
||||
writer.push_str(&stream);
|
||||
writer
|
||||
ghostty_input::helpgen_actions::generate_string(
|
||||
ghostty_input::helpgen_actions::Format::Plaintext,
|
||||
show_docs,
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -94,15 +61,4 @@ mod tests {
|
||||
assert!(s.contains(" respectively.\n\njump_to_prompt:\n"));
|
||||
assert!(s.ends_with('\n'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn matches_input_crate_when_docs_are_clean() {
|
||||
// The first actions have well-formed docs.
|
||||
let ours = generate_plaintext(true);
|
||||
let theirs = ghostty_input::helpgen_actions::generate_string(
|
||||
ghostty_input::helpgen_actions::Format::Plaintext,
|
||||
true,
|
||||
);
|
||||
assert!(ours.lines().take(100).eq(theirs.lines().take(100)));
|
||||
}
|
||||
}
|
||||
@@ -16,35 +16,14 @@ config_struct! {
|
||||
}
|
||||
cli_options!(Options, help);
|
||||
|
||||
/// `terminal/res/rgb.txt`, the same file `x11_color` is built from.
|
||||
///
|
||||
/// TODO(integration): ghostty-vt's `x11_color` only exposes lookups (and
|
||||
/// lower-cases the names); expose its key list and use it instead of
|
||||
/// re-parsing the data here.
|
||||
const RGB_DATA: &str = include_str!("../../ghostty-vt/src/res/rgb.txt");
|
||||
|
||||
/// All X11 color names (with their original spelling) and values. Like the
|
||||
/// case-insensitive Zig map the first spelling of a name wins.
|
||||
#[must_use]
|
||||
pub fn x11_colors() -> Vec<(String, (u8, u8, u8))> {
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
let mut out = vec![];
|
||||
for line in RGB_DATA.split('\n') {
|
||||
if line.len() < 12 {
|
||||
continue;
|
||||
}
|
||||
let parse = |s: &str| s.trim_matches(' ').parse::<u8>().ok();
|
||||
let (Some(r), Some(g), Some(b)) =
|
||||
(parse(&line[0..3]), parse(&line[4..7]), parse(&line[8..11]))
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let name = line[12..].trim_matches([' ', '\t', '\n']);
|
||||
if seen.insert(name.to_ascii_lowercase()) {
|
||||
out.push((name.to_string(), (r, g, b)));
|
||||
}
|
||||
}
|
||||
out
|
||||
ghostty_vt::x11_color::names()
|
||||
.iter()
|
||||
.map(|(n, c)| ((*n).to_string(), (c.r, c.g, c.b)))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// `std.ascii.orderIgnoreCase`.
|
||||
|
||||
@@ -41,11 +41,7 @@ pub fn write_version(out: &mut dyn Write, info: &BuildInfo, tty: bool) -> std::i
|
||||
|
||||
writeln!(out, "Build Config")?;
|
||||
// The Zig build prints its compiler version here.
|
||||
writeln!(
|
||||
out,
|
||||
" - Rust version : {}",
|
||||
option_env!("CARGO_PKG_RUST_VERSION").unwrap_or("unknown")
|
||||
)?;
|
||||
writeln!(out, " - Rust version : {}", env!("GHOSTTY_RUSTC_VERSION"))?;
|
||||
writeln!(out, " - build mode : {}", info.build_mode)?;
|
||||
writeln!(out, " - app runtime : {}", info.app_runtime)?;
|
||||
writeln!(out, " - font engine : {}", info.font_backend)?;
|
||||
|
||||
Reference in new issue
Block a user