From: Stuart Henderson Subject: Re: Adding ECMA-48 REP to wscons to fix breakage To: tech@openbsd.org Date: Sun, 7 Jul 2024 21:22:12 +0100 On 2024/06/20 06:35, Crystal Kolipe wrote: > The attached patch adds the CSI b control sequence to wscons. This seems sane and useful to me, did anyone else look at it? I only have one nit, inline below. > This is needed because the curses updates in the last development cycle broke > the use of the xterm emulation which had worked fine in both 7.3 and 7.4. > > Unlike the quick kludge I posted last month to make things usable, this > version is intended to fix the problem correctly and handles multiple line > output. > > Notes: > > The repeat count is limited to 65535, which matches xterm behaviour. > > According to the spec, sending the repeat sequence after a non-printable > character is undefined behaviour. For example, considering the following > sequence: > > A^G^[[5bB > > Xterm displays a missing character glyph for the five repeats of the bell > character. > > Since we don't necessarily have a missing character glyph available on wscons > this version of the patch just repeats the last printed character. > > In this case we get: > > AAAAAAB > > diff -ur 1/sys/dev/wscons/wsemul_vt100.c 2/sys/dev/wscons/wsemul_vt100.c > --- sys/dev/wscons/wsemul_vt100.c Wed Aug 2 20:20:19 2023 > +++ sys/dev/wscons/wsemul_vt100.c Thu Jun 20 10:05:51 2024 > @@ -394,6 +394,8 @@ > } > } > > +edp->last_printed_char=instate->inchar; ^ whitespace, missing tab > + > #ifdef HAVE_DOUBLE_WIDTH_HEIGHT > WSEMULOP(rc, edp, &edp->abortstate, putchar, > (edp->emulcookie, edp->crow, edp->ccol << edp->dw, dc, > diff -ur 1/sys/dev/wscons/wsemul_vt100_subr.c 2/sys/dev/wscons/wsemul_vt100_subr.c > --- sys/dev/wscons/wsemul_vt100_subr.c Sun Feb 26 15:09:53 2023 > +++ sys/dev/wscons/wsemul_vt100_subr.c Thu Jun 20 09:48:08 2024 > @@ -43,7 +43,8 @@ > #define VTMODE_SET 33 > #define VTMODE_RESET 44 > #define VTMODE_REPORT 55 > - > +extern int wsemul_vt100_output_normal(struct wsemul_vt100_emuldata *edp, > + struct wsemul_inputstate *instate, int kernel); > /* > * scroll up within scrolling region > */ > @@ -548,6 +549,17 @@ > break; > } > break; > + case 'b': /* REP - repeat previously printed character */ > + instate->inchar = edp->last_printed_char; > + /* > + * We arbitrarily limit the repeat count to 65535 to avoid > + * un-interruptable flooding of the console. This matches > + * current xterm behaviour. > + */ > + for (m=0; m < (DEF1_ARG(0) < 65535 ? DEF1_ARG(0) : 65535); m++) { > + wsemul_vt100_output_normal(edp, instate, 0); > + } > + break; > case 'c': /* DA primary */ > if (ARG(0) == 0) > wsdisplay_emulinput(edp->cbcookie, WSEMUL_VT_ID1, > diff -ur 1/sys/dev/wscons/wsemul_vt100var.h 2/sys/dev/wscons/wsemul_vt100var.h > --- sys/dev/wscons/wsemul_vt100var.h Mon Mar 6 17:14:44 2023 > +++ sys/dev/wscons/wsemul_vt100var.h Mon May 27 16:45:26 2024 > @@ -99,6 +99,7 @@ > #else > u_char translatebuf[1]; > #endif > + uint32_t last_printed_char; > }; > > /* some useful utility macros */ >