/* terminal definitions for hp300 */





hp300_setup()
 {
        sendseq( "\33&s1A\33&jB");

        sendseq( "\33&f0a1k16d2L Line    Start  \33p" ) ;
        sendseq( "\33&f0a2k16d2L Line    Middle \33q" ) ;
        sendseq( "\33&f0a3k16d2L Line    End    \33r" ) ;
        sendseq( "\33&f0a4k16d2L Word    Left   \33s" ) ;
        sendseq( "\33&f0a5k16d2L Word    Right  \33t" ) ;
        sendseq( "\33&f0a6k16d2L Top of  Screen \33u" ) ;
        sendseq( "\33&f0a7k16d2L End of  Screen \33v" ) ;
        sendseq( "\33&f0a8k16d2L Enter   Command\33w" ) ;

};


hp300_restore()
 {
        sendseq( "\33&s0A\33&j@");
};







hp300_move(row, col)
register int row, col;
 {      ttyout('\33');
        ttyout('&');
        ttyout('a');
        ttyout(row/100+'0');
        ttyout(row/10 % 10 + '0');
        ttyout(row%10+'0');
        ttyout('y');
        ttyout(col/100+'0');
        ttyout(col/10 % 10 + '0');
        ttyout(col%10+'0');
        ttyout('C');
 } ;



struct spectab hp300_spec[] =
 {      "\33w",       ENTERedit,      ENTERedit,
        "\33v",       BOTSCREEN,            IGN,
        "\33u",       TOPSCREEN,            IGN,
        "\33t",          WRIGHT,         WRIGHT,
        "\33s",           WLEFT,          WLEFT,
        "\33r",            LEND,           LEND,
        "\33q",         LMIDDLE,        LMIDDLE,
        "\33p",          LSTART,         LSTART,
        "\33h",             IGN,            IGN,
        "\33V",         COMMAND,        COMMAND,
        "\33V",             IGN,            IGN,
        "\33U",             IGN,            IGN,
        "\33Q",             IGN,            IGN,
        "\33P",           ERASE,          ERASE,
        "\33P",             IGN,            IGN,
        "\33M",       LINEERASE,            IGN,
        "\33L",             IGN,            IGN,
        "\33K",       TAILERASE,      TAILERASE,
        "\33J",             IGN,            IGN,
        "\33F",             IGN,            IGN,
        "\33D",            LEFT,           LEFT,
        "\33C",           RIGHT,          RIGHT,
        "\33B",            DOWN,            IGN,
        "\33A",              UP,            IGN,
        "\33&P",                    IGN,            IGN,
        "\33",              IGN,            IGN,
        0,              0,              0
 };







/* return the display type of a SPECIAL character sequence.
 * First argument shows whether input is from keyboard or file.
 * Second argument is character.
 * Uses 'spectab' array, defined in relevant .def file
 */
int special(typein, c)
int typein;
char c;
 {  char buf[ENOUGH];
    char *hbp = buf;

    struct spectab *sp;

    for (sp = &hp300_spec[0]; sp->str!=(char*)0; sp++)
      if (sp->str[0] == c)
       {  register char *str = &sp->str[1];

          if (typein)
            {   register char *bp = buf;

                do
                 {  if (*str=='\0')
                     {  while (hbp!=bp) ttyback(*--hbp);
                        return(mode==INMODE ? sp->i_ctype : sp->e_ctype);
                     }
                    if (bp==hbp) *hbp++ = ttyin();
                 }
                while (*bp++ == *str++);
           }
          else
          if (*str=='\0') return(sp->i_ctype);
       }

    /* nothing matches - disaster */
    editerror("cannot recognise special character \\%o\n", c);

 }







struct TERMINAL hp300_ter =
 {      /* nrows, ncols */
        46, 128,


        /* up, left, c_MODIFY, c_CONTROL, c_BLOB */
        { 0, '\b', 0, 0200|'^', 0200|'$' },

        /* rollup, pushdown, pushup, pulldown, pullup */
        { "\n", "\33L", 0, 0, "\33M", true },

        /* scrollup, scrolldown */
        scr2_up, scr2_down,


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

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


        /* clearscreen, *clearhead, *cleartail */
        { "\33&a0y0C\33J", 0, "\33K" },

        /* clr_screen, clr_head, clr_tail */
        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 },

        /* ins_char, del_char */
        insc0, delc0,

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

        /* in_two, out_two */
        no_char, no_char,



        /* move, nmove */
        hp300_move, 11,


        /* special */
        hp300_setup, special, no_int, hp300_restore
 };
