]> gitweb.factorcode.org Git - factor.git/blob - extra/curses/ffi/ffi.factor
replace all TYPEDEF: void* XXX* with C-TYPE: XXX
[factor.git] / extra / curses / ffi / ffi.factor
1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien alien.syntax combinators kernel system
4 alien.libraries classes.struct ;
5 IN: curses.ffi
6
7 << "curses" {
8     { [ os winnt? ]  [ "libcurses.dll" ] }
9     { [ os macosx? ] [ "libcurses.dylib" ] }
10     { [ os unix?  ]  [ "libcurses.so" ] }
11 } cond "cdecl" add-library >>
12
13 C-TYPE: WINDOW
14 C-TYPE: SCREEN
15 TYPEDEF: void* va_list
16
17 TYPEDEF: uint chtype
18 TYPEDEF: chtype attr_t
19 TYPEDEF: short NCURSES_SIZE_T
20 TYPEDEF: ushort wchar_t
21
22 CONSTANT: CCHARW_MAX  5
23
24 STRUCT: cchar_t
25     { attr attr_t }
26     { chars { wchar_t CCHARW_MAX } } ;
27
28 STRUCT: pdat
29     { _pad_y NCURSES_SIZE_T }
30     { _pad_x NCURSES_SIZE_T }
31     { _pad_top NCURSES_SIZE_T }
32     { _pad_left NCURSES_SIZE_T }
33     { _pad_bottom NCURSES_SIZE_T }
34     { _pad_right NCURSES_SIZE_T } ;
35
36 STRUCT: c-window
37     { _cury NCURSES_SIZE_T }
38     { _curx NCURSES_SIZE_T }
39
40     { _maxy NCURSES_SIZE_T }
41     { _maxx NCURSES_SIZE_T }
42     { _begy NCURSES_SIZE_T }
43     { _begx NCURSES_SIZE_T }
44
45     { _flags short  }
46
47     { _attrs attr_t  }
48     { _bkgd chtype  }
49
50     { _notimeout bool    }
51     { _clear bool    }
52     { _leaveok bool    }
53     { _scroll bool    }
54     { _idlok bool    }
55     { _idcok bool    }
56     { _immed bool    }
57     { _sync bool    }
58     { _use_keypad bool    }
59     { _delay int     }
60
61     { _line char* }
62     { _regtop NCURSES_SIZE_T }
63     { _regbottom NCURSES_SIZE_T }
64
65     { _parx int }
66     { _pary int }
67     { _parent WINDOW* }
68
69     { _pad pdat }
70
71     { _yoffset NCURSES_SIZE_T }
72
73     { _bkgrnd cchar_t  } ;
74
75 LIBRARY: curses
76
77 : stdscr ( -- alien )
78     "stdscr" "curses" library dll>> dlsym ;
79
80 FUNCTION: WINDOW* initscr ( ) ;
81 FUNCTION: int endwin ( ) ;
82 FUNCTION: bool isendwin ( ) ;
83 FUNCTION: SCREEN* newterm ( char* type, FILE* outfd, FILE* infd ) ;
84 FUNCTION: SCREEN* set_term ( SCREEN* new ) ;
85 FUNCTION: void delscreen ( SCREEN* sp ) ;
86
87 FUNCTION: int def_prog_mode ( ) ;
88 FUNCTION: int def_shell_mode ( ) ;
89 FUNCTION: int reset_prog_mode ( ) ;
90 FUNCTION: int reset_shell_mode ( ) ;
91 FUNCTION: int resetty ( ) ;
92 FUNCTION: int savetty ( ) ;
93 FUNCTION: int ripoffline ( int line, void* callback ) ;
94 FUNCTION: int curs_set ( int visibility ) ;
95 FUNCTION: int napms ( int ms ) ;
96
97 FUNCTION: WINDOW* newwin ( int nlines, int ncols, int begin_y, int begin_x ) ;
98 FUNCTION: int delwin ( WINDOW* win ) ;
99 FUNCTION: int mvwin ( WINDOW* win, int y, int x ) ;
100 FUNCTION: WINDOW* subwin ( WINDOW* orig, int nlines, int ncols, int begin_y, int begin_x ) ;
101 FUNCTION: WINDOW* derwin ( WINDOW* orig, int nlines, int ncols, int begin_y, int begin_x ) ;
102 FUNCTION: int mvderwin ( WINDOW* win, int par_y, int par_x ) ;
103 FUNCTION: WINDOW* dupwin ( WINDOW* win ) ;
104 FUNCTION: void wsyncup ( WINDOW* win ) ;
105 FUNCTION: int syncok ( WINDOW* win, bool bf ) ;
106 FUNCTION: void wcursyncup ( WINDOW* win ) ;
107 FUNCTION: void wsyncdown ( WINDOW* win ) ;
108
109 FUNCTION: int cbreak ( ) ;
110 FUNCTION: int nocbreak ( ) ;
111 FUNCTION: int echo ( ) ;
112 FUNCTION: int noecho ( ) ;
113 FUNCTION: int halfdelay ( int tenths ) ;
114 FUNCTION: int intrflush ( WINDOW* win, bool bf ) ;
115 FUNCTION: int keypad ( WINDOW* win, bool bf ) ;
116 FUNCTION: int meta ( WINDOW* win, bool bf ) ;
117 FUNCTION: int nodelay ( WINDOW* win, bool bf ) ;
118 FUNCTION: int raw ( ) ;
119 FUNCTION: int noraw ( ) ;
120 FUNCTION: void noqiflush ( ) ;
121 FUNCTION: void qiflush ( ) ;
122 FUNCTION: int notimeout ( WINDOW* win, bool bf ) ;
123 FUNCTION: void timeout ( int delay ) ;
124 FUNCTION: void wtimeout ( WINDOW* win, int delay ) ;
125 FUNCTION: int typeahead ( int fd ) ;
126
127 FUNCTION: int clearok ( WINDOW* win, bool bf ) ;
128 FUNCTION: int idlok ( WINDOW* win, bool bf ) ;
129 FUNCTION: void idcok ( WINDOW* win, bool bf ) ;
130 FUNCTION: void immedok ( WINDOW* win, bool bf ) ;
131 FUNCTION: int leaveok ( WINDOW* win, bool bf ) ;
132 FUNCTION: int setscrreg ( int top, int bot ) ;
133 FUNCTION: int wsetscrreg ( WINDOW* win, int top, int bot ) ;
134 FUNCTION: int scrollok ( WINDOW* win, bool bf ) ;
135 FUNCTION: int nl ( ) ;
136 FUNCTION: int nonl ( ) ;
137
138 FUNCTION: int erase (  ) ;
139 FUNCTION: int werase ( WINDOW* win ) ;
140 FUNCTION: int clear (  ) ;
141 FUNCTION: int wclear ( WINDOW* win ) ;
142 FUNCTION: int clrtobot (  ) ;
143 FUNCTION: int wclrtobot ( WINDOW* win ) ;
144 FUNCTION: int clrtoeol (  ) ;
145 FUNCTION: int wclrtoeol ( WINDOW* win ) ;
146
147 FUNCTION: int refresh ( ) ;
148 FUNCTION: int wrefresh ( WINDOW* win ) ;
149 FUNCTION: int wnoutrefresh ( WINDOW* win ) ;
150 FUNCTION: int doupdate ( ) ;
151 FUNCTION: int redrawwin ( WINDOW* win ) ;
152 FUNCTION: int wredrawln ( WINDOW* win, int beg_line, int num_lines ) ;
153
154 FUNCTION: int getch ( ) ;
155 FUNCTION: int wgetch ( WINDOW* win ) ;
156 FUNCTION: int mvgetch ( int y, int x ) ;
157 FUNCTION: int mvwgetch ( WINDOW* win, int y, int x ) ;
158 FUNCTION: int ungetch ( int ch ) ;
159 FUNCTION: int has_key ( int ch ) ;
160
161 FUNCTION: int getstr ( char* str ) ;
162 FUNCTION: int getnstr ( char* str, int n ) ;
163 FUNCTION: int wgetstr ( WINDOW* win, char* str ) ;
164 FUNCTION: int wgetnstr ( WINDOW* win, char* str, int n ) ;
165 FUNCTION: int mvgetstr ( int y, int x, char* str ) ;
166 FUNCTION: int mvwgetstr ( WINDOW* win, int y, int x, char* str ) ;
167 FUNCTION: int mvgetnstr ( int y, int x, char* str, int n ) ;
168 FUNCTION: int mvwgetnstr ( WINDOW* win, int y, int x, char* str, int n ) ;
169
170 FUNCTION: int printw ( char* fmt, int lol ) ;
171 FUNCTION: int wprintw ( WINDOW* win, char* fmt, int lol ) ;
172 FUNCTION: int mvprintw ( int y, int x, char* fmt, int lol ) ;
173 FUNCTION: int mvwprintw ( WINDOW* win, int y, int x, char* fmt, int lol ) ;
174 FUNCTION: int vwprintw ( WINDOW* win, char* fmt, va_list varglist ) ;
175 FUNCTION: int vw_printw ( WINDOW* win, char* fmt, va_list varglist ) ;
176
177 FUNCTION: int move ( int y, int x ) ;
178 FUNCTION: int wmove ( WINDOW* win, int y, int x ) ;
179
180
181 FUNCTION: int scroll ( WINDOW* win ) ;
182 FUNCTION: int scrl ( int n ) ;
183 FUNCTION: int wscrl ( WINDOW* win, int n ) ;
184
185        ! int setupterm(char *term, int fildes, int *errret);
186        ! int setterm(char *term);
187        ! TERMINAL *set_curterm(TERMINAL *nterm);
188        ! int del_curterm(TERMINAL *oterm);
189        ! int restartterm(const char *term, int fildes, int *errret);
190        ! char *tparm(char *str, ...);
191        ! int tputs(const char *str, int affcnt, int (*putc)(int));
192        ! int putp(const char *str);
193        ! int vidputs(chtype attrs, int (*putc)(int));
194        ! int vidattr(chtype attrs);
195        ! int vid_puts(attr_t attrs, short pair, void *opts, int (*putc)(char));
196        ! int vid_attr(attr_t attrs, short pair, void *opts);
197 FUNCTION: int mvcur ( int oldrow, int oldcol, int newrow, int newcol ) ;
198        ! int tigetflag(char *capname);
199        ! int tigetnum(char *capname);
200        ! char *tigetstr(char *capname);
201
202 FUNCTION: int touchwin ( WINDOW* win ) ;
203 FUNCTION: int touchline ( WINDOW* win, int start, int count ) ;
204 FUNCTION: int untouchwin ( WINDOW* win ) ;
205 FUNCTION: int wtouchln ( WINDOW* win, int y, int n, int changed ) ;
206 FUNCTION: bool is_linetouched ( WINDOW* win, int line ) ;
207 FUNCTION: bool is_wintouched ( WINDOW* win ) ;
208
209 FUNCTION: int insch ( chtype ch ) ;
210 FUNCTION: int winsch ( WINDOW* win, chtype ch ) ;
211 FUNCTION: int mvinsch ( int y, int x, chtype ch ) ;
212 FUNCTION: int mvwinsch ( WINDOW* win, int y, int x, chtype ch ) ;
213 FUNCTION: int delch ( ) ;
214 FUNCTION: int wdelch ( WINDOW* win ) ;
215 FUNCTION: int mvdelch ( int y, int x ) ;
216 FUNCTION: int mvwdelch ( WINDOW* win, int y, int x ) ;
217
218 FUNCTION: int deleteln ( ) ;
219 FUNCTION: int wdeleteln ( WINDOW* win ) ;
220 FUNCTION: int insdelln ( int n ) ;
221 FUNCTION: int winsdelln ( WINDOW* win, int n ) ;
222 FUNCTION: int insertln ( ) ;
223 FUNCTION: int winsertln ( WINDOW* win ) ;
224
225 FUNCTION: int addstr ( char* str ) ;
226 FUNCTION: int addnstr ( char* str, int n ) ;
227 FUNCTION: int waddstr ( WINDOW* win, char* str ) ;
228 FUNCTION: int waddnstr ( WINDOW* win, char* str, int n ) ;
229 FUNCTION: int mvaddstr ( int y, int x, char* str ) ;
230 FUNCTION: int mvaddnstr ( int y, int x, char* str, int n ) ;
231 FUNCTION: int mvwaddstr ( WINDOW* win, int y, int x, char* str ) ;
232 FUNCTION: int mvwaddnstr ( WINDOW* win, int y, int x, char* str, int n ) ;