2005-05-31 11:50:56 -04:00
|
|
|
/* ANSI.C
|
|
|
|
*
|
|
|
|
* The routines in this file provide support for ANSI style terminals
|
|
|
|
* over a serial line. The serial I/O services are provided by routines in
|
|
|
|
* "termio.c". It compiles into nothing if not an ANSI device.
|
|
|
|
*
|
|
|
|
* modified by Petri Kutvonen
|
|
|
|
*/
|
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
#define termdef 1 /* don't define "term" external */
|
2005-05-31 11:50:56 -04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "estruct.h"
|
|
|
|
#include "edef.h"
|
|
|
|
|
|
|
|
#if ANSI
|
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
#define NROW 25 /* Screen size. */
|
|
|
|
#define NCOL 80 /* Edit if you want to. */
|
2005-05-31 11:50:56 -04:00
|
|
|
|
|
|
|
#if PKCODE
|
|
|
|
#define MROW 64
|
|
|
|
#endif
|
2005-09-30 18:26:09 -04:00
|
|
|
#define NPAUSE 100 /* # times thru update to pause */
|
|
|
|
#define MARGIN 8 /* size of minimim margin and */
|
|
|
|
#define SCRSIZ 64 /* scroll size for extended lines */
|
|
|
|
#define BEL 0x07 /* BEL character. */
|
|
|
|
#define ESC 0x1B /* ESC character. */
|
|
|
|
|
|
|
|
extern int ttopen(); /* Forward references. */
|
|
|
|
extern int ttgetc();
|
|
|
|
extern int ttputc();
|
|
|
|
extern int ttflush();
|
|
|
|
extern int ttclose();
|
|
|
|
extern int ansimove();
|
|
|
|
extern int ansieeol();
|
|
|
|
extern int ansieeop();
|
|
|
|
extern int ansibeep();
|
|
|
|
extern int ansiopen();
|
|
|
|
extern int ansirev();
|
|
|
|
extern int ansiclose();
|
|
|
|
extern int ansikopen();
|
|
|
|
extern int ansikclose();
|
|
|
|
extern int ansicres();
|
2005-05-31 11:50:56 -04:00
|
|
|
|
|
|
|
#if COLOR
|
2005-09-30 18:26:09 -04:00
|
|
|
extern int ansifcol();
|
|
|
|
extern int ansibcol();
|
2005-05-31 11:50:56 -04:00
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
int cfcolor = -1; /* current forground color */
|
|
|
|
int cbcolor = -1; /* current background color */
|
2005-05-31 11:50:56 -04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Standard terminal interface dispatch table. Most of the fields point into
|
|
|
|
* "termio" code.
|
|
|
|
*/
|
2005-09-30 18:26:09 -04:00
|
|
|
TERM term = {
|
2005-05-31 11:50:56 -04:00
|
|
|
#if PKCODE
|
2005-09-30 18:26:09 -04:00
|
|
|
MROW - 1,
|
2005-05-31 11:50:56 -04:00
|
|
|
#else
|
2005-09-30 18:26:09 -04:00
|
|
|
NROW - 1,
|
2005-05-31 11:50:56 -04:00
|
|
|
#endif
|
2005-09-30 18:26:09 -04:00
|
|
|
NROW - 1,
|
|
|
|
NCOL,
|
|
|
|
NCOL,
|
2005-05-31 11:50:56 -04:00
|
|
|
MARGIN,
|
|
|
|
SCRSIZ,
|
|
|
|
NPAUSE,
|
2005-09-30 18:26:09 -04:00
|
|
|
ansiopen,
|
|
|
|
ansiclose,
|
2005-05-31 11:50:56 -04:00
|
|
|
ansikopen,
|
|
|
|
ansikclose,
|
2005-09-30 18:26:09 -04:00
|
|
|
ttgetc,
|
|
|
|
ttputc,
|
|
|
|
ttflush,
|
|
|
|
ansimove,
|
|
|
|
ansieeol,
|
|
|
|
ansieeop,
|
|
|
|
ansibeep,
|
2005-05-31 11:50:56 -04:00
|
|
|
ansirev,
|
|
|
|
ansicres
|
|
|
|
#if COLOR
|
2005-09-30 18:26:09 -04:00
|
|
|
, ansifcol,
|
2005-05-31 11:50:56 -04:00
|
|
|
ansibcol
|
|
|
|
#endif
|
|
|
|
#if SCROLLCODE
|
2005-09-30 18:26:09 -04:00
|
|
|
, NULL
|
2005-05-31 11:50:56 -04:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#if COLOR
|
2005-09-30 18:26:09 -04:00
|
|
|
ansifcol(color)
|
|
|
|
/* set the current output color */
|
|
|
|
int color; /* color to set */
|
2005-05-31 11:50:56 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
if (color == cfcolor)
|
|
|
|
return;
|
|
|
|
ttputc(ESC);
|
|
|
|
ttputc('[');
|
2005-09-30 18:26:09 -04:00
|
|
|
ansiparm(color + 30);
|
2005-05-31 11:50:56 -04:00
|
|
|
ttputc('m');
|
|
|
|
cfcolor = color;
|
|
|
|
}
|
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
ansibcol(color)
|
|
|
|
/* set the current background color */
|
|
|
|
int color; /* color to set */
|
2005-05-31 11:50:56 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
if (color == cbcolor)
|
|
|
|
return;
|
|
|
|
ttputc(ESC);
|
|
|
|
ttputc('[');
|
2005-09-30 18:26:09 -04:00
|
|
|
ansiparm(color + 40);
|
2005-05-31 11:50:56 -04:00
|
|
|
ttputc('m');
|
2005-09-30 18:26:09 -04:00
|
|
|
cbcolor = color;
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ansimove(row, col)
|
|
|
|
{
|
2005-09-30 18:26:09 -04:00
|
|
|
ttputc(ESC);
|
|
|
|
ttputc('[');
|
|
|
|
ansiparm(row + 1);
|
|
|
|
ttputc(';');
|
|
|
|
ansiparm(col + 1);
|
|
|
|
ttputc('H');
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ansieeol()
|
|
|
|
{
|
2005-09-30 18:26:09 -04:00
|
|
|
ttputc(ESC);
|
|
|
|
ttputc('[');
|
|
|
|
ttputc('K');
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ansieeop()
|
|
|
|
{
|
|
|
|
#if COLOR
|
|
|
|
ansifcol(gfcolor);
|
|
|
|
ansibcol(gbcolor);
|
|
|
|
#endif
|
2005-09-30 18:26:09 -04:00
|
|
|
ttputc(ESC);
|
|
|
|
ttputc('[');
|
|
|
|
ttputc('J');
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
ansirev(state)
|
|
|
|
/* change reverse video state */
|
|
|
|
int state; /* TRUE = reverse, FALSE = normal */
|
2005-05-31 11:50:56 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
#if COLOR
|
|
|
|
int ftmp, btmp; /* temporaries for colors */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ttputc(ESC);
|
|
|
|
ttputc('[');
|
2005-09-30 18:26:09 -04:00
|
|
|
ttputc(state ? '7' : '0');
|
2005-05-31 11:50:56 -04:00
|
|
|
ttputc('m');
|
|
|
|
#if COLOR
|
|
|
|
if (state == FALSE) {
|
|
|
|
ftmp = cfcolor;
|
|
|
|
btmp = cbcolor;
|
|
|
|
cfcolor = -1;
|
|
|
|
cbcolor = -1;
|
|
|
|
ansifcol(ftmp);
|
|
|
|
ansibcol(btmp);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
ansicres()
|
|
|
|
{ /* change screen resolution */
|
|
|
|
return (TRUE);
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
spal(dummy)
|
|
|
|
{ /* change pallette settings */
|
2005-05-31 11:50:56 -04:00
|
|
|
/* none for now */
|
|
|
|
}
|
|
|
|
|
|
|
|
ansibeep()
|
|
|
|
{
|
2005-09-30 18:26:09 -04:00
|
|
|
ttputc(BEL);
|
|
|
|
ttflush();
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ansiparm(n)
|
2005-09-30 18:26:09 -04:00
|
|
|
register int n;
|
2005-05-31 11:50:56 -04:00
|
|
|
{
|
2005-09-30 18:26:09 -04:00
|
|
|
register int q, r;
|
2005-05-31 11:50:56 -04:00
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
q = n / 10;
|
|
|
|
if (q != 0) {
|
|
|
|
r = q / 10;
|
2005-05-31 11:50:56 -04:00
|
|
|
if (r != 0) {
|
2005-09-30 18:26:09 -04:00
|
|
|
ttputc((r % 10) + '0');
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
2005-09-30 18:26:09 -04:00
|
|
|
ttputc((q % 10) + '0');
|
|
|
|
}
|
|
|
|
ttputc((n % 10) + '0');
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ansiopen()
|
|
|
|
{
|
|
|
|
#if V7 | USG | BSD
|
2005-09-30 18:26:09 -04:00
|
|
|
register char *cp;
|
|
|
|
char *getenv();
|
|
|
|
|
|
|
|
if ((cp = getenv("TERM")) == NULL) {
|
|
|
|
puts("Shell variable TERM not defined!");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (strcmp(cp, "vt100") != 0) {
|
|
|
|
puts("Terminal type not 'vt100'!");
|
|
|
|
exit(1);
|
|
|
|
}
|
2005-05-31 11:50:56 -04:00
|
|
|
#endif
|
|
|
|
strcpy(sres, "NORMAL");
|
|
|
|
revexist = TRUE;
|
2005-09-30 18:26:09 -04:00
|
|
|
ttopen();
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ansiclose()
|
|
|
|
{
|
|
|
|
#if COLOR
|
|
|
|
ansifcol(7);
|
|
|
|
ansibcol(0);
|
|
|
|
#endif
|
|
|
|
ttclose();
|
|
|
|
}
|
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
ansikopen()
|
|
|
|
{ /* open the keyboard (a noop here) */
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
ansikclose()
|
|
|
|
{ /* close the keyboard (a noop here) */
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#if FNLABEL
|
2005-09-30 18:26:09 -04:00
|
|
|
fnclabel(f, n)
|
|
|
|
/* label a function key */
|
|
|
|
int f, n; /* default flag, numeric argument [unused] */
|
2005-05-31 11:50:56 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
/* on machines with no function keys...don't bother */
|
2005-09-30 18:26:09 -04:00
|
|
|
return (TRUE);
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
ansihello()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|