Same fix as r45172 for classes/iconimage:
[AROS-Contrib.git] / fish / microemacs / ansi.c
blobc8921a53927f8bc43e26a1bdf5b6ce754e8120ff
1 /*
2 * The routines in this file provide support for ANSI style terminals
3 * over a serial line. The serial I/O services are provided by routines in
4 * "termio.c". It compiles into nothing if not an ANSI device.
5 */
7 #include <stdio.h>
8 #include "ed.h"
10 #if ANSI
12 #define NROW 23 /* Screen size. */
13 #define NCOL 77 /* Edit if you want to. */
14 #define BEL 0x07 /* BEL character. */
15 #define ESC 0x1B /* ESC character. */
17 extern int ttopen(); /* Forward references. */
18 extern int ttgetc();
19 extern int ttputc();
20 extern int ttflush();
21 extern int ttclose();
22 extern int ansimove();
23 extern int ansieeol();
24 extern int ansieeop();
25 extern int ansibeep();
26 extern int ansiopen();
27 extern int ansiparm();
30 * Standard terminal interface dispatch table. Most of the fields point into
31 * "termio" code.
33 TERM term = {
34 NROW-1,
35 NCOL,
36 &ansiopen,
37 &ttclose,
38 &ttgetc,
39 &ttputc,
40 &ttflush,
41 &ansimove,
42 &ansieeol,
43 &ansieeop,
44 &ansibeep
47 int ansimove(row, col)
48 int row;
49 int col;
51 ttputc(ESC);
52 ttputc('[');
53 ansiparm(row+1);
54 ttputc(';');
55 ansiparm(col+1);
56 ttputc('H');
57 return 0;
60 int ansieeol()
62 ttputc(ESC);
63 ttputc('[');
64 ttputc('K');
65 return 0;
68 int ansieeop()
70 ttputc(ESC);
71 ttputc('[');
72 ttputc('J');
73 return 0;
76 int ansibeep()
78 ttputc(BEL);
79 ttflush();
80 return 0;
83 int ansiparm(n)
84 register int n;
86 register int q;
88 q = n/10;
89 if (q != 0)
90 ansiparm(q);
91 ttputc((n%10) + '0');
92 return 0;
95 #endif
97 int ansiopen(void)
99 #if V7
100 register char *cp;
101 char *getenv();
103 if ((cp = getenv("TERM")) == NULL) {
104 puts("Shell variable TERM not defined!");
105 exit(1);
107 if (strcmp(cp, "vt100") != 0) {
108 puts("Terminal type not 'vt100'!");
109 exit(1);
111 #endif
112 ttopen();
113 return 0;