* [Qemu-devel] [PATCH v2 1/3] ui/curses: Fix monitor color with -curses when 256 colors
@ 2015-10-19 12:23 OGAWA Hirofumi
2015-10-19 12:23 ` [Qemu-devel] [PATCH v2 2/3] ui/curses: Support line graphics chars on -curses mode OGAWA Hirofumi
2015-10-19 12:24 ` [Qemu-devel] [PATCH v2 3/3] ui/curses: Fix pageup/pagedown on -curses OGAWA Hirofumi
0 siblings, 2 replies; 3+ messages in thread
From: OGAWA Hirofumi @ 2015-10-19 12:23 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
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 <hirofumi@mail.parknet.co.jp>
---
ui/curses.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff -puN ui/curses.c~support-curses-256color ui/curses.c
--- qemu/ui/curses.c~support-curses-256color 2015-10-14 20:12:06.311051365 +0900
+++ qemu-hirofumi/ui/curses.c 2015-10-19 21:16:24.595994457 +0900
@@ -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)
_
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH v2 2/3] ui/curses: Support line graphics chars on -curses mode
2015-10-19 12:23 [Qemu-devel] [PATCH v2 1/3] ui/curses: Fix monitor color with -curses when 256 colors OGAWA Hirofumi
@ 2015-10-19 12:23 ` OGAWA Hirofumi
2015-10-19 12:24 ` [Qemu-devel] [PATCH v2 3/3] ui/curses: Fix pageup/pagedown on -curses OGAWA Hirofumi
1 sibling, 0 replies; 3+ messages in thread
From: OGAWA Hirofumi @ 2015-10-19 12:23 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
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 <hirofumi@mail.parknet.co.jp>
---
include/ui/console.h | 12 +++++++++++-
ui/curses.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 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-19 21:16:50.439929458 +0900
+++ qemu-hirofumi/include/ui/console.h 2015-10-19 21:17:57.939760088 +0900
@@ -284,13 +284,23 @@ 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-19 21:16:50.439929458 +0900
+++ qemu-hirofumi/ui/curses.c 2015-10-19 21:17:09.587881354 +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)
{
@@ -348,6 +350,48 @@ static void curses_setup(void)
for (i = 64; i < COLOR_PAIRS; i++) {
init_pair(i, COLOR_WHITE, COLOR_BLACK);
}
+
+ /*
+ * Setup mapping for vga to curses line graphics.
+ * 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
+ /* ACS_* is not constant. So, we can't initialize statically. */
+ 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)
_
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH v2 3/3] ui/curses: Fix pageup/pagedown on -curses
2015-10-19 12:23 [Qemu-devel] [PATCH v2 1/3] ui/curses: Fix monitor color with -curses when 256 colors OGAWA Hirofumi
2015-10-19 12:23 ` [Qemu-devel] [PATCH v2 2/3] ui/curses: Support line graphics chars on -curses mode OGAWA Hirofumi
@ 2015-10-19 12:24 ` OGAWA Hirofumi
1 sibling, 0 replies; 3+ messages in thread
From: OGAWA Hirofumi @ 2015-10-19 12:24 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
Current KEY_NPAGE/KEY_PPAGE handling is broken on -curses. Those uses
"GREY", but "KEY_MASK" masked out "GREY".
To fix, we have to use correct mask value - SCANCODE_KEYMASK.
Then, this adds support of "shift + pageup/pagedown". With this,
-curses mode can use scroll-up/down as usual like other display modes.
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---
ui/curses_keys.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff -puN ui/curses_keys.h~support-curses-pageup ui/curses_keys.h
--- qemu/ui/curses_keys.h~support-curses-pageup 2015-10-19 21:18:09.107732122 +0900
+++ qemu-hirofumi/ui/curses_keys.h 2015-10-19 21:18:09.111732112 +0900
@@ -29,8 +29,7 @@
#include "keymaps.h"
-#define KEY_RELEASE 0x80
-#define KEY_MASK 0x7f
+#define KEY_MASK SCANCODE_KEYMASK
#define GREY_CODE 0xe0
#define GREY SCANCODE_GREY
#define SHIFT_CODE 0x2a
@@ -60,6 +59,8 @@ static const int curses2keysym[CURSES_KE
['\n'] = KEY_ENTER,
[27] = 27,
[KEY_BTAB] = '\t' | KEYSYM_SHIFT,
+ [KEY_SPREVIOUS] = KEY_PPAGE | KEYSYM_SHIFT,
+ [KEY_SNEXT] = KEY_NPAGE | KEYSYM_SHIFT,
};
static const int curses2keycode[CURSES_KEYS] = {
@@ -149,6 +150,9 @@ static const int curses2keycode[CURSES_K
[KEY_IC] = 82 | GREY, /* Insert */
[KEY_DC] = 83 | GREY, /* Delete */
+ [KEY_SPREVIOUS] = 73 | GREY | SHIFT, /* Shift + Page Up */
+ [KEY_SNEXT] = 81 | GREY | SHIFT, /* Shift + Page Down */
+
['!'] = 2 | SHIFT,
['@'] = 3 | SHIFT,
['#'] = 4 | SHIFT,
_
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-19 12:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-19 12:23 [Qemu-devel] [PATCH v2 1/3] ui/curses: Fix monitor color with -curses when 256 colors OGAWA Hirofumi
2015-10-19 12:23 ` [Qemu-devel] [PATCH v2 2/3] ui/curses: Support line graphics chars on -curses mode OGAWA Hirofumi
2015-10-19 12:24 ` [Qemu-devel] [PATCH v2 3/3] ui/curses: Fix pageup/pagedown on -curses OGAWA Hirofumi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).