Download raw body.
tog: fix display of lines ending in \r\n
On Sat, Dec 12, 2020 at 12:09:12AM +0100, Christian Weisgerber wrote: > Christian Weisgerber: > > > Alternatively, > > (2) tog continues to pass the control character to curses, but when > > calculating the column width, tog takes into account that curses > > will change the character into a printable representation. > > > > Below is a quick proof-of-concept that uses approach (2). > > Here's a variant that at least isn't outright wrong. OK. This is a nice and compact solution. Because it isn't obvious, could you add a comment that explains the behaviour we expect from ncurses? Something like: /* ncurses escapes control chars with ^, using an extra column */ > diff 9f6bb280654be7061fc00305743f6ace71f9a1cb /home/naddy/got > blob - 99232045ade1a4d37286e512dd4999368a1b89b5 > file + tog/tog.c > --- tog/tog.c > +++ tog/tog.c > @@ -35,6 +35,7 @@ > #include <unistd.h> > #include <limits.h> > #include <wchar.h> > +#include <wctype.h> > #include <time.h> > #include <pthread.h> > #include <libgen.h> > @@ -1193,6 +1194,10 @@ format_line(wchar_t **wlinep, int *widthp, const char > if (cols + width > wlimit) > break; > cols += width; > + } else if (iswcntrl(wline[i])) { > + if (cols + 2 > wlimit) > + break; > + cols += 2; > } > i++; > } else { > -- > Christian "naddy" Weisgerber naddy@mips.inka.de > >
tog: fix display of lines ending in \r\n