Files
ddidderr 7868e56273 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
2026-10-12 02:08:22 +02:00

47 lines
1.4 KiB
Rust

//! ClipboardCodepointMap is a map of codepoints to replacement values
//! for clipboard operations. When copying text to clipboard, matching
//! codepoints will be replaced with their mapped values.
/// One entry of the map and its replacement value. The canonical
/// definitions live in `ghostty_terminal::formatter` (`CodepointMap`,
/// `Replacement`), which is what the terminal formatter consumes.
pub use ghostty_terminal::formatter::{CodepointMap as Entry, Replacement};
/// The list of entries.
///
/// Note: we do a linear search because we expect to always have very
/// few entries, so the overhead of a binary search is not worth it.
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct ClipboardCodepointMap {
pub list: Vec<Entry>,
}
impl ClipboardCodepointMap {
/// Add an entry to the map.
///
/// For conflicting codepoints, entries added later take priority over
/// entries added earlier.
pub fn add(&mut self, entry: Entry) {
assert!(entry.range[0] <= entry.range[1]);
self.list.push(entry);
}
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use super::*;
#[test]
fn add_and_clone() {
let mut m = ClipboardCodepointMap::default();
m.add(Entry {
range: [1, 2],
replacement: Replacement::String("x".into()),
});
let c = m.clone();
assert_eq!(m, c);
assert_eq!(c.list.len(), 1);
}
}