All of lore.kernel.org
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v3] ui/curses: Support line graphics chars on -curses mode
Date: Thu, 15 Oct 2015 18:54:54 +0900	[thread overview]
Message-ID: <87twps5udt.fsf_-_@mail.parknet.co.jp> (raw)
In-Reply-To: <87y4f45uer.fsf@mail.parknet.co.jp> (OGAWA Hirofumi's message of "Thu, 15 Oct 2015 18:54:20 +0900")

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 |    9 ++------
 ui/console.c         |   13 ++++++++++++
 ui/curses.c          |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 69 insertions(+), 6 deletions(-)

diff -puN include/ui/console.h~support-curses-border include/ui/console.h
--- qemu/include/ui/console.h~support-curses-border	2015-10-15 18:18:18.702781174 +0900
+++ qemu-hirofumi/include/ui/console.h	2015-10-15 18:43:06.927991391 +0900
@@ -287,12 +287,9 @@ typedef chtype console_ch_t;
 #else
 typedef unsigned long console_ch_t;
 #endif
-static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
-{
-    if (!(ch & 0xff))
-        ch |= ' ';
-    *dest = ch;
-}
+typedef void (hw_text_update_t)(console_ch_t *, uint32_t);
+void register_hw_text_update_cb(hw_text_update_t *cb);
+void console_write_ch(console_ch_t *dest, uint32_t ch);
 
 typedef struct GraphicHwOps {
     void (*invalidate)(void *opaque);
diff -puN ui/curses.c~support-curses-border ui/curses.c
--- qemu/ui/curses.c~support-curses-border	2015-10-15 18:18:18.702781174 +0900
+++ qemu-hirofumi/ui/curses.c	2015-10-15 18:44:56.511788663 +0900
@@ -41,6 +41,17 @@ static console_ch_t screen[160 * 100];
 static WINDOW *screenpad = NULL;
 static int width, height, gwidth, gheight, invalidate;
 static int px, py, sminx, sminy, smaxx, smaxy;
+static chtype vga_to_curses[256];
+
+static void curses_write_ch(console_ch_t *dest, uint32_t ch)
+{
+    uint8_t c = ch;
+    if (vga_to_curses[c]) {
+        ch &= ~(console_ch_t)0xff;
+        ch |= vga_to_curses[c];
+    }
+    *dest = ch;
+}
 
 static void curses_update(DisplayChangeListener *dcl,
                           int x, int y, int w, int h)
@@ -346,6 +357,47 @@ 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.
+     * 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)
@@ -379,6 +431,7 @@ void curses_display_init(DisplayState *d
     }
 #endif
 
+    register_hw_text_update_cb(curses_write_ch);
     curses_setup();
     curses_keyboard_setup();
     atexit(curses_atexit);
diff -puN ui/console.c~support-curses-border ui/console.c
--- qemu/ui/console.c~support-curses-border	2015-10-15 18:18:32.482754986 +0900
+++ qemu-hirofumi/ui/console.c	2015-10-15 18:43:22.191963132 +0900
@@ -333,6 +333,19 @@ void qmp_screendump(const char *filename
     ppm_save(filename, surface, errp);
 }
 
+static hw_text_update_t *hw_text_update_cb;
+
+void register_hw_text_update_cb(hw_text_update_t *cb)
+{
+    hw_text_update_cb = cb;
+}
+
+void console_write_ch(console_ch_t *dest, uint32_t ch)
+{
+    if (hw_text_update_cb)
+        hw_text_update_cb(dest, ch);
+}
+
 void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata)
 {
     if (!con) {
_

  reply	other threads:[~2015-10-15  9:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-14 11:35 [Qemu-devel] [RFC 0/3] improve/fix -curses mode OGAWA Hirofumi
2015-10-14 11:36 ` [Qemu-devel] [PATCH 1/3] ui/curses: Fix monitor color with -curses when 256 colors OGAWA Hirofumi
2015-10-14 11:37   ` [Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curses mode OGAWA Hirofumi
2015-10-14 11:37     ` [Qemu-devel] [PATCH 3/3] ui/curses: Fix pageup/pagedown on -curses OGAWA Hirofumi
2015-10-14 14:04     ` [Qemu-devel] [PATCH 2/3] ui/curses: Support line graphics chars on -curses mode Eric Blake
2015-10-14 15:44     ` Gerd Hoffmann
2015-10-14 23:58       ` OGAWA Hirofumi
2015-10-15  0:06         ` OGAWA Hirofumi
2015-10-15  0:07           ` [Qemu-devel] [PATCH v2 1/3] " OGAWA Hirofumi
2015-10-15  7:48         ` [Qemu-devel] [PATCH 2/3] " Gerd Hoffmann
2015-10-15  8:24           ` OGAWA Hirofumi
2015-10-15  8:50             ` OGAWA Hirofumi
2015-10-15  9:13               ` Gerd Hoffmann
2015-10-15  9:54                 ` OGAWA Hirofumi
2015-10-15  9:54                   ` OGAWA Hirofumi [this message]
2015-10-19 10:14                   ` Gerd Hoffmann
2015-10-19 12:22                     ` OGAWA Hirofumi
2015-10-15  9:14             ` Gerd Hoffmann
2015-10-15  9:58               ` OGAWA Hirofumi
2015-10-15 10:01                 ` [Qemu-devel] [PATCH v4] " OGAWA Hirofumi
2015-10-14 16:46 ` [Qemu-devel] [RFC 0/3] improve/fix " Markus Armbruster
2015-10-14 23:59   ` OGAWA Hirofumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87twps5udt.fsf_-_@mail.parknet.co.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.