From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3leT-0007lE-ID for qemu-devel@nongnu.org; Tue, 01 Dec 2015 09:11:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3leO-0007Lj-V9 for qemu-devel@nongnu.org; Tue, 01 Dec 2015 09:11:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3leO-0007KH-PG for qemu-devel@nongnu.org; Tue, 01 Dec 2015 09:11:24 -0500 Message-ID: <1448979081.26005.10.camel@redhat.com> From: Gerd Hoffmann Date: Tue, 01 Dec 2015 15:11:21 +0100 In-Reply-To: <87r3j95407.fsf@mail.parknet.co.jp> References: <87r3j95407.fsf@mail.parknet.co.jp> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] ui/curses: Fix color attribute of monitor for curses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: OGAWA Hirofumi Cc: qemu-devel@nongnu.org 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, >=20 > [WRONG] > bold << 21 | fg << 12 | bg << 8 | char > fg =3D=3D 3bits curses color number > bg =3D=3D 3bits curses color number >=20 > I can't see this format is where come from. Anyway, this doesn't work > at all. >=20 > What curses expects is actually (and vga.c is using), >=20 > [RIGHT] > bold << 21 | bg << 11 | fg << 8 | char > fg =3D=3D 3bits vga color number > bg =3D=3D 3bits vga color number >=20 > And curses set COLOR_PAIR() up to match this format, and curses's > chtype. I.e, >=20 > bold | color_pair | char > color_pair =3D=3D (bg << 3 | fg) >=20 > 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). >=20 > [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] =3D { > { /* 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] =3D QEMU_RGB(0x00, 0x00, 0x00), /* black *= / > + [QEMU_COLOR_BLUE] =3D QEMU_RGB(0x00, 0x00, 0xaa), /* blue */ > + [QEMU_COLOR_GREEN] =3D QEMU_RGB(0x00, 0xaa, 0x00), /* green *= / > + [QEMU_COLOR_CYAN] =3D QEMU_RGB(0x00, 0xaa, 0xaa), /* cyan */ > + [QEMU_COLOR_RED] =3D QEMU_RGB(0xaa, 0x00, 0x00), /* red */ > + [QEMU_COLOR_MAGENTA] =3D QEMU_RGB(0xaa, 0x00, 0xaa), /* magenta= */ > + [QEMU_COLOR_YELLOW] =3D QEMU_RGB(0xaa, 0xaa, 0x00), /* yellow = */ > + [QEMU_COLOR_WHITE] =3D QEMU_RGB(0xaa, 0xaa, 0xaa), /* white *= / The color comments are kind of redundant now ... cheers, Gerd