VPDF compiles and links but exits early after start.
[AROS-Contrib.git] / rexx / src / rxconio.c
blob1d55d9f1b74212849cd7a7d6aafa2b1b245671f5
1 /*
2 ||
3 || Some <conio.h> functions for BREXX
4 || Fully compatible with ansi.r by bnv
5 ||
6 || 13-Feb-1999 by Generoso Martello (generoso@martello.com)
7 ||
8 */
10 #include <conio.h>
12 #include <rexx.h>
13 #include <rxdefs.h>
14 #include <rxconio.h>
16 /* -------------------------------------------------------------- */
17 /* ANSICLS() */
18 /* -------------------------------------------------------------- */
19 /* ANSIERASEEOL() */
20 /* -------------------------------------------------------------- */
21 /* ANSIDELLINE() */
22 /* -------------------------------------------------------------- */
23 /* ANSIINSLINE() */
24 /* -------------------------------------------------------------- */
25 /* ANSISAVECURSOR() */
26 /* -------------------------------------------------------------- */
27 /* ANSILOADCURSOR() */
28 /* -------------------------------------------------------------- */
29 /* GETCH() */
30 /* -------------------------------------------------------------- */
31 /* KBHIT() */
32 /* -------------------------------------------------------------- */
33 /* WHEREX() */
34 /* -------------------------------------------------------------- */
35 /* WHEREY() */
36 /* -------------------------------------------------------------- */
37 void R_conio_O( const int func ) {
38 if (ARGN) Lerror(ERR_INCORRECT_CALL,0);
39 switch (func) {
40 case f_ansicls:
41 ANSI_CLEAR_SCREEN();
42 break;
43 case f_ansieraseeol:
44 ANSI_ERASE_EOL();
45 break;
46 case f_ansidelline:
47 delline();
48 break;
49 case f_ansiinsline:
50 insline();
51 break;
52 case f_ansisavecursor:
53 ANSI_SAVE_CURSOR();
54 break;
55 case f_ansiloadcursor:
56 ANSI_LOAD_CURSOR();
57 break;
58 case f_getch:
59 LTYPE(*ARGR) = LSTRING_TY;
60 LLEN(*ARGR) = 1;
61 LSTR(*ARGR)[0] = getch();
62 break;
63 case f_kbhit:
64 LTYPE(*ARGR) = LSTRING_TY;
65 LLEN(*ARGR) = 1;
66 Licpy(ARGR,kbhit());
67 break;
68 case f_wherex:
69 LTYPE(*ARGR) = LINTEGER_TY;
70 LLEN(*ARGR) = 1;
71 Licpy(ARGR,wherex());
72 break;
73 case f_wherey:
74 LTYPE(*ARGR) = LINTEGER_TY;
75 LLEN(*ARGR) = 1;
76 Licpy(ARGR,wherey());
77 break;
78 default:
79 Lerror(ERR_INTERPRETER_FAILURE,0);
83 /* -------------------------------------------------------------- */
84 /* ANSIMODE((mode)) */
85 /* -------------------------------------------------------------- */
86 /* ANSIATTR((attr)) */
87 /* -------------------------------------------------------------- */
88 /* [ANSI]SETCURSOR((type)) */
89 /* -------------------------------------------------------------- */
90 void R_conio_C( const int func ) {
91 int i;
92 if (ARGN!=1) Lerror(ERR_INCORRECT_CALL,0);
93 L2STR(ARG1);
94 switch (func) {
95 case f_ansimode:
96 i=LASTMODE;
97 if (Lcmp(ARG1,"LASTMODE")==0) i=LASTMODE;
98 else if (Lcmp(ARG1,"BW40") ==0) i=BW40;
99 else if (Lcmp(ARG1,"C40") ==0) i=C40;
100 else if (Lcmp(ARG1,"BW80") ==0) i=BW80;
101 else if (Lcmp(ARG1,"C80") ==0) i=C80;
102 else if (Lcmp(ARG1,"MONO") ==0) i=MONO;
103 else if (Lcmp(ARG1,"C4350") ==0) i=C4350;
104 else if (Lcmp(ARG1,"0") ==0) i=C40;
105 else if (Lcmp(ARG1,"1") ==0) i=BW40;
106 else if (Lcmp(ARG1,"3") ==0) i=C80;
107 ANSI_MODE(i);
108 break;
109 case f_ansiattr:
110 if (Lcmp(ARG1,"NORMAL") ==0) i=0;
111 else if (Lcmp(ARG1,"BOLD") ==0) i=1;
112 else if (Lcmp(ARG1,"UNDERLINED")==0) i=2;
113 else if (Lcmp(ARG1,"BLINK") ==0) i=3;
114 else if (Lcmp(ARG1,"REVERSE") ==0) i=4;
115 else if (Lcmp(ARG1,"UNVISIBLE") ==0) i=5;
116 else i=0;
117 ANSI_ATTR(i);
118 break;
119 case f_setcursor:
120 i=-1;
121 if (Lcmp(ARG1,"OFF") ==0) i=_NOCURSOR;
122 else if (Lcmp(ARG1,"SOLID") ==0) i=_SOLIDCURSOR;
123 else if (Lcmp(ARG1,"NORMAL")==0) i=_NORMALCURSOR;
124 if (i!=-1) _setcursortype(i);
125 break;
126 default:
127 Lerror(ERR_INTERPRETER_FAILURE,0);
131 /* -------------------------------------------------------------- */
132 /* ANSICURSORUP((n)) */
133 /* -------------------------------------------------------------- */
134 /* ANSICURSORDOWN((n)) */
135 /* -------------------------------------------------------------- */
136 /* ANSICURSORRIGHT((n)) */
137 /* -------------------------------------------------------------- */
138 /* ANSICURSORLEFT((n)) */
139 /* -------------------------------------------------------------- */
140 void R_conio_I( const int func ) {
141 if (ARGN!=1) Lerror(ERR_INCORRECT_CALL,0);
142 L2INT(ARG1);
143 switch (func) {
144 case f_ansicursorup:
145 ANSI_CURSOR_UP(LINT(*ARG1));
146 break;
147 case f_ansicursordown:
148 ANSI_CURSOR_DOWN(LINT(*ARG1));
149 break;
150 case f_ansicursorright:
151 ANSI_CURSOR_RIGHT(LINT(*ARG1));
152 break;
153 case f_ansicursorleft:
154 ANSI_CURSOR_LEFT(LINT(*ARG1));
155 break;
156 default:
157 Lerror(ERR_INTERPRETER_FAILURE,0);
161 /* -------------------------------------------------------------- */
162 /* ANSICOLOR((forecolor)[,(backcolor)]) */
163 /* -------------------------------------------------------------- */
164 void R_conio_ansicolor() {
165 int i=-1, j=-1;
166 if ((ARGN<1) || (ARGN>2)) Lerror(ERR_INCORRECT_CALL,0);
167 L2STR(ARG1);
168 if (Lcmp(ARG1,"BLACK") ==0) i=BLACK;
169 else if (Lcmp(ARG1,"BLUE") ==0) i=BLUE;
170 else if (Lcmp(ARG1,"GREEN") ==0) i=GREEN;
171 else if (Lcmp(ARG1,"CYAN") ==0) i=CYAN;
172 else if (Lcmp(ARG1,"RED") ==0) i=RED;
173 else if (Lcmp(ARG1,"MAGENTA") ==0) i=MAGENTA;
174 else if (Lcmp(ARG1,"YELLOW") ==0) i=YELLOW;
175 else if (Lcmp(ARG1,"WHITE") ==0) i=WHITE;
176 else if ((Lcmp(ARG1,"BROWN") ==0) || (Lcmp(ARG1,"BOLDYELLOW") ==0)) i=BROWN;
177 else if ((Lcmp(ARG1,"LIGHTGRAY") ==0) || (Lcmp(ARG1,"BOLDWHITE") ==0)) i=LIGHTGRAY;
178 else if ((Lcmp(ARG1,"DARKGRAY") ==0) || (Lcmp(ARG1,"BOLDBLACK") ==0)) i=DARKGRAY;
179 else if ((Lcmp(ARG1,"LIGHTBLUE") ==0) || (Lcmp(ARG1,"BOLDBLUE") ==0)) i=LIGHTBLUE;
180 else if ((Lcmp(ARG1,"LIGHTGREEN") ==0) || (Lcmp(ARG1,"BOLDGREEN") ==0)) i=LIGHTGREEN;
181 else if ((Lcmp(ARG1,"LIGHTCYAN") ==0) || (Lcmp(ARG1,"BOLDCYAN") ==0)) i=LIGHTCYAN;
182 else if ((Lcmp(ARG1,"LIGHTRED") ==0) || (Lcmp(ARG1,"BOLDRED") ==0)) i=LIGHTRED;
183 else if ((Lcmp(ARG1,"LIGHTMAGENTA")==0) || (Lcmp(ARG1,"BOLDMAGENTA")==0)) i=LIGHTMAGENTA;
184 if (ARGN==2) {
185 L2STR(ARG2);
186 if (Lcmp(ARG2,"BLACK") ==0) j=BLACK;
187 else if (Lcmp(ARG2,"BLUE") ==0) j=BLUE;
188 else if (Lcmp(ARG2,"GREEN") ==0) j=GREEN;
189 else if (Lcmp(ARG2,"CYAN") ==0) j=CYAN;
190 else if (Lcmp(ARG2,"RED") ==0) j=RED;
191 else if (Lcmp(ARG2,"MAGENTA") ==0) j=MAGENTA;
192 else if (Lcmp(ARG2,"YELLOW") ==0) j=YELLOW;
193 else if (Lcmp(ARG2,"WHITE") ==0) j=WHITE;
195 if (j!=-1) { ANSI_COLOR(i,j); } else { ANSI_FG_LCOLOR(i); }
198 /* -------------------------------------------------------------- */
199 /* ANSIGOTO((x),(y)) */
200 /* -------------------------------------------------------------- */
201 void R_conio_ansigoto() {
202 if (ARGN!=2) Lerror(ERR_INCORRECT_CALL,0);
203 L2INT(ARG1);
204 L2INT(ARG2);
205 ANSI_GOTOXY(LINT(*ARG1),LINT(*ARG2));
208 void RxConIOInitialize() {
209 RxRegFunction("CLS", R_conio_O, f_ansicls);
210 RxRegFunction("ANSICLS", R_conio_O, f_ansicls);
211 RxRegFunction("ANSIERASEEOL", R_conio_O, f_ansieraseeol);
212 RxRegFunction("ANSIDELLINE", R_conio_O, f_ansidelline);
213 RxRegFunction("ANSIINSLINE", R_conio_O, f_ansiinsline);
214 RxRegFunction("ANSISAVECURSOR", R_conio_O, f_ansisavecursor);
215 RxRegFunction("ANSILOADCURSOR", R_conio_O, f_ansiloadcursor);
216 RxRegFunction("GETCH", R_conio_O, f_getch);
217 RxRegFunction("KBHIT", R_conio_O, f_kbhit);
218 RxRegFunction("WHEREX", R_conio_O, f_wherex);
219 RxRegFunction("WHEREY", R_conio_O, f_wherey);
220 RxRegFunction("ANSICURSORUP", R_conio_I, f_ansicursorup);
221 RxRegFunction("ANSICURSORDOWN", R_conio_I, f_ansicursordown);
222 RxRegFunction("ANSICURSORRIGHT", R_conio_I, f_ansicursorright);
223 RxRegFunction("ANSICURSORLEFT", R_conio_I, f_ansicursorleft);
224 RxRegFunction("ANSIMODE", R_conio_C, f_ansimode);
225 RxRegFunction("ANSIATTR", R_conio_C, f_ansiattr);
226 RxRegFunction("SETCURSOR", R_conio_C, f_setcursor);
227 RxRegFunction("ANSISETCURSOR", R_conio_C, f_setcursor);
228 RxRegFunction("ANSIGOTO", R_conio_ansigoto, 0);
229 RxRegFunction("ANSICOLOR", R_conio_ansicolor, 0);