root / curses.c @ 9c1dd99b
History | View | Annotate | Download (9.8 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 | #include <curses.h> |
25 | 4d3b6f6e | balrog | |
26 | 4d3b6f6e | balrog | #ifndef _WIN32
|
27 | 4d3b6f6e | balrog | #include <signal.h> |
28 | 4d3b6f6e | balrog | #include <sys/ioctl.h> |
29 | 4d3b6f6e | balrog | #include <termios.h> |
30 | 4d3b6f6e | balrog | #endif
|
31 | 4d3b6f6e | balrog | |
32 | 128ab2ff | blueswir1 | #ifdef __OpenBSD__
|
33 | 128ab2ff | blueswir1 | #define resize_term resizeterm
|
34 | 128ab2ff | blueswir1 | #endif
|
35 | 128ab2ff | blueswir1 | |
36 | 511d2b14 | blueswir1 | #include "qemu-common.h" |
37 | 511d2b14 | blueswir1 | #include "console.h" |
38 | 511d2b14 | blueswir1 | #include "sysemu.h" |
39 | 511d2b14 | blueswir1 | |
40 | 4d3b6f6e | balrog | #define FONT_HEIGHT 16 |
41 | 4d3b6f6e | balrog | #define FONT_WIDTH 8 |
42 | 4d3b6f6e | balrog | |
43 | 4d3b6f6e | balrog | static console_ch_t screen[160 * 100]; |
44 | 4d3b6f6e | balrog | static WINDOW *screenpad = NULL; |
45 | 4d3b6f6e | balrog | static int width, height, gwidth, gheight, invalidate; |
46 | 4d3b6f6e | balrog | static int px, py, sminx, sminy, smaxx, smaxy; |
47 | 4d3b6f6e | balrog | |
48 | 4d3b6f6e | balrog | static void curses_update(DisplayState *ds, int x, int y, int w, int h) |
49 | 4d3b6f6e | balrog | { |
50 | 4d3b6f6e | balrog | chtype *line; |
51 | 4d3b6f6e | balrog | |
52 | 4d3b6f6e | balrog | line = ((chtype *) screen) + y * width; |
53 | 4d3b6f6e | balrog | for (h += y; y < h; y ++, line += width)
|
54 | 4d3b6f6e | balrog | mvwaddchnstr(screenpad, y, 0, line, width);
|
55 | 4d3b6f6e | balrog | |
56 | 4d3b6f6e | balrog | pnoutrefresh(screenpad, py, px, sminy, sminx, smaxy - 1, smaxx - 1); |
57 | 4d3b6f6e | balrog | refresh(); |
58 | 4d3b6f6e | balrog | } |
59 | 4d3b6f6e | balrog | |
60 | 4d3b6f6e | balrog | static void curses_calc_pad(void) |
61 | 4d3b6f6e | balrog | { |
62 | c21bbcfa | balrog | if (is_fixedsize_console()) {
|
63 | 4d3b6f6e | balrog | width = gwidth; |
64 | 4d3b6f6e | balrog | height = gheight; |
65 | 4d3b6f6e | balrog | } else {
|
66 | 4d3b6f6e | balrog | width = COLS; |
67 | 4d3b6f6e | balrog | height = LINES; |
68 | 4d3b6f6e | balrog | } |
69 | 4d3b6f6e | balrog | |
70 | 4d3b6f6e | balrog | if (screenpad)
|
71 | 4d3b6f6e | balrog | delwin(screenpad); |
72 | 4d3b6f6e | balrog | |
73 | 4d3b6f6e | balrog | clear(); |
74 | 4d3b6f6e | balrog | refresh(); |
75 | 4d3b6f6e | balrog | |
76 | 4d3b6f6e | balrog | screenpad = newpad(height, width); |
77 | 4d3b6f6e | balrog | |
78 | 4d3b6f6e | balrog | if (width > COLS) {
|
79 | 4d3b6f6e | balrog | px = (width - COLS) / 2;
|
80 | 4d3b6f6e | balrog | sminx = 0;
|
81 | 4d3b6f6e | balrog | smaxx = COLS; |
82 | 4d3b6f6e | balrog | } else {
|
83 | 4d3b6f6e | balrog | px = 0;
|
84 | 4d3b6f6e | balrog | sminx = (COLS - width) / 2;
|
85 | 4d3b6f6e | balrog | smaxx = sminx + width; |
86 | 4d3b6f6e | balrog | } |
87 | 4d3b6f6e | balrog | |
88 | 4d3b6f6e | balrog | if (height > LINES) {
|
89 | 4d3b6f6e | balrog | py = (height - LINES) / 2;
|
90 | 4d3b6f6e | balrog | sminy = 0;
|
91 | 4d3b6f6e | balrog | smaxy = LINES; |
92 | 4d3b6f6e | balrog | } else {
|
93 | 4d3b6f6e | balrog | py = 0;
|
94 | 4d3b6f6e | balrog | sminy = (LINES - height) / 2;
|
95 | 4d3b6f6e | balrog | smaxy = sminy + height; |
96 | 4d3b6f6e | balrog | } |
97 | 4d3b6f6e | balrog | } |
98 | 4d3b6f6e | balrog | |
99 | 7d957bd8 | aliguori | static void curses_resize(DisplayState *ds) |
100 | 4d3b6f6e | balrog | { |
101 | 7d957bd8 | aliguori | if (ds_get_width(ds) == gwidth && ds_get_height(ds) == gheight)
|
102 | 4d3b6f6e | balrog | return;
|
103 | 4d3b6f6e | balrog | |
104 | 7d957bd8 | aliguori | gwidth = ds_get_width(ds); |
105 | 7d957bd8 | aliguori | gheight = ds_get_height(ds); |
106 | 4d3b6f6e | balrog | |
107 | 4d3b6f6e | balrog | curses_calc_pad(); |
108 | 68f00996 | aliguori | ds->surface->width = width * FONT_WIDTH; |
109 | 68f00996 | aliguori | ds->surface->height = height * FONT_HEIGHT; |
110 | 4d3b6f6e | balrog | } |
111 | 4d3b6f6e | balrog | |
112 | 4d3b6f6e | balrog | #ifndef _WIN32
|
113 | b1314cf9 | balrog | #if defined(SIGWINCH) && defined(KEY_RESIZE)
|
114 | 4d3b6f6e | balrog | static void curses_winch_handler(int signum) |
115 | 4d3b6f6e | balrog | { |
116 | 4d3b6f6e | balrog | struct winsize {
|
117 | 4d3b6f6e | balrog | unsigned short ws_row; |
118 | 4d3b6f6e | balrog | unsigned short ws_col; |
119 | 4d3b6f6e | balrog | unsigned short ws_xpixel; /* unused */ |
120 | 4d3b6f6e | balrog | unsigned short ws_ypixel; /* unused */ |
121 | 4d3b6f6e | balrog | } ws; |
122 | 4d3b6f6e | balrog | |
123 | 4d3b6f6e | balrog | /* terminal size changed */
|
124 | 4d3b6f6e | balrog | if (ioctl(1, TIOCGWINSZ, &ws) == -1) |
125 | 4d3b6f6e | balrog | return;
|
126 | 4d3b6f6e | balrog | |
127 | 4d3b6f6e | balrog | resize_term(ws.ws_row, ws.ws_col); |
128 | 4d3b6f6e | balrog | curses_calc_pad(); |
129 | 4d3b6f6e | balrog | invalidate = 1;
|
130 | 4d3b6f6e | balrog | |
131 | 4d3b6f6e | balrog | /* some systems require this */
|
132 | 4d3b6f6e | balrog | signal(SIGWINCH, curses_winch_handler); |
133 | 4d3b6f6e | balrog | } |
134 | 4d3b6f6e | balrog | #endif
|
135 | 4d3b6f6e | balrog | #endif
|
136 | 4d3b6f6e | balrog | |
137 | 4d3b6f6e | balrog | static void curses_cursor_position(DisplayState *ds, int x, int y) |
138 | 4d3b6f6e | balrog | { |
139 | 4d3b6f6e | balrog | if (x >= 0) { |
140 | 4d3b6f6e | balrog | x = sminx + x - px; |
141 | 4d3b6f6e | balrog | y = sminy + y - py; |
142 | 4d3b6f6e | balrog | |
143 | 4d3b6f6e | balrog | if (x >= 0 && y >= 0 && x < COLS && y < LINES) { |
144 | 4d3b6f6e | balrog | move(y, x); |
145 | 4d3b6f6e | balrog | curs_set(1);
|
146 | 4d3b6f6e | balrog | /* it seems that curs_set(1) must always be called before
|
147 | 4d3b6f6e | balrog | * curs_set(2) for the latter to have effect */
|
148 | 4d3b6f6e | balrog | if (!is_graphic_console())
|
149 | 4d3b6f6e | balrog | curs_set(2);
|
150 | 4d3b6f6e | balrog | return;
|
151 | 4d3b6f6e | balrog | } |
152 | 4d3b6f6e | balrog | } |
153 | 4d3b6f6e | balrog | |
154 | 4d3b6f6e | balrog | curs_set(0);
|
155 | 4d3b6f6e | balrog | } |
156 | 4d3b6f6e | balrog | |
157 | 4d3b6f6e | balrog | /* generic keyboard conversion */
|
158 | 4d3b6f6e | balrog | |
159 | 4d3b6f6e | balrog | #include "curses_keys.h" |
160 | 4d3b6f6e | balrog | |
161 | 4d3b6f6e | balrog | static kbd_layout_t *kbd_layout = 0; |
162 | 4d3b6f6e | balrog | static int keycode2keysym[CURSES_KEYS]; |
163 | 4d3b6f6e | balrog | |
164 | 4d3b6f6e | balrog | static void curses_refresh(DisplayState *ds) |
165 | 4d3b6f6e | balrog | { |
166 | 4d3b6f6e | balrog | int chr, nextchr, keysym, keycode;
|
167 | 4d3b6f6e | balrog | |
168 | 4d3b6f6e | balrog | if (invalidate) {
|
169 | 4d3b6f6e | balrog | clear(); |
170 | 4d3b6f6e | balrog | refresh(); |
171 | 4d3b6f6e | balrog | curses_calc_pad(); |
172 | 7d957bd8 | aliguori | ds->surface->width = FONT_WIDTH * width; |
173 | 7d957bd8 | aliguori | ds->surface->height = FONT_HEIGHT * height; |
174 | 4d3b6f6e | balrog | vga_hw_invalidate(); |
175 | 4d3b6f6e | balrog | invalidate = 0;
|
176 | 4d3b6f6e | balrog | } |
177 | 4d3b6f6e | balrog | |
178 | 4d3b6f6e | balrog | vga_hw_text_update(screen); |
179 | 4d3b6f6e | balrog | |
180 | 4d3b6f6e | balrog | nextchr = ERR; |
181 | 4d3b6f6e | balrog | while (1) { |
182 | 4d3b6f6e | balrog | /* while there are any pending key strokes to process */
|
183 | 4d3b6f6e | balrog | if (nextchr == ERR)
|
184 | 4d3b6f6e | balrog | chr = getch(); |
185 | 4d3b6f6e | balrog | else {
|
186 | 4d3b6f6e | balrog | chr = nextchr; |
187 | 4d3b6f6e | balrog | nextchr = ERR; |
188 | 4d3b6f6e | balrog | } |
189 | 4d3b6f6e | balrog | |
190 | 4d3b6f6e | balrog | if (chr == ERR)
|
191 | 4d3b6f6e | balrog | break;
|
192 | 4d3b6f6e | balrog | |
193 | b1314cf9 | balrog | #ifdef KEY_RESIZE
|
194 | 4d3b6f6e | balrog | /* this shouldn't occur when we use a custom SIGWINCH handler */
|
195 | 4d3b6f6e | balrog | if (chr == KEY_RESIZE) {
|
196 | 4d3b6f6e | balrog | clear(); |
197 | 4d3b6f6e | balrog | refresh(); |
198 | 4d3b6f6e | balrog | curses_calc_pad(); |
199 | 4d3b6f6e | balrog | curses_update(ds, 0, 0, width, height); |
200 | 7d957bd8 | aliguori | ds->surface->width = FONT_WIDTH * width; |
201 | 7d957bd8 | aliguori | ds->surface->height = FONT_HEIGHT * height; |
202 | 4d3b6f6e | balrog | continue;
|
203 | 4d3b6f6e | balrog | } |
204 | b1314cf9 | balrog | #endif
|
205 | 4d3b6f6e | balrog | |
206 | 4d3b6f6e | balrog | keycode = curses2keycode[chr]; |
207 | 4d3b6f6e | balrog | if (keycode == -1) |
208 | 4d3b6f6e | balrog | continue;
|
209 | 4d3b6f6e | balrog | |
210 | 4d3b6f6e | balrog | /* alt key */
|
211 | 4d3b6f6e | balrog | if (keycode == 1) { |
212 | 4d3b6f6e | balrog | nextchr = getch(); |
213 | 4d3b6f6e | balrog | |
214 | 4d3b6f6e | balrog | if (nextchr != ERR) {
|
215 | 4d3b6f6e | balrog | keycode = curses2keycode[nextchr]; |
216 | 4d3b6f6e | balrog | nextchr = ERR; |
217 | 4d3b6f6e | balrog | if (keycode == -1) |
218 | 4d3b6f6e | balrog | continue;
|
219 | 4d3b6f6e | balrog | |
220 | 4d3b6f6e | balrog | keycode |= ALT; |
221 | 4d3b6f6e | balrog | |
222 | 4d3b6f6e | balrog | /* process keys reserved for qemu */
|
223 | 4d3b6f6e | balrog | if (keycode >= QEMU_KEY_CONSOLE0 &&
|
224 | 4d3b6f6e | balrog | keycode < QEMU_KEY_CONSOLE0 + 9) {
|
225 | 4d3b6f6e | balrog | erase(); |
226 | 4d3b6f6e | balrog | wnoutrefresh(stdscr); |
227 | 4d3b6f6e | balrog | console_select(keycode - QEMU_KEY_CONSOLE0); |
228 | 4d3b6f6e | balrog | |
229 | 4d3b6f6e | balrog | invalidate = 1;
|
230 | 4d3b6f6e | balrog | continue;
|
231 | 4d3b6f6e | balrog | } |
232 | 4d3b6f6e | balrog | } |
233 | 4d3b6f6e | balrog | } |
234 | 4d3b6f6e | balrog | |
235 | 4d3b6f6e | balrog | if (kbd_layout && !(keycode & GREY)) {
|
236 | 4d3b6f6e | balrog | keysym = keycode2keysym[keycode & KEY_MASK]; |
237 | 4d3b6f6e | balrog | if (keysym == -1) |
238 | 4d3b6f6e | balrog | keysym = chr; |
239 | 4d3b6f6e | balrog | |
240 | 4d3b6f6e | balrog | keycode &= ~KEY_MASK; |
241 | 4d3b6f6e | balrog | keycode |= keysym2scancode(kbd_layout, keysym); |
242 | 4d3b6f6e | balrog | } |
243 | 4d3b6f6e | balrog | |
244 | 4d3b6f6e | balrog | if (is_graphic_console()) {
|
245 | 4d3b6f6e | balrog | /* since terminals don't know about key press and release
|
246 | 4d3b6f6e | balrog | * events, we need to emit both for each key received */
|
247 | 4d3b6f6e | balrog | if (keycode & SHIFT)
|
248 | 4d3b6f6e | balrog | kbd_put_keycode(SHIFT_CODE); |
249 | 4d3b6f6e | balrog | if (keycode & CNTRL)
|
250 | 4d3b6f6e | balrog | kbd_put_keycode(CNTRL_CODE); |
251 | 4d3b6f6e | balrog | if (keycode & ALT)
|
252 | 4d3b6f6e | balrog | kbd_put_keycode(ALT_CODE); |
253 | 4d3b6f6e | balrog | if (keycode & GREY)
|
254 | 4d3b6f6e | balrog | kbd_put_keycode(GREY_CODE); |
255 | 4d3b6f6e | balrog | kbd_put_keycode(keycode & KEY_MASK); |
256 | 4d3b6f6e | balrog | if (keycode & GREY)
|
257 | 4d3b6f6e | balrog | kbd_put_keycode(GREY_CODE); |
258 | 4d3b6f6e | balrog | kbd_put_keycode((keycode & KEY_MASK) | KEY_RELEASE); |
259 | 4d3b6f6e | balrog | if (keycode & ALT)
|
260 | 4d3b6f6e | balrog | kbd_put_keycode(ALT_CODE | KEY_RELEASE); |
261 | 4d3b6f6e | balrog | if (keycode & CNTRL)
|
262 | 4d3b6f6e | balrog | kbd_put_keycode(CNTRL_CODE | KEY_RELEASE); |
263 | 4d3b6f6e | balrog | if (keycode & SHIFT)
|
264 | 4d3b6f6e | balrog | kbd_put_keycode(SHIFT_CODE | KEY_RELEASE); |
265 | 4d3b6f6e | balrog | } else {
|
266 | 4d3b6f6e | balrog | keysym = curses2keysym[chr]; |
267 | 4d3b6f6e | balrog | if (keysym == -1) |
268 | 4d3b6f6e | balrog | keysym = chr; |
269 | 4d3b6f6e | balrog | |
270 | 4d3b6f6e | balrog | kbd_put_keysym(keysym); |
271 | 4d3b6f6e | balrog | } |
272 | 4d3b6f6e | balrog | } |
273 | 4d3b6f6e | balrog | } |
274 | 4d3b6f6e | balrog | |
275 | 4d3b6f6e | balrog | static void curses_cleanup(void *opaque) |
276 | 4d3b6f6e | balrog | { |
277 | 4d3b6f6e | balrog | endwin(); |
278 | 4d3b6f6e | balrog | } |
279 | 4d3b6f6e | balrog | |
280 | 4d3b6f6e | balrog | static void curses_atexit(void) |
281 | 4d3b6f6e | balrog | { |
282 | 4d3b6f6e | balrog | curses_cleanup(NULL);
|
283 | 4d3b6f6e | balrog | } |
284 | 4d3b6f6e | balrog | |
285 | 4d3b6f6e | balrog | static void curses_setup(void) |
286 | 4d3b6f6e | balrog | { |
287 | 4d3b6f6e | balrog | int i, colour_default[8] = { |
288 | 4d3b6f6e | balrog | COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, |
289 | 4d3b6f6e | balrog | COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, |
290 | 4d3b6f6e | balrog | }; |
291 | 4d3b6f6e | balrog | |
292 | 4d3b6f6e | balrog | /* input as raw as possible, let everything be interpreted
|
293 | 4d3b6f6e | balrog | * by the guest system */
|
294 | 4d3b6f6e | balrog | initscr(); noecho(); intrflush(stdscr, FALSE); |
295 | 4d3b6f6e | balrog | nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE); |
296 | 4d3b6f6e | balrog | start_color(); raw(); scrollok(stdscr, FALSE); |
297 | 4d3b6f6e | balrog | |
298 | 4d3b6f6e | balrog | for (i = 0; i < 64; i ++) |
299 | 4d3b6f6e | balrog | init_pair(i, colour_default[i & 7], colour_default[i >> 3]); |
300 | 4d3b6f6e | balrog | } |
301 | 4d3b6f6e | balrog | |
302 | 4d3b6f6e | balrog | static void curses_keyboard_setup(void) |
303 | 4d3b6f6e | balrog | { |
304 | 4d3b6f6e | balrog | int i, keycode, keysym;
|
305 | 4d3b6f6e | balrog | |
306 | 4d3b6f6e | balrog | #if defined(__APPLE__)
|
307 | 4d3b6f6e | balrog | /* always use generic keymaps */
|
308 | 4d3b6f6e | balrog | if (!keyboard_layout)
|
309 | 4d3b6f6e | balrog | keyboard_layout = "en-us";
|
310 | 4d3b6f6e | balrog | #endif
|
311 | 4d3b6f6e | balrog | if(keyboard_layout) {
|
312 | 0483755a | aliguori | kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout); |
313 | 4d3b6f6e | balrog | if (!kbd_layout)
|
314 | 4d3b6f6e | balrog | exit(1);
|
315 | 4d3b6f6e | balrog | } |
316 | 4d3b6f6e | balrog | |
317 | 4d3b6f6e | balrog | for (i = 0; i < CURSES_KEYS; i ++) |
318 | 4d3b6f6e | balrog | keycode2keysym[i] = -1;
|
319 | 4d3b6f6e | balrog | |
320 | 4d3b6f6e | balrog | for (i = 0; i < CURSES_KEYS; i ++) { |
321 | 4d3b6f6e | balrog | if (curses2keycode[i] == -1) |
322 | 4d3b6f6e | balrog | continue;
|
323 | 4d3b6f6e | balrog | |
324 | 4d3b6f6e | balrog | keycode = curses2keycode[i] & KEY_MASK; |
325 | 4d3b6f6e | balrog | if (keycode2keysym[keycode] >= 0) |
326 | 4d3b6f6e | balrog | continue;
|
327 | 4d3b6f6e | balrog | |
328 | 4d3b6f6e | balrog | for (keysym = 0; keysym < CURSES_KEYS; keysym ++) |
329 | 4d3b6f6e | balrog | if (curses2keycode[keysym] == keycode) {
|
330 | 4d3b6f6e | balrog | keycode2keysym[keycode] = keysym; |
331 | 4d3b6f6e | balrog | break;
|
332 | 4d3b6f6e | balrog | } |
333 | 4d3b6f6e | balrog | |
334 | 4d3b6f6e | balrog | if (keysym >= CURSES_KEYS)
|
335 | 4d3b6f6e | balrog | keycode2keysym[keycode] = i; |
336 | 4d3b6f6e | balrog | } |
337 | 4d3b6f6e | balrog | } |
338 | 4d3b6f6e | balrog | |
339 | 4d3b6f6e | balrog | void curses_display_init(DisplayState *ds, int full_screen) |
340 | 4d3b6f6e | balrog | { |
341 | 7d957bd8 | aliguori | DisplayChangeListener *dcl; |
342 | 4d3b6f6e | balrog | #ifndef _WIN32
|
343 | 4d3b6f6e | balrog | if (!isatty(1)) { |
344 | 4d3b6f6e | balrog | fprintf(stderr, "We need a terminal output\n");
|
345 | 4d3b6f6e | balrog | exit(1);
|
346 | 4d3b6f6e | balrog | } |
347 | 4d3b6f6e | balrog | #endif
|
348 | 4d3b6f6e | balrog | |
349 | 4d3b6f6e | balrog | curses_setup(); |
350 | 4d3b6f6e | balrog | curses_keyboard_setup(); |
351 | 4d3b6f6e | balrog | atexit(curses_atexit); |
352 | 4d3b6f6e | balrog | |
353 | 4d3b6f6e | balrog | #ifndef _WIN32
|
354 | b1314cf9 | balrog | #if defined(SIGWINCH) && defined(KEY_RESIZE)
|
355 | 4d3b6f6e | balrog | /* some curses implementations provide a handler, but we
|
356 | 4d3b6f6e | balrog | * want to be sure this is handled regardless of the library */
|
357 | 4d3b6f6e | balrog | signal(SIGWINCH, curses_winch_handler); |
358 | 4d3b6f6e | balrog | #endif
|
359 | 4d3b6f6e | balrog | #endif
|
360 | 4d3b6f6e | balrog | |
361 | 7d957bd8 | aliguori | dcl = (DisplayChangeListener *) qemu_mallocz(sizeof(DisplayChangeListener));
|
362 | 7d957bd8 | aliguori | dcl->dpy_update = curses_update; |
363 | 7d957bd8 | aliguori | dcl->dpy_resize = curses_resize; |
364 | 7d957bd8 | aliguori | dcl->dpy_refresh = curses_refresh; |
365 | 7d957bd8 | aliguori | dcl->dpy_text_cursor = curses_cursor_position; |
366 | 7d957bd8 | aliguori | register_displaychangelistener(ds, dcl); |
367 | 7b5d76da | aliguori | qemu_free_displaysurface(ds); |
368 | 68f00996 | aliguori | ds->surface = qemu_create_displaysurface_from(640, 400, 0, 0, (uint8_t*) screen); |
369 | 4d3b6f6e | balrog | |
370 | 4d3b6f6e | balrog | invalidate = 1;
|
371 | 4d3b6f6e | balrog | |
372 | 4d3b6f6e | balrog | /* Standard VGA initial text mode dimensions */
|
373 | 7d957bd8 | aliguori | curses_resize(ds); |
374 | 4d3b6f6e | balrog | } |