/*
 *      Driver file for Hewlet Packard 2621 Terminal emulator
 *      - Use with UMIST.def
 */


hp2621_move(srow, scol)
register int srow, scol;
 {  /*  ESC ,&,a,2dcol,c,2drow,Y */
    ttyout('\033');
    ttyout('&');
    ttyout('a');
    dedpnum(ttyout,scol,10);
    ttyout('c');
    dedpnum(ttyout,srow,10);
    ttyout('Y');
 }

int hp2621_setup()
{
   sendseq("\033&j@\r\0333\r\033H\033J");
}

int hp2621_restore()
{
}

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

   if (c != '\033') {
      editerror("character %o given to hp2621 special",c);
      return(IGN);
    }
   if (typein) {
      ch = ttyin();
      switch(ch) {
      case 033: return(ENTERedit);
      default:  complain(); return(IGN);
      }
   }
   else
      return(IGN);
}

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

    /* up, left, c_MODIFY, c_CONTROL, c_BLOB - single characters */
    { 0, '\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 */
    { "\033H\033J", 0, "\033K" },
        /* clrseq */

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

    /* 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&dB", "\033&d@" },
        /* vidseq */

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

    /* move PROCEDURE and nmove integer */
    hp2621_move, 9,

    /* setup, special, pad, restore PROCEDURES */
   hp2621_setup, no_int, no_int, hp2621_restore

 };
