From 642680a9145f49eef2ff2404d2641940eb06cd7d Mon Sep 17 00:00:00 2001 From: Alois Wohlschlager Date: Sun, 8 Sep 2024 15:26:35 +0200 Subject: [PATCH 1/2] alois31 Copyright Waiver I dedicate any and all copyright interest in this software to the public domain. I make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. I intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. From 1634f9d56c21b1dafe102cb955644a4ad18bdc9c Mon Sep 17 00:00:00 2001 From: Alois Wohlschlager Date: Sun, 8 Sep 2024 15:26:48 +0200 Subject: [PATCH 2/2] Highlight ASCII control characters unambiguously Previously, all ASCII control characters would be shown as the replacement character. This leads to a visual loss of information and ambiguities, particularly when opening files that contain lots of control characters (or binary files). Use the common circumflex notation, known from software such as `cat -v` or vim, instead. Fixes #2936 --- src/highlighters.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/highlighters.cc b/src/highlighters.cc index cccccffd66..a263ee8ed1 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -1327,7 +1327,12 @@ void expand_unprintable(HighlightContext context, DisplayBuffer& display_buffer, if (ByteCount pos(next - line_data); pos < atom_it->end().column) atom_it = line.split(atom_it, {begin.line, pos}); - atom_it->replace("�"); + if (cp < ' ') + atom_it->replace(format("^{}", (char)(cp + '@'))); + else if (cp == 127) + atom_it->replace("^?"); + else + atom_it->replace("�"); atom_it->face = error; break; }