From: Stefan Sperling Subject: Re: tog: fix display of lines ending in \r\n To: Christian Weisgerber Cc: gameoftrees@openbsd.org Date: Thu, 10 Dec 2020 23:34:21 +0100 On Thu, Dec 10, 2020 at 11:17:48PM +0100, Christian Weisgerber wrote: > Stefan Sperling: > > > What specific problem are you looking at? > > tog's log view dealing with the attached repository. > > There are two ESC characters in the commit message. They are escaped > to "^[", but then the next line is offset by 4 characters. > > This would be consistent with ESC being handled as a zero-width > character, and a later instance (curses itself?) turning them into > visible sequences. One thing we could do is this. Keeps the display intact, at least. diff 3f670bfb38a502b7309f7db354b9d4f767ea12fc /home/stsp/src/got blob - ee044a71602208bed395a517f0354d580be3407f file + tog/tog.c --- tog/tog.c +++ tog/tog.c @@ -19,6 +19,7 @@ #include #include +#include #include #define _XOPEN_SOURCE_EXTENDED #include @@ -1175,8 +1176,12 @@ format_line(wchar_t **wlinep, int *widthp, const char i = 0; while (i < wlen) { - int width = wcwidth(wline[i]); + int width; + if (iswcntrl(wline[i])) + wline[i] = L'?'; + + width = wcwidth(wline[i]); if (width == 0) { i++; continue;