Skip to content

Commit 18f2867

Browse files
committed
infocmp -C: keep the charset-off in me for custom-charset (cons) entries
When smacs/rmacs are dropped for consistency (custom, non-identity acsc), the reset's own charset-off is meaningful, so the trim-paths of _nc_trim_sgr0 yield the raw sgr@0 instead of the trimmed form (hp2622 \E&d@\017, dku7102 \E[0m\017). The sgr0-return paths are unchanged, so the entries that legitimately reduce to sgr0 are unaffected. Termcap (-C) content 93.4% -> 95.5%, exact 44.2%. terminfo -1 100%; tests green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CbiPgWC3PHKmrTNvZzXcWQ
1 parent 98d7788 commit 18f2867

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

crates/ncurses-tools/src/bin/infocmp.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,10 @@ fn me_from_sgr0(ti: &Terminfo) -> Option<Vec<u8>> {
630630
return Some(sgr0.to_vec());
631631
};
632632
let off = ncurses_native::terminfo::tparm_n(sgr, &[0; 9]);
633+
// When smacs/rmacs are dropped for consistency (custom, non-identity acsc), a reset that would
634+
// otherwise be trimmed keeps its charset-off instead -- i.e. the trim-paths below yield the raw
635+
// sgr@0 (hp2622 \E&d@\017, dku7102 \E[0m\017), while the sgr0-paths are unaffected.
636+
let cons = drop_acs_for_consistency(ti);
633637
let rm = ti.string("rmacs").map(strip_pad).unwrap_or_default();
634638
if rm.is_empty() {
635639
return Some(sgr0.to_vec());
@@ -661,7 +665,10 @@ fn me_from_sgr0(ti: &Terminfo) -> Option<Vec<u8>> {
661665
// charset (modulo the implicit-zero \E[m/\E[0m); a bare \E[m or a mismatch keeps sgr0 (d220,
662666
// linux).
663667
if !is_csi {
664-
return Some(if rm.len() == 1 { trim } else { sgr0.to_vec() });
668+
if rm.len() == 1 {
669+
return Some(if cons { off } else { trim });
670+
}
671+
return Some(sgr0.to_vec());
665672
}
666673
if tp == b"\x1b[m" {
667674
// A bare \E[m trim: keep sgr0, which legitimately ends with the charset-off shift
@@ -674,7 +681,7 @@ fn me_from_sgr0(ti: &Terminfo) -> Option<Vec<u8>> {
674681
None => s0.clone(),
675682
};
676683
if normalize_sgr(&tp) == normalize_sgr(&s0r) {
677-
return Some(trim);
684+
return Some(if cons { off } else { trim });
678685
}
679686
return Some(sgr0.to_vec());
680687
}

0 commit comments

Comments
 (0)