qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] ui/curses: Fix color attribute of monitor for c


From: Gerd Hoffmann
Subject: Re: [Qemu-devel] [PATCH] ui/curses: Fix color attribute of monitor for curses
Date: Tue, 01 Dec 2015 15:11:21 +0100

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]