-/* yForth? - Written by Luca Padovani (C) 1996/97
- * ------------------------------------------------------------------------
- * This software is FreeWare as long as it comes with this header in each
- * source file, anyway you can use it or any part of it whatever
- * you want. It comes without any warranty, so use it at your own risk.
+/* yForth? - A Forth interpreter written in ANSI C
+ * Copyright (C) 2012 Luca Padovani
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
* ------------------------------------------------------------------------
* Module name: udio.c
* Abstract: User Device Input/Output functions. Here are enclosed all
*/
#include "yforth.h"
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
# include <conio.h>
-#elifdef HAVE_CURSES
-# include <curses.h>
#endif
#include "udio.h"
/* d_clrscr: clear the screen */
void d_clrscr() {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
clrscr();
-#elifdef HAVE_CURSES
- clear();
#endif
}
/* d_clreol: clear to end of line */
void d_clreol() {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
clreol();
-#elifdef HAVE_CURSES
- clrtoeol();
#endif
}
/* d_setattr: set default attributes */
void d_setaddr(Cell attr) {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
textattr(attr);
-#elifdef HAVE_CURSES
#endif
}
/* d_getattr: get default attributes */
Cell d_getattr() {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
struct text_info ti;
gettextinfo(&ti);
return (ti.attribute);
-#elifdef HAVE_CURSES
#endif
}
/* d_gotoxy: move the cursor to the location (x, y) of the screen */
void d_gotoxy(Cell x, Cell y) {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
gotoxy(x, y);
-#elifdef HAVE_CURSES
- move(y, x);
#endif
}
/* d_wherex: current column position of the cursor */
Cell d_wherex() {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
return (wherex());
-#elifdef HAVE_CURSES
- int x, y;
- getyx(stdscr, y, x);
- return ((Cell) x);
#endif
}
/* d_wherey: current row position of the cursor */
Cell d_wherey() {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
return (wherey());
-#elifdef HAVE_CURSES
- int x, y;
- getyx(stdscr, y, x);
- return ((Cell) y);
#endif
}
* Return
*/
Char d_getch() {
-#ifdef HAVE_CONIO
- return (getch());
-#elifdef HAVE_CURSES
+#if HAVE_CONIO
return (getch());
#endif
}
/* d_kbhit: return True if a character is available */
Cell d_kbhit() {
-#ifdef HAVE_CONIO
+#if HAVE_CONIO
return (kbhit());
-#elifdef HAVE_CURSES
- return (1);
-#endif
+#endif
}
/* d_open: Initialize the Input/Output device */
void d_open() {
-#ifdef HAVE_CURSES
- initscr();
- cbreak();
- noecho();
- nonl();
- /* intrflush(stdscr, FALSE); */
- /* keypad(stdscr, TRUE); */
-#endif
-}
+}
/* d_close: make some work when program finish to restore Input/Output device */
void d_close() {
-#ifdef HAVE_CURSES
- endwin();
-#endif
}