[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curs
From: |
OGAWA Hirofumi |
Subject: |
[Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curses mode |
Date: |
Wed, 14 Oct 2015 20:37:07 +0900 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
This converts vga code to curses code in console_write_bh().
With this changes, we can see line graphics (for example, dialog uses)
correctly.
Signed-off-by: OGAWA Hirofumi <address@hidden>
---
include/ui/console.h | 11 ++++++++++-
ui/curses.c | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 1 deletion(-)
diff -puN include/ui/console.h~support-curses-border include/ui/console.h
--- qemu/include/ui/console.h~support-curses-border 2015-10-14
20:25:56.681826861 +0900
+++ qemu-hirofumi/include/ui/console.h 2015-10-14 20:25:56.685826856 +0900
@@ -284,13 +284,22 @@ static inline pixman_format_code_t surfa
#ifdef CONFIG_CURSES
#include <curses.h>
typedef chtype console_ch_t;
+extern chtype vga_to_curses[];
#else
typedef unsigned long console_ch_t;
#endif
static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
{
- if (!(ch & 0xff))
+ uint8_t c = ch;
+#ifdef CONFIG_CURSES
+ if (vga_to_curses[c]) {
+ ch &= ~(console_ch_t)0xff;
+ ch |= vga_to_curses[c];
+ }
+#else
+ if (c == '\0')
ch |= ' ';
+#endif
*dest = ch;
}
diff -puN ui/curses.c~support-curses-border ui/curses.c
--- qemu/ui/curses.c~support-curses-border 2015-10-14 20:25:56.681826861
+0900
+++ qemu-hirofumi/ui/curses.c 2015-10-14 20:25:56.685826856 +0900
@@ -42,6 +42,8 @@ static WINDOW *screenpad = NULL;
static int width, height, gwidth, gheight, invalidate;
static int px, py, sminx, sminy, smaxx, smaxy;
+chtype vga_to_curses[256];
+
static void curses_update(DisplayChangeListener *dcl,
int x, int y, int w, int h)
{
@@ -346,6 +348,46 @@ static void curses_setup(void)
/* 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);
+
+ /* Setup mapping for vga to curses line graphics */
+ memset(vga_to_curses, 0, sizeof(vga_to_curses));
+ /* FIXME: for better font, have to use ncursesw and setlocale() */
+#if 0
+ /* FIXME: map from where? */
+ ACS_S1;
+ ACS_S3;
+ ACS_S7;
+ ACS_S9;
+#endif
+ vga_to_curses['\0'] = ' ';
+ vga_to_curses[0x04] = ACS_DIAMOND;
+ vga_to_curses[0x0a] = ACS_RARROW;
+ vga_to_curses[0x0b] = ACS_LARROW;
+ vga_to_curses[0x18] = ACS_UARROW;
+ vga_to_curses[0x19] = ACS_DARROW;
+ vga_to_curses[0x9c] = ACS_STERLING;
+ vga_to_curses[0xb0] = ACS_BOARD;
+ vga_to_curses[0xb1] = ACS_CKBOARD;
+ vga_to_curses[0xb3] = ACS_VLINE;
+ vga_to_curses[0xb4] = ACS_RTEE;
+ vga_to_curses[0xbf] = ACS_URCORNER;
+ vga_to_curses[0xc0] = ACS_LLCORNER;
+ vga_to_curses[0xc1] = ACS_BTEE;
+ vga_to_curses[0xc2] = ACS_TTEE;
+ vga_to_curses[0xc3] = ACS_LTEE;
+ vga_to_curses[0xc4] = ACS_HLINE;
+ vga_to_curses[0xc5] = ACS_PLUS;
+ vga_to_curses[0xce] = ACS_LANTERN;
+ vga_to_curses[0xd8] = ACS_NEQUAL;
+ vga_to_curses[0xd9] = ACS_LRCORNER;
+ vga_to_curses[0xda] = ACS_ULCORNER;
+ vga_to_curses[0xdb] = ACS_BLOCK;
+ vga_to_curses[0xe3] = ACS_PI;
+ vga_to_curses[0xf1] = ACS_PLMINUS;
+ vga_to_curses[0xf2] = ACS_GEQUAL;
+ vga_to_curses[0xf3] = ACS_LEQUAL;
+ vga_to_curses[0xf8] = ACS_DEGREE;
+ vga_to_curses[0xfe] = ACS_BULLET;
}
static void curses_keyboard_setup(void)
_
- [Qemu-devel] [RFC 0/3] improve/fix -curses mode, OGAWA Hirofumi, 2015/10/14
- [Qemu-devel] [PATCH 1/3] ui/curses: Fix monitor color with -curses when 256 colors, OGAWA Hirofumi, 2015/10/15
- [Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curses mode,
OGAWA Hirofumi <=
- [Qemu-devel] [PATCH 3/3] ui/curses: Fix pageup/pagedown on -curses, OGAWA Hirofumi, 2015/10/14
- Re: [Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curses mode, Eric Blake, 2015/10/14
- Re: [Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curses mode, Gerd Hoffmann, 2015/10/14
- Re: [Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curses mode, OGAWA Hirofumi, 2015/10/14
- Re: [Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curses mode, OGAWA Hirofumi, 2015/10/14
- [Qemu-devel] [PATCH v2 1/3] ui/curses: Support line graphics chars on -curses mode, OGAWA Hirofumi, 2015/10/14
- Re: [Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curses mode, Gerd Hoffmann, 2015/10/15
- Re: [Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curses mode, OGAWA Hirofumi, 2015/10/15
- Re: [Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curses mode, OGAWA Hirofumi, 2015/10/15
- Re: [Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curses mode, Gerd Hoffmann, 2015/10/15