Here is a patch to implement five additional escape sequences in the wscons vt100 emulation.
This is a port of some code that I originally wrote for OpenBSD, and which was recently accepted into CVS there. It's useful, because these sequences correspond to the terminfo capabilities rin, indn, vpa, hpa, and cbt as defined in the xterm terminfo entry. With these sequences implemented, it becomes slightly more practical to set TERM=xterm when connecting to remote systems that don't have a comprehensive terminfo database. The current lack of support for cbt, vpa, and hpa is actually mentioned in the comments in the terminfo file, (see line 2533). --- dev/wscons/wsemul_vt100_subr.c.dist 2018-12-05 22:42:20.000000000 -0300 +++ dev/wscons/wsemul_vt100_subr.c 2023-01-16 08:35:17.292084228 -0300 @@ -188,7 +188,7 @@ void wsemul_vt100_handle_csi(struct vt100base_data *edp, u_char c) { - int n, help, flags, fgcol, bgcol; + int n, m, help, flags, fgcol, bgcol; long attr, bkgdattr; #define A3(a, b, c) (((a) << 16) | ((b) << 8) | (c)) @@ -410,6 +410,9 @@ edp->ccol -= uimin(DEF1_ARG(edp, 0), edp->ccol); edp->flags &= ~VTFL_LASTCHAR; break; + case 'G': /* CHA */ + edp->ccol = uimin(DEF1_ARG(edp, 0)-1, edp->ncols-1); + break; case 'H': /* CUP */ case 'f': /* HVP */ if (edp->flags & VTFL_DECOM) @@ -445,15 +448,40 @@ COPYCOLS(edp, edp->ccol + n, edp->ccol, help); ERASECOLS(edp, NCOLS(edp) - n, n, edp->bkgdattr); break; + case 'S': /* SU */ + wsemul_vt100_scrollup (edp,DEF1_ARG(edp, 0)); + break; + case 'T': /* SD */ + wsemul_vt100_scrolldown (edp,DEF1_ARG(edp, 0)); + break; case 'X': /* ECH erase character */ n = uimin(DEF1_ARG(edp, 0), COLS_LEFT(edp) + 1); ERASECOLS(edp, edp->ccol, n, edp->bkgdattr); break; + case 'Z': /* CBT */ + if (edp->ccol == 0) + break; + for (m = 0; m < DEF1_ARG(edp, 0); m++) { + if (edp->tabs) { + for (n = edp->ccol - 1; n > 0; n--) { + if (edp->tabs[n]) + break; + } + } else + n = (edp->ccol - 1) & ~7; + edp->ccol = n; + if (n == 0) + break; + } + break; case 'c': /* DA primary */ if (ARG(edp, 0) == 0) wsdisplay_emulinput(edp->cbcookie, WSEMUL_VT_ID1, sizeof(WSEMUL_VT_ID1)); break; + case 'd': /* VPA */ + edp->crow = uimin(DEF1_ARG(edp, 0)-1, edp->nrows-1); + break; case 'g': /* TBC */ KASSERT(edp->tabs != 0); switch (ARG(edp, 0)) {