diff --git a/.github/workflows/termwiz.yml b/.github/workflows/termwiz.yml
index 10c44f62b..eb595e024 100644
--- a/.github/workflows/termwiz.yml
+++ b/.github/workflows/termwiz.yml
@@ -12,6 +12,7 @@ on:
- "filedescriptor/**"
- "vtparse/**"
- ".github/workflows/termwiz.yml"
+ - "ci/regen-binary-terminfo.sh"
push:
branches:
- main
@@ -23,8 +24,34 @@ on:
- "filedescriptor/**"
- "vtparse/**"
- ".github/workflows/termwiz.yml"
+ - "ci/regen-binary-terminfo.sh"
jobs:
+ check-terminfo:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v6
+
+ - name: "Install tic"
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y ncurses-bin
+
+ - name: "Check compiled terminfo is up to date"
+ run: |
+ bash ci/regen-binary-terminfo.sh
+ if git diff --exit-code -- termwiz/data/w/wezterm; then
+ echo "✅ termwiz/data/w/wezterm is up to date with termwiz/data/wezterm.terminfo"
+ else
+ echo "❌ termwiz/data/w/wezterm is out of date with termwiz/data/wezterm.terminfo"
+ echo # blank line
+ echo "Regenerate it with:"
+ echo " ci/regen-binary-terminfo.sh"
+ echo # blank line
+ exit 1
+ fi
+
build-termwiz-all-features:
runs-on: ubuntu-latest
steps:
diff --git a/ci/regen-binary-terminfo.sh b/ci/regen-binary-terminfo.sh
new file mode 100755
index 000000000..eefb4dacb
--- /dev/null
+++ b/ci/regen-binary-terminfo.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+# Regenerate the compiled terminfo database from its text source.
+
+set -euo pipefail
+
+repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+
+# tic lays entries out as
//,
+# so this writes termwiz/data/w/wezterm.
+tic -x -o "$repo_root/termwiz/data" "$repo_root/termwiz/data/wezterm.terminfo"
diff --git a/term/src/terminalstate/mod.rs b/term/src/terminalstate/mod.rs
index f2ad3a514..13f29b337 100644
--- a/term/src/terminalstate/mod.rs
+++ b/term/src/terminalstate/mod.rs
@@ -38,7 +38,7 @@ use crate::terminalstate::kitty::*;
lazy_static::lazy_static! {
static ref DB: Database = {
- let data = include_bytes!("../../../termwiz/data/wezterm");
+ let data = include_bytes!("../../../termwiz/data/w/wezterm");
Database::from_buffer(&data[..]).unwrap()
};
}
@@ -2890,3 +2890,84 @@ impl TerminalState {
.unwrap_or(self.keyboard_encoding)
}
}
+
+#[cfg(test)]
+mod test {
+ use super::*;
+ use std::sync::mpsc::Receiver;
+ use std::sync::Mutex;
+ use std::time::Duration;
+ use wezterm_escape_parser::Action;
+
+ #[derive(Debug)]
+ struct TestConfig;
+
+ impl crate::TerminalConfiguration for TestConfig {
+ fn color_palette(&self) -> ColorPalette {
+ ColorPalette::default()
+ }
+ }
+
+ /// Captures everything the terminal writes and signals on flush, so a test
+ /// can wait for the writer thread to emit the response before reading it.
+ struct CaptureWriter {
+ buffer: Arc>>,
+ flushed: Sender<()>,
+ }
+
+ impl Write for CaptureWriter {
+ fn write(&mut self, buf: &[u8]) -> std::io::Result {
+ self.buffer.lock().unwrap().extend_from_slice(buf);
+ Ok(buf.len())
+ }
+
+ fn flush(&mut self) -> std::io::Result<()> {
+ let _ = self.flushed.send(());
+ Ok(())
+ }
+ }
+
+ /// Builds a terminal whose output is captured into `buffer`.
+ fn capture_terminal(buffer: &Arc>>) -> (TerminalState, Receiver<()>) {
+ let (flushed, flushed_rx) = channel();
+ let writer = Box::new(CaptureWriter {
+ buffer: Arc::clone(buffer),
+ flushed,
+ });
+ let state = TerminalState::new(
+ TerminalSize::default(),
+ Arc::new(TestConfig),
+ "WezTerm",
+ "O_o",
+ writer,
+ );
+ (state, flushed_rx)
+ }
+
+ #[test]
+ fn embedded_terminfo_is_valid() {
+ // Initializing the lazy_static database panics if the embedded
+ // terminfo file is missing or malformed.
+ assert!(DB.raw("Tc").is_some());
+ }
+
+ #[test]
+ fn xt_get_tcap_responds_from_embedded_terminfo() {
+ let buffer = Arc::new(Mutex::new(Vec::new()));
+ let (mut state, flushed_rx) = capture_terminal(&buffer);
+
+ {
+ let mut performer = performer::Performer::new(&mut state);
+ performer.perform(Action::XtGetTcap(vec!["sitm".to_string()]));
+ }
+
+ // Wait for the writer thread to write and flush the response.
+ flushed_rx
+ .recv_timeout(Duration::from_secs(5))
+ .expect("terminal did not flush its response");
+
+ let response = String::from_utf8(buffer.lock().unwrap().clone()).unwrap();
+ // 7369746D is hex for "sitm"; 1B5B336D is hex for the SGR italics sequence.
+ assert_eq!(response, "\x1bP1+r7369746D=1B5B336D\x1b\\");
+ }
+}
diff --git a/termwiz/data/wezterm b/termwiz/data/wezterm
deleted file mode 100644
index e402d3d9f..000000000
Binary files a/termwiz/data/wezterm and /dev/null differ