blob: 85503876c094be1a0ede9c67a7bf87e5998924ad [file] [log] [blame]
balrog4d3b6f62008-02-10 16:33:14 +00001/*
2 * QEMU curses/ncurses display driver
3 *
4 * Copyright (c) 2005 Andrzej Zaborowski <balrog@zabor.org>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
Peter Maydelle16f4c82016-01-29 17:49:51 +000024#include "qemu/osdep.h"
balrog4d3b6f62008-02-10 16:33:14 +000025
26#ifndef _WIN32
balrog4d3b6f62008-02-10 16:33:14 +000027#include <sys/ioctl.h>
28#include <termios.h>
29#endif
30
blueswir1511d2b12009-03-07 15:32:56 +000031#include "qemu-common.h"
Paolo Bonzini28ecbae2012-11-28 12:06:30 +010032#include "ui/console.h"
Gerd Hoffmanncd100322013-12-04 13:40:20 +010033#include "ui/input.h"
Paolo Bonzini9c17d612012-12-17 18:20:04 +010034#include "sysemu/sysemu.h"
blueswir1511d2b12009-03-07 15:32:56 +000035
Gerd Hoffmanne2f82e92017-09-27 12:38:11 +020036/* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */
37#undef KEY_EVENT
38#include <curses.h>
39#undef KEY_EVENT
40
balrog4d3b6f62008-02-10 16:33:14 +000041#define FONT_HEIGHT 16
42#define FONT_WIDTH 8
43
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +010044static DisplayChangeListener *dcl;
Anthony Liguoric227f092009-10-01 16:12:16 -050045static console_ch_t screen[160 * 100];
balrog4d3b6f62008-02-10 16:33:14 +000046static WINDOW *screenpad = NULL;
47static int width, height, gwidth, gheight, invalidate;
48static int px, py, sminx, sminy, smaxx, smaxy;
49
Gerd Hoffmanne2f82e92017-09-27 12:38:11 +020050static chtype vga_to_curses[256];
OGAWA Hirofumie2368dc2015-10-19 21:23:46 +090051
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +010052static void curses_update(DisplayChangeListener *dcl,
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +010053 int x, int y, int w, int h)
balrog4d3b6f62008-02-10 16:33:14 +000054{
Gerd Hoffmanne2f82e92017-09-27 12:38:11 +020055 console_ch_t *line;
56 chtype curses_line[width];
balrog4d3b6f62008-02-10 16:33:14 +000057
Gerd Hoffmanne2f82e92017-09-27 12:38:11 +020058 line = screen + y * width;
59 for (h += y; y < h; y ++, line += width) {
60 for (x = 0; x < width; x++) {
61 chtype ch = line[x] & 0xff;
62 chtype at = line[x] & ~0xff;
63 if (vga_to_curses[ch]) {
64 ch = vga_to_curses[ch];
65 }
66 curses_line[x] = ch | at;
67 }
68 mvwaddchnstr(screenpad, y, 0, curses_line, width);
69 }
balrog4d3b6f62008-02-10 16:33:14 +000070
71 pnoutrefresh(screenpad, py, px, sminy, sminx, smaxy - 1, smaxx - 1);
72 refresh();
73}
74
75static void curses_calc_pad(void)
76{
Gerd Hoffmann81c0d5a2013-03-14 14:27:08 +010077 if (qemu_console_is_fixedsize(NULL)) {
balrog4d3b6f62008-02-10 16:33:14 +000078 width = gwidth;
79 height = gheight;
80 } else {
81 width = COLS;
82 height = LINES;
83 }
84
85 if (screenpad)
86 delwin(screenpad);
87
88 clear();
89 refresh();
90
91 screenpad = newpad(height, width);
92
93 if (width > COLS) {
94 px = (width - COLS) / 2;
95 sminx = 0;
96 smaxx = COLS;
97 } else {
98 px = 0;
99 sminx = (COLS - width) / 2;
100 smaxx = sminx + width;
101 }
102
103 if (height > LINES) {
104 py = (height - LINES) / 2;
105 sminy = 0;
106 smaxy = LINES;
107 } else {
108 py = 0;
109 sminy = (LINES - height) / 2;
110 smaxy = sminy + height;
111 }
112}
113
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100114static void curses_resize(DisplayChangeListener *dcl,
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100115 int width, int height)
balrog4d3b6f62008-02-10 16:33:14 +0000116{
Gerd Hoffmanna93a4a22012-09-28 15:02:08 +0200117 if (width == gwidth && height == gheight) {
balrog4d3b6f62008-02-10 16:33:14 +0000118 return;
Gerd Hoffmanna93a4a22012-09-28 15:02:08 +0200119 }
balrog4d3b6f62008-02-10 16:33:14 +0000120
Gerd Hoffmanna93a4a22012-09-28 15:02:08 +0200121 gwidth = width;
122 gheight = height;
balrog4d3b6f62008-02-10 16:33:14 +0000123
124 curses_calc_pad();
125}
126
Gerd Hoffmann032ac6f2013-11-22 15:35:03 +0100127#if !defined(_WIN32) && defined(SIGWINCH) && defined(KEY_RESIZE)
128static volatile sig_atomic_t got_sigwinch;
129static void curses_winch_check(void)
balrog4d3b6f62008-02-10 16:33:14 +0000130{
131 struct winsize {
132 unsigned short ws_row;
133 unsigned short ws_col;
134 unsigned short ws_xpixel; /* unused */
135 unsigned short ws_ypixel; /* unused */
136 } ws;
137
Gerd Hoffmann032ac6f2013-11-22 15:35:03 +0100138 if (!got_sigwinch) {
balrog4d3b6f62008-02-10 16:33:14 +0000139 return;
Gerd Hoffmann032ac6f2013-11-22 15:35:03 +0100140 }
141 got_sigwinch = false;
142
143 if (ioctl(1, TIOCGWINSZ, &ws) == -1) {
144 return;
145 }
balrog4d3b6f62008-02-10 16:33:14 +0000146
147 resize_term(ws.ws_row, ws.ws_col);
balrog4d3b6f62008-02-10 16:33:14 +0000148 invalidate = 1;
balrog4d3b6f62008-02-10 16:33:14 +0000149}
Gerd Hoffmann032ac6f2013-11-22 15:35:03 +0100150
151static void curses_winch_handler(int signum)
152{
153 got_sigwinch = true;
154}
155
156static void curses_winch_init(void)
157{
158 struct sigaction old, winch = {
159 .sa_handler = curses_winch_handler,
160 };
161 sigaction(SIGWINCH, &winch, &old);
162}
163#else
164static void curses_winch_check(void) {}
165static void curses_winch_init(void) {}
balrog4d3b6f62008-02-10 16:33:14 +0000166#endif
167
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100168static void curses_cursor_position(DisplayChangeListener *dcl,
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100169 int x, int y)
balrog4d3b6f62008-02-10 16:33:14 +0000170{
171 if (x >= 0) {
172 x = sminx + x - px;
173 y = sminy + y - py;
174
175 if (x >= 0 && y >= 0 && x < COLS && y < LINES) {
176 move(y, x);
177 curs_set(1);
178 /* it seems that curs_set(1) must always be called before
179 * curs_set(2) for the latter to have effect */
Gerd Hoffmann81c0d5a2013-03-14 14:27:08 +0100180 if (!qemu_console_is_graphic(NULL)) {
balrog4d3b6f62008-02-10 16:33:14 +0000181 curs_set(2);
Gerd Hoffmann81c0d5a2013-03-14 14:27:08 +0100182 }
balrog4d3b6f62008-02-10 16:33:14 +0000183 return;
184 }
185 }
186
187 curs_set(0);
188}
189
190/* generic keyboard conversion */
191
192#include "curses_keys.h"
balrog4d3b6f62008-02-10 16:33:14 +0000193
Anthony Liguoric227f092009-10-01 16:12:16 -0500194static kbd_layout_t *kbd_layout = NULL;
balrog4d3b6f62008-02-10 16:33:14 +0000195
Gerd Hoffmannbc2ed972013-03-01 13:03:04 +0100196static void curses_refresh(DisplayChangeListener *dcl)
balrog4d3b6f62008-02-10 16:33:14 +0000197{
Peter Maydell99a9ef42016-08-11 15:23:27 +0100198 int chr, keysym, keycode, keycode_alt;
balrog4d3b6f62008-02-10 16:33:14 +0000199
Gerd Hoffmann032ac6f2013-11-22 15:35:03 +0100200 curses_winch_check();
201
balrog4d3b6f62008-02-10 16:33:14 +0000202 if (invalidate) {
203 clear();
204 refresh();
205 curses_calc_pad();
Gerd Hoffmann1dbfa002013-03-12 13:44:38 +0100206 graphic_hw_invalidate(NULL);
balrog4d3b6f62008-02-10 16:33:14 +0000207 invalidate = 0;
208 }
209
Gerd Hoffmann1dbfa002013-03-12 13:44:38 +0100210 graphic_hw_text_update(NULL, screen);
balrog4d3b6f62008-02-10 16:33:14 +0000211
balrog4d3b6f62008-02-10 16:33:14 +0000212 while (1) {
213 /* while there are any pending key strokes to process */
Peter Maydell99a9ef42016-08-11 15:23:27 +0100214 chr = getch();
balrog4d3b6f62008-02-10 16:33:14 +0000215
216 if (chr == ERR)
217 break;
218
balrogb1314cf2008-02-22 18:21:28 +0000219#ifdef KEY_RESIZE
balrog4d3b6f62008-02-10 16:33:14 +0000220 /* this shouldn't occur when we use a custom SIGWINCH handler */
221 if (chr == KEY_RESIZE) {
222 clear();
223 refresh();
224 curses_calc_pad();
Gerd Hoffmannbc2ed972013-03-01 13:03:04 +0100225 curses_update(dcl, 0, 0, width, height);
balrog4d3b6f62008-02-10 16:33:14 +0000226 continue;
227 }
balrogb1314cf2008-02-22 18:21:28 +0000228#endif
balrog4d3b6f62008-02-10 16:33:14 +0000229
230 keycode = curses2keycode[chr];
Samuel Thibault44bb61c2010-02-28 21:03:00 +0100231 keycode_alt = 0;
balrog4d3b6f62008-02-10 16:33:14 +0000232
233 /* alt key */
234 if (keycode == 1) {
Peter Maydell99a9ef42016-08-11 15:23:27 +0100235 int nextchr = getch();
balrog4d3b6f62008-02-10 16:33:14 +0000236
237 if (nextchr != ERR) {
Samuel Thibault44bb61c2010-02-28 21:03:00 +0100238 chr = nextchr;
239 keycode_alt = ALT;
Peter Maydell99a9ef42016-08-11 15:23:27 +0100240 keycode = curses2keycode[chr];
balrog4d3b6f62008-02-10 16:33:14 +0000241
Samuel Thibault44bb61c2010-02-28 21:03:00 +0100242 if (keycode != -1) {
243 keycode |= ALT;
balrog4d3b6f62008-02-10 16:33:14 +0000244
Samuel Thibault44bb61c2010-02-28 21:03:00 +0100245 /* process keys reserved for qemu */
246 if (keycode >= QEMU_KEY_CONSOLE0 &&
247 keycode < QEMU_KEY_CONSOLE0 + 9) {
248 erase();
249 wnoutrefresh(stdscr);
250 console_select(keycode - QEMU_KEY_CONSOLE0);
balrog4d3b6f62008-02-10 16:33:14 +0000251
Samuel Thibault44bb61c2010-02-28 21:03:00 +0100252 invalidate = 1;
253 continue;
254 }
balrog4d3b6f62008-02-10 16:33:14 +0000255 }
256 }
257 }
258
Samuel Thibault44bb61c2010-02-28 21:03:00 +0100259 if (kbd_layout) {
260 keysym = -1;
261 if (chr < CURSES_KEYS)
262 keysym = curses2keysym[chr];
balrog4d3b6f62008-02-10 16:33:14 +0000263
Samuel Thibault44bb61c2010-02-28 21:03:00 +0100264 if (keysym == -1) {
Samuel Thibaultd03703c2010-10-19 19:48:20 +0200265 if (chr < ' ') {
266 keysym = chr + '@';
267 if (keysym >= 'A' && keysym <= 'Z')
268 keysym += 'a' - 'A';
269 keysym |= KEYSYM_CNTRL;
270 } else
Samuel Thibault44bb61c2010-02-28 21:03:00 +0100271 keysym = chr;
272 }
273
274 keycode = keysym2scancode(kbd_layout, keysym & KEYSYM_MASK);
275 if (keycode == 0)
276 continue;
277
278 keycode |= (keysym & ~KEYSYM_MASK) >> 16;
279 keycode |= keycode_alt;
balrog4d3b6f62008-02-10 16:33:14 +0000280 }
281
Samuel Thibault44bb61c2010-02-28 21:03:00 +0100282 if (keycode == -1)
283 continue;
284
Gerd Hoffmann81c0d5a2013-03-14 14:27:08 +0100285 if (qemu_console_is_graphic(NULL)) {
balrog4d3b6f62008-02-10 16:33:14 +0000286 /* since terminals don't know about key press and release
287 * events, we need to emit both for each key received */
Gerd Hoffmanncd100322013-12-04 13:40:20 +0100288 if (keycode & SHIFT) {
289 qemu_input_event_send_key_number(NULL, SHIFT_CODE, true);
Gerd Hoffmann5a165662014-05-28 13:05:04 +0200290 qemu_input_event_send_key_delay(0);
Samuel Thibault44bb61c2010-02-28 21:03:00 +0100291 }
Gerd Hoffmanncd100322013-12-04 13:40:20 +0100292 if (keycode & CNTRL) {
293 qemu_input_event_send_key_number(NULL, CNTRL_CODE, true);
Gerd Hoffmann5a165662014-05-28 13:05:04 +0200294 qemu_input_event_send_key_delay(0);
Samuel Thibault44bb61c2010-02-28 21:03:00 +0100295 }
Gerd Hoffmanncd100322013-12-04 13:40:20 +0100296 if (keycode & ALT) {
297 qemu_input_event_send_key_number(NULL, ALT_CODE, true);
Gerd Hoffmann5a165662014-05-28 13:05:04 +0200298 qemu_input_event_send_key_delay(0);
Gerd Hoffmanncd100322013-12-04 13:40:20 +0100299 }
300 if (keycode & ALTGR) {
301 qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, true);
Gerd Hoffmann5a165662014-05-28 13:05:04 +0200302 qemu_input_event_send_key_delay(0);
Gerd Hoffmanncd100322013-12-04 13:40:20 +0100303 }
304
Andrew Oatesf5c0ab12014-05-23 20:16:09 -0400305 qemu_input_event_send_key_number(NULL, keycode & KEY_MASK, true);
Gerd Hoffmann5a165662014-05-28 13:05:04 +0200306 qemu_input_event_send_key_delay(0);
Andrew Oatesf5c0ab12014-05-23 20:16:09 -0400307 qemu_input_event_send_key_number(NULL, keycode & KEY_MASK, false);
Gerd Hoffmann5a165662014-05-28 13:05:04 +0200308 qemu_input_event_send_key_delay(0);
Gerd Hoffmanncd100322013-12-04 13:40:20 +0100309
310 if (keycode & ALTGR) {
311 qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, false);
Gerd Hoffmann5a165662014-05-28 13:05:04 +0200312 qemu_input_event_send_key_delay(0);
Gerd Hoffmanncd100322013-12-04 13:40:20 +0100313 }
314 if (keycode & ALT) {
315 qemu_input_event_send_key_number(NULL, ALT_CODE, false);
Gerd Hoffmann5a165662014-05-28 13:05:04 +0200316 qemu_input_event_send_key_delay(0);
Gerd Hoffmanncd100322013-12-04 13:40:20 +0100317 }
318 if (keycode & CNTRL) {
319 qemu_input_event_send_key_number(NULL, CNTRL_CODE, false);
Gerd Hoffmann5a165662014-05-28 13:05:04 +0200320 qemu_input_event_send_key_delay(0);
Gerd Hoffmanncd100322013-12-04 13:40:20 +0100321 }
322 if (keycode & SHIFT) {
323 qemu_input_event_send_key_number(NULL, SHIFT_CODE, false);
Gerd Hoffmann5a165662014-05-28 13:05:04 +0200324 qemu_input_event_send_key_delay(0);
Gerd Hoffmanncd100322013-12-04 13:40:20 +0100325 }
balrog4d3b6f62008-02-10 16:33:14 +0000326 } else {
Peter Maydellbba4e1b2016-08-11 15:23:26 +0100327 keysym = -1;
328 if (chr < CURSES_KEYS) {
329 keysym = curses2qemu[chr];
330 }
balrog4d3b6f62008-02-10 16:33:14 +0000331 if (keysym == -1)
332 keysym = chr;
333
334 kbd_put_keysym(keysym);
335 }
336 }
337}
338
Blue Swirlaaf12c22010-03-21 19:44:06 +0000339static void curses_atexit(void)
balrog4d3b6f62008-02-10 16:33:14 +0000340{
341 endwin();
342}
343
balrog4d3b6f62008-02-10 16:33:14 +0000344static void curses_setup(void)
345{
346 int i, colour_default[8] = {
OGAWA Hirofumi40837332015-11-29 22:28:24 +0900347 [QEMU_COLOR_BLACK] = COLOR_BLACK,
348 [QEMU_COLOR_BLUE] = COLOR_BLUE,
349 [QEMU_COLOR_GREEN] = COLOR_GREEN,
350 [QEMU_COLOR_CYAN] = COLOR_CYAN,
351 [QEMU_COLOR_RED] = COLOR_RED,
352 [QEMU_COLOR_MAGENTA] = COLOR_MAGENTA,
353 [QEMU_COLOR_YELLOW] = COLOR_YELLOW,
354 [QEMU_COLOR_WHITE] = COLOR_WHITE,
balrog4d3b6f62008-02-10 16:33:14 +0000355 };
356
357 /* input as raw as possible, let everything be interpreted
358 * by the guest system */
359 initscr(); noecho(); intrflush(stdscr, FALSE);
360 nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE);
361 start_color(); raw(); scrollok(stdscr, FALSE);
362
OGAWA Hirofumi40837332015-11-29 22:28:24 +0900363 /* Make color pair to match color format (3bits bg:3bits fg) */
OGAWA Hirofumi615220d2015-10-19 21:23:10 +0900364 for (i = 0; i < 64; i++) {
balrog4d3b6f62008-02-10 16:33:14 +0000365 init_pair(i, colour_default[i & 7], colour_default[i >> 3]);
OGAWA Hirofumi615220d2015-10-19 21:23:10 +0900366 }
OGAWA Hirofumi40837332015-11-29 22:28:24 +0900367 /* Set default color for more than 64 for safety. */
OGAWA Hirofumi615220d2015-10-19 21:23:10 +0900368 for (i = 64; i < COLOR_PAIRS; i++) {
369 init_pair(i, COLOR_WHITE, COLOR_BLACK);
370 }
OGAWA Hirofumie2368dc2015-10-19 21:23:46 +0900371
372 /*
373 * Setup mapping for vga to curses line graphics.
374 * FIXME: for better font, have to use ncursesw and setlocale()
375 */
376#if 0
377 /* FIXME: map from where? */
378 ACS_S1;
379 ACS_S3;
380 ACS_S7;
381 ACS_S9;
382#endif
383 /* ACS_* is not constant. So, we can't initialize statically. */
384 vga_to_curses['\0'] = ' ';
385 vga_to_curses[0x04] = ACS_DIAMOND;
OGAWA Hirofumie2368dc2015-10-19 21:23:46 +0900386 vga_to_curses[0x18] = ACS_UARROW;
387 vga_to_curses[0x19] = ACS_DARROW;
Samuel Thibault697783a2016-10-15 21:53:04 +0200388 vga_to_curses[0x1a] = ACS_RARROW;
389 vga_to_curses[0x1b] = ACS_LARROW;
OGAWA Hirofumie2368dc2015-10-19 21:23:46 +0900390 vga_to_curses[0x9c] = ACS_STERLING;
391 vga_to_curses[0xb0] = ACS_BOARD;
392 vga_to_curses[0xb1] = ACS_CKBOARD;
393 vga_to_curses[0xb3] = ACS_VLINE;
394 vga_to_curses[0xb4] = ACS_RTEE;
395 vga_to_curses[0xbf] = ACS_URCORNER;
396 vga_to_curses[0xc0] = ACS_LLCORNER;
397 vga_to_curses[0xc1] = ACS_BTEE;
398 vga_to_curses[0xc2] = ACS_TTEE;
399 vga_to_curses[0xc3] = ACS_LTEE;
400 vga_to_curses[0xc4] = ACS_HLINE;
401 vga_to_curses[0xc5] = ACS_PLUS;
402 vga_to_curses[0xce] = ACS_LANTERN;
403 vga_to_curses[0xd8] = ACS_NEQUAL;
404 vga_to_curses[0xd9] = ACS_LRCORNER;
405 vga_to_curses[0xda] = ACS_ULCORNER;
406 vga_to_curses[0xdb] = ACS_BLOCK;
407 vga_to_curses[0xe3] = ACS_PI;
408 vga_to_curses[0xf1] = ACS_PLMINUS;
409 vga_to_curses[0xf2] = ACS_GEQUAL;
410 vga_to_curses[0xf3] = ACS_LEQUAL;
411 vga_to_curses[0xf8] = ACS_DEGREE;
412 vga_to_curses[0xfe] = ACS_BULLET;
balrog4d3b6f62008-02-10 16:33:14 +0000413}
414
415static void curses_keyboard_setup(void)
416{
balrog4d3b6f62008-02-10 16:33:14 +0000417#if defined(__APPLE__)
418 /* always use generic keymaps */
419 if (!keyboard_layout)
420 keyboard_layout = "en-us";
421#endif
422 if(keyboard_layout) {
aliguori04837552009-03-06 20:27:10 +0000423 kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
balrog4d3b6f62008-02-10 16:33:14 +0000424 if (!kbd_layout)
425 exit(1);
426 }
balrog4d3b6f62008-02-10 16:33:14 +0000427}
428
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100429static const DisplayChangeListenerOps dcl_ops = {
430 .dpy_name = "curses",
431 .dpy_text_update = curses_update,
432 .dpy_text_resize = curses_resize,
433 .dpy_refresh = curses_refresh,
434 .dpy_text_cursor = curses_cursor_position,
435};
436
balrog4d3b6f62008-02-10 16:33:14 +0000437void curses_display_init(DisplayState *ds, int full_screen)
438{
439#ifndef _WIN32
440 if (!isatty(1)) {
441 fprintf(stderr, "We need a terminal output\n");
442 exit(1);
443 }
444#endif
445
446 curses_setup();
447 curses_keyboard_setup();
Anthony Liguori28695482010-03-21 14:13:02 -0500448 atexit(curses_atexit);
balrog4d3b6f62008-02-10 16:33:14 +0000449
Gerd Hoffmann032ac6f2013-11-22 15:35:03 +0100450 curses_winch_init();
balrog4d3b6f62008-02-10 16:33:14 +0000451
Markus Armbrusterfedf0d32015-11-03 17:12:03 +0100452 dcl = g_new0(DisplayChangeListener, 1);
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100453 dcl->ops = &dcl_ops;
Gerd Hoffmann52090892013-04-23 15:44:31 +0200454 register_displaychangelistener(dcl);
balrog4d3b6f62008-02-10 16:33:14 +0000455
456 invalidate = 1;
balrog4d3b6f62008-02-10 16:33:14 +0000457}