From: Gerd Hoffmann <kraxel@redhat.com>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] ui/curses: Fix color attribute of monitor for curses
Date: Tue, 01 Dec 2015 15:11:21 +0100 [thread overview]
Message-ID: <1448979081.26005.10.camel@redhat.com> (raw)
In-Reply-To: <87r3j95407.fsf@mail.parknet.co.jp>
On So, 2015-11-29 at 22:28 +0900, OGAWA Hirofumi wrote:
> Current text_console_update() writes totally broken color attributes
> to console_write_ch(). The format now is writing,
>
> [WRONG]
> bold << 21 | fg << 12 | bg << 8 | char
> fg == 3bits curses color number
> bg == 3bits curses color number
>
> I can't see this format is where come from. Anyway, this doesn't work
> at all.
>
> What curses expects is actually (and vga.c is using),
>
> [RIGHT]
> bold << 21 | bg << 11 | fg << 8 | char
> fg == 3bits vga color number
> bg == 3bits vga color number
>
> And curses set COLOR_PAIR() up to match this format, and curses's
> chtype. I.e,
>
> bold | color_pair | char
> color_pair == (bg << 3 | fg)
>
> To fix, this simply uses VGA color number everywhere except curses.c
> internal. Then, convert it to above [RIGHT] format to write by
> console_write_ch(). And as bonus, this reduces to expose curses define
> to other parts (removes COLOR_* from console.c).
>
> [Tested the first line is displayed as white on blue back for monitor
> in curses console]
Nice cleanup.
> static const pixman_color_t color_table_rgb[2][8] = {
> { /* dark */
> - QEMU_RGB(0x00, 0x00, 0x00), /* black */
> - QEMU_RGB(0xaa, 0x00, 0x00), /* red */
> - QEMU_RGB(0x00, 0xaa, 0x00), /* green */
> - QEMU_RGB(0xaa, 0xaa, 0x00), /* yellow */
> - QEMU_RGB(0x00, 0x00, 0xaa), /* blue */
> - QEMU_RGB(0xaa, 0x00, 0xaa), /* magenta */
> - QEMU_RGB(0x00, 0xaa, 0xaa), /* cyan */
> - QEMU_RGB(0xaa, 0xaa, 0xaa), /* white */
> + [QEMU_COLOR_BLACK] = QEMU_RGB(0x00, 0x00, 0x00), /* black */
> + [QEMU_COLOR_BLUE] = QEMU_RGB(0x00, 0x00, 0xaa), /* blue */
> + [QEMU_COLOR_GREEN] = QEMU_RGB(0x00, 0xaa, 0x00), /* green */
> + [QEMU_COLOR_CYAN] = QEMU_RGB(0x00, 0xaa, 0xaa), /* cyan */
> + [QEMU_COLOR_RED] = QEMU_RGB(0xaa, 0x00, 0x00), /* red */
> + [QEMU_COLOR_MAGENTA] = QEMU_RGB(0xaa, 0x00, 0xaa), /* magenta */
> + [QEMU_COLOR_YELLOW] = QEMU_RGB(0xaa, 0xaa, 0x00), /* yellow */
> + [QEMU_COLOR_WHITE] = QEMU_RGB(0xaa, 0xaa, 0xaa), /* white */
The color comments are kind of redundant now ...
cheers,
Gerd
next prev parent reply other threads:[~2015-12-01 14:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-29 13:28 [Qemu-devel] [PATCH] ui/curses: Fix color attribute of monitor for curses OGAWA Hirofumi
2015-12-01 14:11 ` Gerd Hoffmann [this message]
2015-12-01 18:43 ` OGAWA Hirofumi
2015-12-01 18:44 ` [Qemu-devel] [PATCH v2] " OGAWA Hirofumi
2015-12-15 10:37 ` Gerd Hoffmann
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=1448979081.26005.10.camel@redhat.com \
--to=kraxel@redhat.com \
--cc=hirofumi@mail.parknet.co.jp \
--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 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).