From nobody Sat Apr 27 18:01:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506501471443939.6247963218555; Wed, 27 Sep 2017 01:37:51 -0700 (PDT) Received: from localhost ([::1]:53423 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dx7qf-0006i2-Vv for importer@patchew.org; Wed, 27 Sep 2017 04:37:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dx7po-0006IY-EX for qemu-devel@nongnu.org; Wed, 27 Sep 2017 04:36:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dx7pi-0007yF-KH for qemu-devel@nongnu.org; Wed, 27 Sep 2017 04:36:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34352) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dx7pi-0007xD-C2 for qemu-devel@nongnu.org; Wed, 27 Sep 2017 04:36:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 929DF883C5 for ; Wed, 27 Sep 2017 08:36:40 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 723D75C696; Wed, 27 Sep 2017 08:36:37 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DF72C20488; Wed, 27 Sep 2017 10:36:36 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 929DF883C5 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 27 Sep 2017 10:36:36 +0200 Message-Id: <20170927083636.26648-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 27 Sep 2017 08:36:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] console: purge curses bits from console.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Handle the translation from vga chars to curses chars in curses_update() instead of console_write_ch(). Purge any curses support bits from ui/console.h include file. Signed-off-by: Gerd Hoffmann Reviewed-by: Richard Henderson --- include/ui/console.h | 23 ++--------------------- ui/curses.c | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 8024878bae..6966e4bd9d 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -336,29 +336,10 @@ static inline pixman_format_code_t surface_format(Dis= playSurface *s) return s->format; } =20 -#ifdef CONFIG_CURSES -/* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */ -#undef KEY_EVENT -#include -#undef KEY_EVENT -typedef chtype console_ch_t; -extern chtype vga_to_curses[]; -#else -typedef unsigned long console_ch_t; -#endif +typedef uint32_t console_ch_t; + static inline void console_write_ch(console_ch_t *dest, uint32_t ch) { - uint8_t c =3D ch; -#ifdef CONFIG_CURSES - if (vga_to_curses[c]) { - ch &=3D ~(console_ch_t)0xff; - ch |=3D vga_to_curses[c]; - } -#else - if (c =3D=3D '\0') { - ch |=3D ' '; - } -#endif *dest =3D ch; } =20 diff --git a/ui/curses.c b/ui/curses.c index 03cefdf470..85503876c0 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -33,6 +33,11 @@ #include "ui/input.h" #include "sysemu/sysemu.h" =20 +/* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */ +#undef KEY_EVENT +#include +#undef KEY_EVENT + #define FONT_HEIGHT 16 #define FONT_WIDTH 8 =20 @@ -42,16 +47,26 @@ static WINDOW *screenpad =3D NULL; static int width, height, gwidth, gheight, invalidate; static int px, py, sminx, sminy, smaxx, smaxy; =20 -chtype vga_to_curses[256]; +static chtype vga_to_curses[256]; =20 static void curses_update(DisplayChangeListener *dcl, int x, int y, int w, int h) { - chtype *line; + console_ch_t *line; + chtype curses_line[width]; =20 - line =3D ((chtype *) screen) + y * width; - for (h +=3D y; y < h; y ++, line +=3D width) - mvwaddchnstr(screenpad, y, 0, line, width); + line =3D screen + y * width; + for (h +=3D y; y < h; y ++, line +=3D width) { + for (x =3D 0; x < width; x++) { + chtype ch =3D line[x] & 0xff; + chtype at =3D line[x] & ~0xff; + if (vga_to_curses[ch]) { + ch =3D vga_to_curses[ch]; + } + curses_line[x] =3D ch | at; + } + mvwaddchnstr(screenpad, y, 0, curses_line, width); + } =20 pnoutrefresh(screenpad, py, px, sminy, sminx, smaxy - 1, smaxx - 1); refresh(); --=20 2.9.3