/************************************************************************
 *                                                                      *
 *                      copyright Richard Bornat 1981                   *
 *                                                                      *
 ************************************************************************/

sys_pad(c)
/* pad out the horrible systime terminal */
 { register int i;

   for (i=1; i<=10; i++) ttyout(0);
 }

sys_move(srow, scol)
register int srow, scol;
 {  /* ^^, col+32, row+64 */
    ttyout(036);
    ttyout(scol + 32);
    ttyout(srow + 64);
 }
sys_special(typein, c)
int typein;
register char c;
 {  if (c!=035) editerror("sys_special given character %o", c);
    else
      return(typein ? -'_' : UP); /* anything to confuse infile */
 }

#define TER_ROWS 25
#define TER_COLS 80

struct TERMINAL sys_ter =
 {  /* nrows, ncols - size of the screen */
    TER_ROWS, TER_COLS,

    /* up, left, c_MODIFY, c_CONTROL, c_BLOB - single characters */
    { '\032', '\010', 0, '\0177', '\0177' },     /* onechar */
        /* onechar */

    /* rollup, pushdown, pushup, pulldown, pullup STRINGS */
    /* and hardscroll boolean */
    { "\0\n", 0, 0, 0, 0, false },
        /* scrseq */

    /* scrollup, scrolldown PROCEDURES */
    scr0_up, scr0_down,

    /* splitdown, splitup, joindown, joinup STRINGS */
    { 0, 0, 0, 0, false },
        /* splitseq */

    /* split_row, join_row PROCEDURES */
    split0, join0,

    /* clearscreen, *clearhead, *cleartail STRINGS */
    { "\0\030", 0, "\0\026" },
        /* clrseq */

    /* clr_screen, clr_head, clr_tail PROCEDURES */
    clrs1, clrh0, clrt1,

    /* inspace, makespace, rubout, erase STRINGS */
    { 0, 0, 0, 0 },
        /* charseq */

    /* ins_char, del_char PROCEDURES */
    insc0, delc0,

    /* bright, normal STRINGS */
    { 0, 0 },
        /* vidseq */

    /* in_two, out_two PROCEDURES */
    no_char, no_char,

    /* move PROCEDURE and nmove integer */
    sys_move, 3,

    /* setup, special, pad PROCEDURES */
    no_int, sys_special, sys_pad
 };

/* systime can't type an underline, so translate <control>-~
 * into an underline.
 */

/* table of characters for input (INMODE) mode */
char  ictab[] =
 {      /* 000 - 007, null - ^G */
        IGN, WRIGHT, WLEFT, IGN, IGN, DOWN, TAILERASE, WERASE,
        /* 010 - 017, ^H - ^O */
        LEFT, TAB, NL, LSTART, LEND, CR, BOTSCREEN, TOPSCREEN,
        /* 020 - 027, ^P - ^W */
        IGN, RIGHT, ERASE, UP, IGN, LEFT, SEND, WRUBOUT,
        /* 030 - 037, ^X - ^_ */
        HEADRUBOUT, CHMODE, CONTROL, ENTERedit, IGN, LINEERASE, SPECIAL, IGN,
        SPACE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, RUBOUT
 };

/* table of characters for edit (EDMODE) mode. Much the same
 * as ictab, except for the absence of UP, DOWN, TOPSCREEN,
 * BOTSCREEN and LINEERASE. CR or LF are also COMMAND in this mode
 */
char  ectab[] =
 {      /* 000 - 007, null - ^G */
        IGN, WRIGHT, WLEFT, IGN, IGN, IGN, TAILERASE, WERASE,
        /* 010 - 017, ^H - ^O */
        LEFT, TAB, COMMAND, LSTART, LEND, COMMAND, IGN, IGN,
        /* 020 - 027, ^P - ^W */
        IGN, RIGHT, ERASE, IGN, IGN, LEFT, SEND, WRUBOUT,
        /* 030 - 037, ^X - ^_ */
        HEADRUBOUT, CHMODE, CONTROL, ENTERedit, IGN, IGN, SPECIAL, IGN,
        SPACE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, ONE,
        ONE, ONE, ONE, ONE, ONE, ONE, ONE, RUBOUT
 };
