root / curses.c @ c596defd
History | View | Annotate | Download (9.5 kB)
1 | 4d3b6f6e | balrog | /*
|
---|---|---|---|
2 | 4d3b6f6e | balrog | * QEMU curses/ncurses display driver
|
3 | 4d3b6f6e | balrog | *
|
4 | 4d3b6f6e | balrog | * Copyright (c) 2005 Andrzej Zaborowski <balrog@zabor.org>
|
5 | 4d3b6f6e | balrog | *
|
6 | 4d3b6f6e | balrog | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 4d3b6f6e | balrog | * of this software and associated documentation files (the "Software"), to deal
|
8 | 4d3b6f6e | balrog | * in the Software without restriction, including without limitation the rights
|
9 | 4d3b6f6e | balrog | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 4d3b6f6e | balrog | * copies of the Software, and to permit persons to whom the Software is
|
11 | 4d3b6f6e | balrog | * furnished to do so, subject to the following conditions:
|
12 | 4d3b6f6e | balrog | *
|
13 | 4d3b6f6e | balrog | * The above copyright notice and this permission notice shall be included in
|
14 | 4d3b6f6e | balrog | * all copies or substantial portions of the Software.
|
15 | 4d3b6f6e | balrog | *
|
16 | 4d3b6f6e | balrog | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 4d3b6f6e | balrog | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 4d3b6f6e | balrog | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 4d3b6f6e | balrog | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 4d3b6f6e | balrog | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 4d3b6f6e | balrog | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 4d3b6f6e | balrog | * THE SOFTWARE.
|
23 | 4d3b6f6e | balrog | */
|
24 | 4d3b6f6e | balrog | |
25 | 4d3b6f6e | balrog | #include "qemu-common.h" |
26 | 4d3b6f6e | balrog | #include "console.h" |
27 | 4d3b6f6e | balrog | #include "sysemu.h" |
28 | 4d3b6f6e | balrog | |
29 | 4d3b6f6e | balrog | #include <curses.h> |
30 | 4d3b6f6e | balrog | |
31 | 4d3b6f6e | balrog | #ifndef _WIN32
|
32 | 4d3b6f6e | balrog | #include <signal.h> |
33 | 4d3b6f6e | balrog | #include <sys/ioctl.h> |
34 | 4d3b6f6e | balrog | #include <termios.h> |
35 | 4d3b6f6e | balrog | #endif
|
36 | 4d3b6f6e | balrog | |
37 | 4d3b6f6e | balrog | #define FONT_HEIGHT 16 |
38 | 4d3b6f6e | balrog | #define FONT_WIDTH 8 |
39 | 4d3b6f6e | balrog | |
40 | 4d3b6f6e | balrog | static console_ch_t screen[160 * 100]; |
41 | 4d3b6f6e | balrog | static WINDOW *screenpad = NULL; |
42 | 4d3b6f6e | balrog | static int width, height, gwidth, gheight, invalidate; |
43 | 4d3b6f6e | balrog | static int px, py, sminx, sminy, smaxx, smaxy; |
44 | 4d3b6f6e | balrog | |
45 | 4d3b6f6e | balrog | static void curses_update(DisplayState *ds, int x, int y, int w, int h) |
46 | 4d3b6f6e | balrog | { |
47 | 4d3b6f6e | balrog | chtype *line; |
48 | 4d3b6f6e | balrog | |
49 | 4d3b6f6e | balrog | line = ((chtype *) screen) + y * width; |
50 | 4d3b6f6e | balrog | for (h += y; y < h; y ++, line += width)
|
51 | 4d3b6f6e | balrog | mvwaddchnstr(screenpad, y, 0, line, width);
|
52 | 4d3b6f6e | balrog | |
53 | 4d3b6f6e | balrog | pnoutrefresh(screenpad, py, px, sminy, sminx, smaxy - 1, smaxx - 1); |
54 | 4d3b6f6e | balrog | refresh(); |
55 | 4d3b6f6e | balrog | } |
56 | 4d3b6f6e | balrog | |
57 | 4d3b6f6e | balrog | static void curses_calc_pad(void) |
58 | 4d3b6f6e | balrog | { |
59 | 4d3b6f6e | balrog | if (is_graphic_console()) {
|
60 | 4d3b6f6e | balrog | width = gwidth; |
61 | 4d3b6f6e | balrog | height = gheight; |
62 | 4d3b6f6e | balrog | } else {
|
63 | 4d3b6f6e | balrog | width = COLS; |
64 | 4d3b6f6e | balrog | height = LINES; |
65 | 4d3b6f6e | balrog | } |
66 | 4d3b6f6e | balrog | |
67 | 4d3b6f6e | balrog | if (screenpad)
|
68 | 4d3b6f6e | balrog | delwin(screenpad); |
69 | 4d3b6f6e | balrog | |
70 | 4d3b6f6e | balrog | clear(); |
71 | 4d3b6f6e | balrog | refresh(); |
72 | 4d3b6f6e | balrog | |
73 | 4d3b6f6e | balrog | screenpad = newpad(height, width); |
74 | 4d3b6f6e | balrog | |
75 | 4d3b6f6e | balrog | if (width > COLS) {
|
76 | 4d3b6f6e | balrog | px = (width - COLS) / 2;
|
77 | 4d3b6f6e | balrog | sminx = 0;
|
78 | 4d3b6f6e | balrog | smaxx = COLS; |
79 | 4d3b6f6e | balrog | } else {
|
80 | 4d3b6f6e | balrog | px = 0;
|
81 | 4d3b6f6e | balrog | sminx = (COLS - width) / 2;
|
82 | 4d3b6f6e | balrog | smaxx = sminx + width; |
83 | 4d3b6f6e | balrog | } |
84 | 4d3b6f6e | balrog | |
85 | 4d3b6f6e | balrog | if (height > LINES) {
|
86 | 4d3b6f6e | balrog | py = (height - LINES) / 2;
|
87 | 4d3b6f6e | balrog | sminy = 0;
|
88 | 4d3b6f6e | balrog | smaxy = LINES; |
89 | 4d3b6f6e | balrog | } else {
|
90 | 4d3b6f6e | balrog | py = 0;
|
91 | 4d3b6f6e | balrog | sminy = (LINES - height) / 2;
|
92 | 4d3b6f6e | balrog | smaxy = sminy + height; |
93 | 4d3b6f6e | balrog | } |
94 | 4d3b6f6e | balrog | } |
95 | 4d3b6f6e | balrog | |
96 | 4d3b6f6e | balrog | static void curses_resize(DisplayState *ds, int w, int h) |
97 | 4d3b6f6e | balrog | { |
98 | 4d3b6f6e | balrog | if (w == gwidth && h == gheight)
|
99 | 4d3b6f6e | balrog | return;
|
100 | 4d3b6f6e | balrog | |
101 | 4d3b6f6e | balrog | gwidth = w; |
102 | 4d3b6f6e | balrog | gheight = h; |
103 | 4d3b6f6e | balrog | |
104 | 4d3b6f6e | balrog | curses_calc_pad(); |
105 | 4d3b6f6e | balrog | } |
106 | 4d3b6f6e | balrog | |
107 | 4d3b6f6e | balrog | #ifndef _WIN32
|
108 | b1314cf9 | balrog | #if defined(SIGWINCH) && defined(KEY_RESIZE)
|
109 | 4d3b6f6e | balrog | static void curses_winch_handler(int signum) |
110 | 4d3b6f6e | balrog | { |
111 | 4d3b6f6e | balrog | struct winsize {
|
112 | 4d3b6f6e | balrog | unsigned short ws_row; |
113 | 4d3b6f6e | balrog | unsigned short ws_col; |
114 | 4d3b6f6e | balrog | unsigned short ws_xpixel; /* unused */ |
115 | 4d3b6f6e | balrog | unsigned short ws_ypixel; /* unused */ |
116 | 4d3b6f6e | balrog | } ws; |
117 | 4d3b6f6e | balrog | |
118 | 4d3b6f6e | balrog | /* terminal size changed */
|
119 | 4d3b6f6e | balrog | if (ioctl(1, TIOCGWINSZ, &ws) == -1) |
120 | 4d3b6f6e | balrog | return;
|
121 | 4d3b6f6e | balrog | |
122 | 4d3b6f6e | balrog | resize_term(ws.ws_row, ws.ws_col); |
123 | 4d3b6f6e | balrog | curses_calc_pad(); |
124 | 4d3b6f6e | balrog | invalidate = 1;
|
125 | 4d3b6f6e | balrog | |
126 | 4d3b6f6e | balrog | /* some systems require this */
|
127 | 4d3b6f6e | balrog | signal(SIGWINCH, curses_winch_handler); |
128 | 4d3b6f6e | balrog | } |
129 | 4d3b6f6e | balrog | #endif
|
130 | 4d3b6f6e | balrog | #endif
|
131 | 4d3b6f6e | balrog | |
132 | 4d3b6f6e | balrog | static void curses_cursor_position(DisplayState *ds, int x, int y) |
133 | 4d3b6f6e | balrog | { |
134 | 4d3b6f6e | balrog | if (x >= 0) { |
135 | 4d3b6f6e | balrog | x = sminx + x - px; |
136 | 4d3b6f6e | balrog | y = sminy + y - py; |
137 | 4d3b6f6e | balrog | |
138 | 4d3b6f6e | balrog | if (x >= 0 && y >= 0 && x < COLS && y < LINES) { |
139 | 4d3b6f6e | balrog | move(y, x); |
140 | 4d3b6f6e | balrog | curs_set(1);
|
141 | 4d3b6f6e | balrog | /* it seems that curs_set(1) must always be called before
|
142 | 4d3b6f6e | balrog | * curs_set(2) for the latter to have effect */
|
143 | 4d3b6f6e | balrog | if (!is_graphic_console())
|
144 | 4d3b6f6e | balrog | curs_set(2);
|
145 | 4d3b6f6e | balrog | return;
|
146 | 4d3b6f6e | balrog | } |
147 | 4d3b6f6e | balrog | } |
148 | 4d3b6f6e | balrog | |
149 | 4d3b6f6e | balrog | curs_set(0);
|
150 | 4d3b6f6e | balrog | } |
151 | 4d3b6f6e | balrog | |
152 | 4d3b6f6e | balrog | /* generic keyboard conversion */
|
153 | 4d3b6f6e | balrog | |
154 | 4d3b6f6e | balrog | #include "curses_keys.h" |
155 | 4d3b6f6e | balrog | #include "keymaps.c" |
156 | 4d3b6f6e | balrog | |
157 | 4d3b6f6e | balrog | static kbd_layout_t *kbd_layout = 0; |
158 | 4d3b6f6e | balrog | static int keycode2keysym[CURSES_KEYS]; |
159 | 4d3b6f6e | balrog | |
160 | 4d3b6f6e | balrog | static void curses_refresh(DisplayState *ds) |
161 | 4d3b6f6e | balrog | { |
162 | 4d3b6f6e | balrog | int chr, nextchr, keysym, keycode;
|
163 | 4d3b6f6e | balrog | |
164 | 4d3b6f6e | balrog | if (invalidate) {
|
165 | 4d3b6f6e | balrog | clear(); |
166 | 4d3b6f6e | balrog | refresh(); |
167 | 4d3b6f6e | balrog | curses_calc_pad(); |
168 | 4d3b6f6e | balrog | ds->width = FONT_WIDTH * width; |
169 | 4d3b6f6e | balrog | ds->height = FONT_HEIGHT * height; |
170 | 4d3b6f6e | balrog | vga_hw_invalidate(); |
171 | 4d3b6f6e | balrog | invalidate = 0;
|
172 | 4d3b6f6e | balrog | } |
173 | 4d3b6f6e | balrog | |
174 | 4d3b6f6e | balrog | vga_hw_text_update(screen); |
175 | 4d3b6f6e | balrog | |
176 | 4d3b6f6e | balrog | nextchr = ERR; |
177 | 4d3b6f6e | balrog | while (1) { |
178 | 4d3b6f6e | balrog | /* while there are any pending key strokes to process */
|
179 | 4d3b6f6e | balrog | if (nextchr == ERR)
|
180 | 4d3b6f6e | balrog | chr = getch(); |
181 | 4d3b6f6e | balrog | else {
|
182 | 4d3b6f6e | balrog | chr = nextchr; |
183 | 4d3b6f6e | balrog | nextchr = ERR; |
184 | 4d3b6f6e | balrog | } |
185 | 4d3b6f6e | balrog | |
186 | 4d3b6f6e | balrog | if (chr == ERR)
|
187 | 4d3b6f6e | balrog | break;
|
188 | 4d3b6f6e | balrog | |
189 | b1314cf9 | balrog | #ifdef KEY_RESIZE
|
190 | 4d3b6f6e | balrog | /* this shouldn't occur when we use a custom SIGWINCH handler */
|
191 | 4d3b6f6e | balrog | if (chr == KEY_RESIZE) {
|
192 | 4d3b6f6e | balrog | clear(); |
193 | 4d3b6f6e | balrog | refresh(); |
194 | 4d3b6f6e | balrog | curses_calc_pad(); |
195 | 4d3b6f6e | balrog | curses_update(ds, 0, 0, width, height); |
196 | 4d3b6f6e | balrog | ds->width = FONT_WIDTH * width; |
197 | 4d3b6f6e | balrog | ds->height = FONT_HEIGHT * height; |
198 | 4d3b6f6e | balrog | continue;
|
199 | 4d3b6f6e | balrog | } |
200 | b1314cf9 | balrog | #endif
|
201 | 4d3b6f6e | balrog | |
202 | 4d3b6f6e | balrog | keycode = curses2keycode[chr]; |
203 | 4d3b6f6e | balrog | if (keycode == -1) |
204 | 4d3b6f6e | balrog | continue;
|
205 | 4d3b6f6e | balrog | |
206 | 4d3b6f6e | balrog | /* alt key */
|
207 | 4d3b6f6e | balrog | if (keycode == 1) { |
208 | 4d3b6f6e | balrog | nextchr = getch(); |
209 | 4d3b6f6e | balrog | |
210 | 4d3b6f6e | balrog | if (nextchr != ERR) {
|
211 | 4d3b6f6e | balrog | keycode = curses2keycode[nextchr]; |
212 | 4d3b6f6e | balrog | nextchr = ERR; |
213 | 4d3b6f6e | balrog | if (keycode == -1) |
214 | 4d3b6f6e | balrog | continue;
|
215 | 4d3b6f6e | balrog | |
216 | 4d3b6f6e | balrog | keycode |= ALT; |
217 | 4d3b6f6e | balrog | |
218 | 4d3b6f6e | balrog | /* process keys reserved for qemu */
|
219 | 4d3b6f6e | balrog | if (keycode >= QEMU_KEY_CONSOLE0 &&
|
220 | 4d3b6f6e | balrog | keycode < QEMU_KEY_CONSOLE0 + 9) {
|
221 | 4d3b6f6e | balrog | erase(); |
222 | 4d3b6f6e | balrog | wnoutrefresh(stdscr); |
223 | 4d3b6f6e | balrog | console_select(keycode - QEMU_KEY_CONSOLE0); |
224 | 4d3b6f6e | balrog | |
225 | 4d3b6f6e | balrog | invalidate = 1;
|
226 | 4d3b6f6e | balrog | continue;
|
227 | 4d3b6f6e | balrog | } |
228 | 4d3b6f6e | balrog | } |
229 | 4d3b6f6e | balrog | } |
230 | 4d3b6f6e | balrog | |
231 | 4d3b6f6e | balrog | if (kbd_layout && !(keycode & GREY)) {
|
232 | 4d3b6f6e | balrog | keysym = keycode2keysym[keycode & KEY_MASK]; |
233 | 4d3b6f6e | balrog | if (keysym == -1) |
234 | 4d3b6f6e | balrog | keysym = chr; |
235 | 4d3b6f6e | balrog | |
236 | 4d3b6f6e | balrog | keycode &= ~KEY_MASK; |
237 | 4d3b6f6e | balrog | keycode |= keysym2scancode(kbd_layout, keysym); |
238 | 4d3b6f6e | balrog | } |
239 | 4d3b6f6e | balrog | |
240 | 4d3b6f6e | balrog | if (is_graphic_console()) {
|
241 | 4d3b6f6e | balrog | /* since terminals don't know about key press and release
|
242 | 4d3b6f6e | balrog | * events, we need to emit both for each key received */
|
243 | 4d3b6f6e | balrog | if (keycode & SHIFT)
|
244 | 4d3b6f6e | balrog | kbd_put_keycode(SHIFT_CODE); |
245 | 4d3b6f6e | balrog | if (keycode & CNTRL)
|
246 | 4d3b6f6e | balrog | kbd_put_keycode(CNTRL_CODE); |
247 | 4d3b6f6e | balrog | if (keycode & ALT)
|
248 | 4d3b6f6e | balrog | kbd_put_keycode(ALT_CODE); |
249 | 4d3b6f6e | balrog | if (keycode & GREY)
|
250 | 4d3b6f6e | balrog | kbd_put_keycode(GREY_CODE); |
251 | 4d3b6f6e | balrog | kbd_put_keycode(keycode & KEY_MASK); |
252 | 4d3b6f6e | balrog | if (keycode & GREY)
|
253 | 4d3b6f6e | balrog | kbd_put_keycode(GREY_CODE); |
254 | 4d3b6f6e | balrog | kbd_put_keycode((keycode & KEY_MASK) | KEY_RELEASE); |
255 | 4d3b6f6e | balrog | if (keycode & ALT)
|
256 | 4d3b6f6e | balrog | kbd_put_keycode(ALT_CODE | KEY_RELEASE); |
257 | 4d3b6f6e | balrog | if (keycode & CNTRL)
|
258 | 4d3b6f6e | balrog | kbd_put_keycode(CNTRL_CODE | KEY_RELEASE); |
259 | 4d3b6f6e | balrog | if (keycode & SHIFT)
|
260 | 4d3b6f6e | balrog | kbd_put_keycode(SHIFT_CODE | KEY_RELEASE); |
261 | 4d3b6f6e | balrog | } else {
|
262 | 4d3b6f6e | balrog | keysym = curses2keysym[chr]; |
263 | 4d3b6f6e | balrog | if (keysym == -1) |
264 | 4d3b6f6e | balrog | keysym = chr; |
265 | 4d3b6f6e | balrog | |
266 | 4d3b6f6e | balrog | kbd_put_keysym(keysym); |
267 | 4d3b6f6e | balrog | } |
268 | 4d3b6f6e | balrog | } |
269 | 4d3b6f6e | balrog | } |
270 | 4d3b6f6e | balrog | |
271 | 4d3b6f6e | balrog | static void curses_cleanup(void *opaque) |
272 | 4d3b6f6e | balrog | { |
273 | 4d3b6f6e | balrog | endwin(); |
274 | 4d3b6f6e | balrog | } |
275 | 4d3b6f6e | balrog | |
276 | 4d3b6f6e | balrog | static void curses_atexit(void) |
277 | 4d3b6f6e | balrog | { |
278 | 4d3b6f6e | balrog | curses_cleanup(NULL);
|
279 | 4d3b6f6e | balrog | } |
280 | 4d3b6f6e | balrog | |
281 | 4d3b6f6e | balrog | static void curses_setup(void) |
282 | 4d3b6f6e | balrog | { |
283 | 4d3b6f6e | balrog | int i, colour_default[8] = { |
284 | 4d3b6f6e | balrog | COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, |
285 | 4d3b6f6e | balrog | COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, |
286 | 4d3b6f6e | balrog | }; |
287 | 4d3b6f6e | balrog | |
288 | 4d3b6f6e | balrog | /* input as raw as possible, let everything be interpreted
|
289 | 4d3b6f6e | balrog | * by the guest system */
|
290 | 4d3b6f6e | balrog | initscr(); noecho(); intrflush(stdscr, FALSE); |
291 | 4d3b6f6e | balrog | nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE); |
292 | 4d3b6f6e | balrog | start_color(); raw(); scrollok(stdscr, FALSE); |
293 | 4d3b6f6e | balrog | |
294 | 4d3b6f6e | balrog | for (i = 0; i < 64; i ++) |
295 | 4d3b6f6e | balrog | init_pair(i, colour_default[i & 7], colour_default[i >> 3]); |
296 | 4d3b6f6e | balrog | } |
297 | 4d3b6f6e | balrog | |
298 | 4d3b6f6e | balrog | static void curses_keyboard_setup(void) |
299 | 4d3b6f6e | balrog | { |
300 | 4d3b6f6e | balrog | int i, keycode, keysym;
|
301 | 4d3b6f6e | balrog | |
302 | 4d3b6f6e | balrog | #if defined(__APPLE__)
|
303 | 4d3b6f6e | balrog | /* always use generic keymaps */
|
304 | 4d3b6f6e | balrog | if (!keyboard_layout)
|
305 | 4d3b6f6e | balrog | keyboard_layout = "en-us";
|
306 | 4d3b6f6e | balrog | #endif
|
307 | 4d3b6f6e | balrog | if(keyboard_layout) {
|
308 | 4d3b6f6e | balrog | kbd_layout = init_keyboard_layout(keyboard_layout); |
309 | 4d3b6f6e | balrog | if (!kbd_layout)
|
310 | 4d3b6f6e | balrog | exit(1);
|
311 | 4d3b6f6e | balrog | } |
312 | 4d3b6f6e | balrog | |
313 | 4d3b6f6e | balrog | for (i = 0; i < CURSES_KEYS; i ++) |
314 | 4d3b6f6e | balrog | keycode2keysym[i] = -1;
|
315 | 4d3b6f6e | balrog | |
316 | 4d3b6f6e | balrog | for (i = 0; i < CURSES_KEYS; i ++) { |
317 | 4d3b6f6e | balrog | if (curses2keycode[i] == -1) |
318 | 4d3b6f6e | balrog | continue;
|
319 | 4d3b6f6e | balrog | |
320 | 4d3b6f6e | balrog | keycode = curses2keycode[i] & KEY_MASK; |
321 | 4d3b6f6e | balrog | if (keycode2keysym[keycode] >= 0) |
322 | 4d3b6f6e | balrog | continue;
|
323 | 4d3b6f6e | balrog | |
324 | 4d3b6f6e | balrog | for (keysym = 0; keysym < CURSES_KEYS; keysym ++) |
325 | 4d3b6f6e | balrog | if (curses2keycode[keysym] == keycode) {
|
326 | 4d3b6f6e | balrog | keycode2keysym[keycode] = keysym; |
327 | 4d3b6f6e | balrog | break;
|
328 | 4d3b6f6e | balrog | } |
329 | 4d3b6f6e | balrog | |
330 | 4d3b6f6e | balrog | if (keysym >= CURSES_KEYS)
|
331 | 4d3b6f6e | balrog | keycode2keysym[keycode] = i; |
332 | 4d3b6f6e | balrog | } |
333 | 4d3b6f6e | balrog | } |
334 | 4d3b6f6e | balrog | |
335 | 4d3b6f6e | balrog | void curses_display_init(DisplayState *ds, int full_screen) |
336 | 4d3b6f6e | balrog | { |
337 | 4d3b6f6e | balrog | #ifndef _WIN32
|
338 | 4d3b6f6e | balrog | if (!isatty(1)) { |
339 | 4d3b6f6e | balrog | fprintf(stderr, "We need a terminal output\n");
|
340 | 4d3b6f6e | balrog | exit(1);
|
341 | 4d3b6f6e | balrog | } |
342 | 4d3b6f6e | balrog | #endif
|
343 | 4d3b6f6e | balrog | |
344 | 4d3b6f6e | balrog | curses_setup(); |
345 | 4d3b6f6e | balrog | curses_keyboard_setup(); |
346 | 4d3b6f6e | balrog | atexit(curses_atexit); |
347 | 4d3b6f6e | balrog | |
348 | 4d3b6f6e | balrog | #ifndef _WIN32
|
349 | 4d3b6f6e | balrog | signal(SIGINT, SIG_DFL); |
350 | 4d3b6f6e | balrog | signal(SIGQUIT, SIG_DFL); |
351 | b1314cf9 | balrog | #if defined(SIGWINCH) && defined(KEY_RESIZE)
|
352 | 4d3b6f6e | balrog | /* some curses implementations provide a handler, but we
|
353 | 4d3b6f6e | balrog | * want to be sure this is handled regardless of the library */
|
354 | 4d3b6f6e | balrog | signal(SIGWINCH, curses_winch_handler); |
355 | 4d3b6f6e | balrog | #endif
|
356 | 4d3b6f6e | balrog | #endif
|
357 | 4d3b6f6e | balrog | |
358 | 4d3b6f6e | balrog | ds->data = (void *) screen;
|
359 | 4d3b6f6e | balrog | ds->linesize = 0;
|
360 | 4d3b6f6e | balrog | ds->depth = 0;
|
361 | 4d3b6f6e | balrog | ds->width = 640;
|
362 | 4d3b6f6e | balrog | ds->height = 400;
|
363 | 4d3b6f6e | balrog | ds->dpy_update = curses_update; |
364 | 4d3b6f6e | balrog | ds->dpy_resize = curses_resize; |
365 | 4d3b6f6e | balrog | ds->dpy_refresh = curses_refresh; |
366 | 4d3b6f6e | balrog | ds->dpy_text_cursor = curses_cursor_position; |
367 | 4d3b6f6e | balrog | |
368 | 4d3b6f6e | balrog | invalidate = 1;
|
369 | 4d3b6f6e | balrog | |
370 | 4d3b6f6e | balrog | /* Standard VGA initial text mode dimensions */
|
371 | 4d3b6f6e | balrog | curses_resize(ds, 80, 25); |
372 | 4d3b6f6e | balrog | } |