From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtYPR-00009v-4Z for qemu-devel@nongnu.org; Tue, 03 Nov 2015 05:01:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtYPM-0003x1-2P for qemu-devel@nongnu.org; Tue, 03 Nov 2015 05:01:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51594) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtYPL-0003we-Su for qemu-devel@nongnu.org; Tue, 03 Nov 2015 05:01:39 -0500 From: Gerd Hoffmann Date: Tue, 3 Nov 2015 11:01:26 +0100 Message-Id: <1446544891-3600-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1446544891-3600-1-git-send-email-kraxel@redhat.com> References: <1446544891-3600-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 1/6] ui/curses: Fix monitor color with -curses when 256 colors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , OGAWA Hirofumi From: OGAWA Hirofumi If TERM=xterm-256color, COLOR_PAIRS==256 and monitor passes chtype like 0x74xx. Then, the code uses uninitialized color pair. As result, monitor uses black for both of fg and bg color, i.e. terminal is filled by black. To fix, this initialize above than 64 with default color (fg=white,bg=black). FIXME: on 256 color, curses may be possible better vga color emulation. Signed-off-by: OGAWA Hirofumi Signed-off-by: Gerd Hoffmann --- ui/curses.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/curses.c b/ui/curses.c index 8edb038..35edd5e 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -341,8 +341,13 @@ static void curses_setup(void) nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE); start_color(); raw(); scrollok(stdscr, FALSE); - for (i = 0; i < 64; i ++) + for (i = 0; i < 64; i++) { init_pair(i, colour_default[i & 7], colour_default[i >> 3]); + } + /* Set default color for more than 64. (monitor uses 0x74xx for example) */ + for (i = 64; i < COLOR_PAIRS; i++) { + init_pair(i, COLOR_WHITE, COLOR_BLACK); + } } static void curses_keyboard_setup(void) -- 1.8.3.1