]> gitweb.factorcode.org Git - factor.git/blob - extra/curses/ffi/ffi.factor
a9edc2e92b1316646ec5eced97aac243725a803f
[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.c-types alien.libraries classes.struct unix.types ;
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 C-GLOBAL: void* stdscr
78
79 FUNCTION: WINDOW* initscr ( ) ;
80 FUNCTION: int endwin ( ) ;
81 FUNCTION: bool isendwin ( ) ;
82 FUNCTION: SCREEN* newterm ( char* type, FILE* outfd, FILE* infd ) ;
83 FUNCTION: SCREEN* set_term ( SCREEN* new ) ;
84 FUNCTION: void delscreen ( SCREEN* sp ) ;
85
86 FUNCTION: int def_prog_mode ( ) ;
87 FUNCTION: int def_shell_mode ( ) ;
88 FUNCTION: int reset_prog_mode ( ) ;
89 FUNCTION: int reset_shell_mode ( ) ;
90 FUNCTION: int resetty ( ) ;
91 FUNCTION: int savetty ( ) ;
92 FUNCTION: int ripoffline ( int line, void* callback ) ;
93 FUNCTION: int curs_set ( int visibility ) ;
94 FUNCTION: int napms ( int ms ) ;
95
96 FUNCTION: WINDOW* newwin ( int nlines, int ncols, int begin_y, int begin_x ) ;
97 FUNCTION: int delwin ( WINDOW* win ) ;
98 FUNCTION: int mvwin ( WINDOW* win, int y, int x ) ;
99 FUNCTION: WINDOW* subwin ( WINDOW* orig, int nlines, int ncols, int begin_y, int begin_x ) ;
100 FUNCTION: WINDOW* derwin ( WINDOW* orig, int nlines, int ncols, int begin_y, int begin_x ) ;
101 FUNCTION: int mvderwin ( WINDOW* win, int par_y, int par_x ) ;
102 FUNCTION: WINDOW* dupwin ( WINDOW* win ) ;
103 FUNCTION: void wsyncup ( WINDOW* win ) ;
104 FUNCTION: int syncok ( WINDOW* win, bool bf ) ;
105 FUNCTION: void wcursyncup ( WINDOW* win ) ;
106 FUNCTION: void wsyncdown ( WINDOW* win ) ;
107
108 FUNCTION: int cbreak ( ) ;
109 FUNCTION: int nocbreak ( ) ;
110 FUNCTION: int echo ( ) ;
111 FUNCTION: int noecho ( ) ;
112 FUNCTION: int halfdelay ( int tenths ) ;
113 FUNCTION: int intrflush ( WINDOW* win, bool bf ) ;
114 FUNCTION: int keypad ( WINDOW* win, bool bf ) ;
115 FUNCTION: int meta ( WINDOW* win, bool bf ) ;
116 FUNCTION: int nodelay ( WINDOW* win, bool bf ) ;
117 FUNCTION: int raw ( ) ;
118 FUNCTION: int noraw ( ) ;
119 FUNCTION: void noqiflush ( ) ;
120 FUNCTION: void qiflush ( ) ;
121 FUNCTION: int notimeout ( WINDOW* win, bool bf ) ;
122 FUNCTION: void timeout ( int delay ) ;
123 FUNCTION: void wtimeout ( WINDOW* win, int delay ) ;
124 FUNCTION: int typeahead ( int fd ) ;
125
126 FUNCTION: int clearok ( WINDOW* win, bool bf ) ;
127 FUNCTION: int idlok ( WINDOW* win, bool bf ) ;
128 FUNCTION: void idcok ( WINDOW* win, bool bf ) ;
129 FUNCTION: void immedok ( WINDOW* win, bool bf ) ;
130 FUNCTION: int leaveok ( WINDOW* win, bool bf ) ;
131 FUNCTION: int setscrreg ( int top, int bot ) ;
132 FUNCTION: int wsetscrreg ( WINDOW* win, int top, int bot ) ;
133 FUNCTION: int scrollok ( WINDOW* win, bool bf ) ;
134 FUNCTION: int nl ( ) ;
135 FUNCTION: int nonl ( ) ;
136
137 FUNCTION: int erase (  ) ;
138 FUNCTION: int werase ( WINDOW* win ) ;
139 FUNCTION: int clear (  ) ;
140 FUNCTION: int wclear ( WINDOW* win ) ;
141 FUNCTION: int clrtobot (  ) ;
142 FUNCTION: int wclrtobot ( WINDOW* win ) ;
143 FUNCTION: int clrtoeol (  ) ;
144 FUNCTION: int wclrtoeol ( WINDOW* win ) ;
145
146 FUNCTION: int refresh ( ) ;
147 FUNCTION: int wrefresh ( WINDOW* win ) ;
148 FUNCTION: int wnoutrefresh ( WINDOW* win ) ;
149 FUNCTION: int doupdate ( ) ;
150 FUNCTION: int redrawwin ( WINDOW* win ) ;
151 FUNCTION: int wredrawln ( WINDOW* win, int beg_line, int num_lines ) ;
152
153 FUNCTION: int getch ( ) ;
154 FUNCTION: int wgetch ( WINDOW* win ) ;
155 FUNCTION: int mvgetch ( int y, int x ) ;
156 FUNCTION: int mvwgetch ( WINDOW* win, int y, int x ) ;
157 FUNCTION: int ungetch ( int ch ) ;
158 FUNCTION: int has_key ( int ch ) ;
159
160 FUNCTION: int getstr ( char* str ) ;
161 FUNCTION: int getnstr ( char* str, int n ) ;
162 FUNCTION: int wgetstr ( WINDOW* win, char* str ) ;
163 FUNCTION: int wgetnstr ( WINDOW* win, char* str, int n ) ;
164 FUNCTION: int mvgetstr ( int y, int x, char* str ) ;
165 FUNCTION: int mvwgetstr ( WINDOW* win, int y, int x, char* str ) ;
166 FUNCTION: int mvgetnstr ( int y, int x, char* str, int n ) ;
167 FUNCTION: int mvwgetnstr ( WINDOW* win, int y, int x, char* str, int n ) ;
168
169 FUNCTION: int printw ( char* fmt, int lol ) ;
170 FUNCTION: int wprintw ( WINDOW* win, char* fmt, int lol ) ;
171 FUNCTION: int mvprintw ( int y, int x, char* fmt, int lol ) ;
172 FUNCTION: int mvwprintw ( WINDOW* win, int y, int x, char* fmt, int lol ) ;
173 FUNCTION: int vwprintw ( WINDOW* win, char* fmt, va_list varglist ) ;
174 FUNCTION: int vw_printw ( WINDOW* win, char* fmt, va_list varglist ) ;
175
176 FUNCTION: int move ( int y, int x ) ;
177 FUNCTION: int wmove ( WINDOW* win, int y, int x ) ;
178
179
180 FUNCTION: int scroll ( WINDOW* win ) ;
181 FUNCTION: int scrl ( int n ) ;
182 FUNCTION: int wscrl ( WINDOW* win, int n ) ;
183
184        ! int setupterm(char *term, int fildes, int *errret);
185        ! int setterm(char *term);
186        ! TERMINAL *set_curterm(TERMINAL *nterm);
187        ! int del_curterm(TERMINAL *oterm);
188        ! int restartterm(const char *term, int fildes, int *errret);
189        ! char *tparm(char *str, ...);
190        ! int tputs(const char *str, int affcnt, int (*putc)(int));
191        ! int putp(const char *str);
192        ! int vidputs(chtype attrs, int (*putc)(int));
193        ! int vidattr(chtype attrs);
194        ! int vid_puts(attr_t attrs, short pair, void *opts, int (*putc)(char));
195        ! int vid_attr(attr_t attrs, short pair, void *opts);
196 FUNCTION: int mvcur ( int oldrow, int oldcol, int newrow, int newcol ) ;
197        ! int tigetflag(char *capname);
198        ! int tigetnum(char *capname);
199        ! char *tigetstr(char *capname);
200
201 FUNCTION: int touchwin ( WINDOW* win ) ;
202 FUNCTION: int touchline ( WINDOW* win, int start, int count ) ;
203 FUNCTION: int untouchwin ( WINDOW* win ) ;
204 FUNCTION: int wtouchln ( WINDOW* win, int y, int n, int changed ) ;
205 FUNCTION: bool is_linetouched ( WINDOW* win, int line ) ;
206 FUNCTION: bool is_wintouched ( WINDOW* win ) ;
207
208 FUNCTION: int insch ( chtype ch ) ;
209 FUNCTION: int winsch ( WINDOW* win, chtype ch ) ;
210 FUNCTION: int mvinsch ( int y, int x, chtype ch ) ;
211 FUNCTION: int mvwinsch ( WINDOW* win, int y, int x, chtype ch ) ;
212 FUNCTION: int delch ( ) ;
213 FUNCTION: int wdelch ( WINDOW* win ) ;
214 FUNCTION: int mvdelch ( int y, int x ) ;
215 FUNCTION: int mvwdelch ( WINDOW* win, int y, int x ) ;
216
217 FUNCTION: int deleteln ( ) ;
218 FUNCTION: int wdeleteln ( WINDOW* win ) ;
219 FUNCTION: int insdelln ( int n ) ;
220 FUNCTION: int winsdelln ( WINDOW* win, int n ) ;
221 FUNCTION: int insertln ( ) ;
222 FUNCTION: int winsertln ( WINDOW* win ) ;
223
224 FUNCTION: int addstr ( char* str ) ;
225 FUNCTION: int addnstr ( char* str, int n ) ;
226 FUNCTION: int waddstr ( WINDOW* win, char* str ) ;
227 FUNCTION: int waddnstr ( WINDOW* win, char* str, int n ) ;
228 FUNCTION: int mvaddstr ( int y, int x, char* str ) ;
229 FUNCTION: int mvaddnstr ( int y, int x, char* str, int n ) ;
230 FUNCTION: int mvwaddstr ( WINDOW* win, int y, int x, char* str ) ;
231 FUNCTION: int mvwaddnstr ( WINDOW* win, int y, int x, char* str, int n ) ;