/*
 *      Driver file for dave armitage bbc terminal
 * like an adm3a with vt52 cursor keys!
 * and non-statndard highlighting
 *      - Use with UMIST.def
 */

/*#define HANDSHAKE /* enable <cntl-q><cntl-s> handshake */

dwa_move(srow, scol)
register int srow, scol;
 {  /* ESC, =, row+space, col+space */
    ttyout('\033');
    ttyout('=');
    ttyout(srow+' ');
    ttyout(scol+' ');
 }


int dwa_setup()
{
#ifdef HANDSHAKE
   extern struct tchars tchars;

   tchars.t_startc = 021;
   tchars.t_stopc = 023;
#endif HANDSHAKE

}

int dwa_restore()
{
}

int dwa_special(typein,c) int typein; register char c; {
register char ch;

if (c != '\033') {
 editerror("character %o given to dwaer special",c);
 return(IGN);
 }
if (typein) {
 ch = ttyin();
 switch(ch) {
  case 'C': return(RIGHT);
  case 'D': return(LEFT);
  case 033: return(ENTERedit);
  }
 if (mode!=INMODE) {complain(); return(IGN);}
 switch(ch) {
  case 'B': return(DOWN);
  case 'A': return(UP);
  case '[': return(NEXTPAGE);
  case ']': return(LASTPAGE);
  default:  complain(); return(IGN);
  }
 }
else return(IGN);
}


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

    /* up, left, c_MODIFY, c_CONTROL, c_BLOB - single characters */
    { '\013', '\010', 0, 0200|'^', 0200|' ' },
	/* onechar */

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

    /* scrollup, scrolldown PROCEDURES */
    /* scr1_ is pushup, pulldown */
    /* scr2_ is pushdown, pullup */
    /* scr3_ is both */
    /* scr0_ is neither (and in that case hardscroll is false) */
    scr0_up, scr0_down,

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

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

    /* clearscreen, *clearhead, *cleartail STRINGS */
    /* I assume ^L for clear screen, but it isn't important */
    { "\032", 0, 0 },
	/* clrseq */

    /* clr_screen, clr_head, clr_tail PROCEDURES */
    /* I assume hardware support for clear screen at least */
    clrs1, clrh0, clrt0,

    /* inspace, makespace, rubout, erase STRINGS */
    /* inspace puts a space and moves the cursor right,
     * makespace doesn't move it. Likewise rubout moves the
     * cursor left, erase doesn't move it
     */
    { 0, 0, 0, 0 },
	/* charseq */

    /* ins_char, del_char PROCEDURES */
    /* insc1 uses inspace, insc2 makespace */
    /* delc1 uses rubout, delc2 erase */
    /* insc0, delc0 use neither */
    insc0, delc0,

    /* bright, normal STRINGS */
    { "\033)", "\033(" },
	/* vidseq */

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

    /* move PROCEDURE and nmove integer */
    dwa_move, 4,

    /* setup, special, pad, restore PROCEDURES */
   dwa_setup, dwa_special, no_int, dwa_restore

 };
