#include "ded.h" #include "char.h" #include "ter.h" /************************************************************************ * * * copyright Richard Bornat 1981 * * * ************************************************************************/ /* make the screen cursor (real_c) * same as the user cursor (virt_c) */ fixpos() { register int srow, scol; if ( (srow=virt_c.row) bottomrow) virt_c.row=srow=bottomrow; if ( (scol=virt_c.col) rightcol) virt_c.col=scol=rightcol+1; move_to(srow, scol); } /* adjust cursor position */ adj_virt_c(r,c) register int r,c; { register int i; if ((i = virt_c.row += r) bottomrow) virt_c.row = bottomrow; if ((i = virt_c.col += c) rightcol) virt_c.col = rightcol; } /* set some arbitrary cursor */ void set_c(r,c,pos) int r,c; register struct CURSOR *pos; { pos->row = r; pos->col = c; } /* move cursor with minimum of fuss - this procedure is called * by fixpos only when the cursor needs to be moved. */ move_to(srow, scol) register int srow, scol; { if (srow<0) srow = 0; else if (srow>FOOTROW) srow = FOOTROW; if (scol<0) scol = 0; else if (scol>RIGHTCOL) scol = RIGHTCOL; if (srow!=real_c.row || scol!=real_c.col) { int n_vert, n_horiz; int ncr; register char *rp; n_vert = (srow>=real_c.row ? srow-real_c.row : ter.onechar.up!=0 ? real_c.row-srow : 500); n_horiz = (scol>=real_c.col ? scol-real_c.col : ter.onechar.left!=0 ? real_c.col-scol : 500); ncr = scol+1; /* use either incremental motion or cursor addressing - * whichever uses less characters */ if ( (n_horiz<=ncr ? n_vert+n_horiz<=ter.nmove : n_vert+ncr<=ter.nmove)) { if (ncrreal_c.row) { ttyout(c_NL); real_c.row++; } /* move up */ while (srowreal_c.col) { ttyout(*rp++); real_c.col++; } /* move left */ while (scol