From nobody Wed Nov 12 10:07:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1570161335; cv=none; d=zoho.com; s=zohoarc; b=ioRWRdoHZKqztqvbJ5Unqr0XvWhTk3Y9azIq5JzIZ8gGxgcnNhahlHvypNlEAZ4wy4H/R/I1ayoZYorg+YJANbkOL+zCimcpBld9kexc+SqQ5EOOgJN6//Ul01jrfhB8PrvArSsWB2VsT0/y5Lz9vSoEyMq4xKibPYoJ/U+Uk14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570161335; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=DRplJ7s5wS8wWAiJ0s8iSyGbDczl1bzm8yyvKstkRwM=; b=gJfFdy4wpyswfG/bIdoLbY1EkEq1oj95l2fxsejmH6y5MGn82nTlLdU4/sQJlxynbAdxDGb0jKBEMUMk5JhHU99R5qtjCY53ZC0TVzJEjZVMFcn2SBFnlomNQo7vP7dpyYN8VLEoCDeicvXu3e75R6iVz2ZRK3uuXLoQ3IuBLlM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570161335885926.1560255664092; Thu, 3 Oct 2019 20:55:35 -0700 (PDT) Received: from localhost ([::1]:42046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGEgg-00018S-KA for importer@patchew.org; Thu, 03 Oct 2019 23:55:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53146) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGEfN-0000DN-A8 for qemu-devel@nongnu.org; Thu, 03 Oct 2019 23:54:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGEfM-0005cm-Am for qemu-devel@nongnu.org; Thu, 03 Oct 2019 23:54:05 -0400 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]:45993) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iGEfM-0005bs-5S for qemu-devel@nongnu.org; Thu, 03 Oct 2019 23:54:04 -0400 Received: by mail-io1-xd44.google.com with SMTP id c25so10483332iot.12 for ; Thu, 03 Oct 2019 20:54:04 -0700 (PDT) Received: from matt-laptop3.localdomain (d118-75-38-58.col.wideopenwest.com. [75.118.58.38]) by smtp.gmail.com with ESMTPSA id n17sm1570274ioj.73.2019.10.03.20.54.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2019 20:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DRplJ7s5wS8wWAiJ0s8iSyGbDczl1bzm8yyvKstkRwM=; b=WBGKMJ5+R5bTQYTON78PqI+80rbTZksQCK7GvyyE9s6XwrbJ1y8JlXiTkzoWAW15IT ZgOStmyoVQNr/LAmfzyrgOseEW05bnXWiSu99ZTWvVFCEjdSOHPpVNVZ3Hvsa4Nbjorb UmauygC1Xf8SBY29BNMcfbSAGVbzJldP955lbn8xCA+Lf9XyyDIaKcHDJWBbZfpa8cZB kUlfrgMiRicHd6cqRhptWq5Z9cGFCCR58C35dYTJpsuuWkjlkuktnqBTckg9UOedmQVQ hWCVtZawY+dXvvykqTn2gONdyiktHnh9AOQp4XiPfuoaZfKhD4WBqORdmIx5b3+cH3Yw gywQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DRplJ7s5wS8wWAiJ0s8iSyGbDczl1bzm8yyvKstkRwM=; b=il78UVqFjfAePczRQfScSlwY+aCfiLcSh6tJEET/wMjphskN05tfO6ehAHH8ADYyWT cDJfKptAZSD9B+/YdZKKtAvrQm5XHqiKrQVkZwaSoNuNPjvLd2+XTfi1awUDsxB789rs Ov9zGLtkslGAvOzT1HevbOzL4oVWVj5LK26a4AynfYsZGkHj7WYSpE/eVd/Tru3+02sQ ThvbivRwVx1QO81E5rxAXhnPvmD60Th+UtSnWFk67+Xt9j7lbdRfLhdQFDgXKh3hBP9B hwZtho4U4iSBHuLALiRLU4mcDuxW5NWmdN5C8vTXocq1JUWW1RS/o6cUeY6tPNhDuH3H U5oA== X-Gm-Message-State: APjAAAUbgrrGT5UK5V/eSTYP1XvChUjRZVJw4cRulUAiLggVYW9O/VqU h086dV/Z4JMYIXQQYnLpSYUe63yh X-Google-Smtp-Source: APXvYqzWmnAn93FQyCdk8ZKB9fDfmc/k2GvS+BnHJDPMDAXIjNee8vW06LdAWKSNqwhm5pwzb4tpUw== X-Received: by 2002:a92:5fd7:: with SMTP id i84mr13149817ill.125.1570161243222; Thu, 03 Oct 2019 20:54:03 -0700 (PDT) From: Matthew Kilgore To: qemu-devel@nongnu.org Subject: [PATCH v2 1/2] curses: use the bit mask constants provided by curses Date: Thu, 3 Oct 2019 23:53:37 -0400 Message-Id: <20191004035338.25601-2-mattkilgore12@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191004035338.25601-1-mattkilgore12@gmail.com> References: <20191004035338.25601-1-mattkilgore12@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::d44 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: samuel.thibault@ens-lyon.org, Matthew Kilgore , philmd@redhat.com, Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The curses API provides the A_ATTRIBUTES and A_CHARTEXT bit masks for getting the attributes and character parts of a chtype, respectively. We should use provided constants instead of using 0xff. Signed-off-by: Matthew Kilgore Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Samuel Thibault Tested-by: Samuel Thibault --- ui/curses.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/curses.c b/ui/curses.c index ec281125acbd..84003f56a323 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -75,8 +75,8 @@ static void curses_update(DisplayChangeListener *dcl, 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; + chtype ch =3D line[x] & A_CHARTEXT; + chtype at =3D line[x] & A_ATTRIBUTES; ret =3D getcchar(&vga_to_curses[ch], wch, &attrs, &colors, NUL= L); if (ret =3D=3D ERR || wch[0] =3D=3D 0) { wch[0] =3D ch; --=20 2.23.0 From nobody Wed Nov 12 10:07:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1570161402; cv=none; d=zoho.com; s=zohoarc; b=KjXcz6XYF88jRr4Ckl1hdwmHBdE3RxzMHZjN+WAikwKqo3ndEACEvsDbQgjqvRcqBF+wWuweRQgT/iblUriZbNE7aR9uC/zwPJsXAq9RQ1HZqcYKwsSaJ4y1YUTBPfQwQyO6DlB4XhJy2hvEUAku+a+FAPB+lm/ZJZyuJXUibEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570161402; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4t7F4icG7FK10qm+njYNIEACzuJH42++WTZ6mU1D06E=; b=bcxwXZ1I3qTOj8Rdnofe3J3ds2uxF7gn/xSqE+OkROm94ng4mxvCDIe54FxK8ZMUiaBW/2E7NwjsHhK2ZGkuninbVBCtqIcByyG3PKi0GRMj+oONbje6l2Nov2iAZMZXAXIf21n3RRBz2mZwRiwYotNkgowxRokJrkHI124Tx3Y= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570161402979756.2706353520376; Thu, 3 Oct 2019 20:56:42 -0700 (PDT) Received: from localhost ([::1]:42060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGEhs-0002Z5-0F for importer@patchew.org; Thu, 03 Oct 2019 23:56:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53193) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGEfP-0000Fw-EP for qemu-devel@nongnu.org; Thu, 03 Oct 2019 23:54:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGEfO-0005gj-HF for qemu-devel@nongnu.org; Thu, 03 Oct 2019 23:54:07 -0400 Received: from mail-io1-xd42.google.com ([2607:f8b0:4864:20::d42]:35498) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iGEfO-0005g5-CA for qemu-devel@nongnu.org; Thu, 03 Oct 2019 23:54:06 -0400 Received: by mail-io1-xd42.google.com with SMTP id q10so10622588iop.2 for ; Thu, 03 Oct 2019 20:54:06 -0700 (PDT) Received: from matt-laptop3.localdomain (d118-75-38-58.col.wideopenwest.com. [75.118.58.38]) by smtp.gmail.com with ESMTPSA id n17sm1570274ioj.73.2019.10.03.20.54.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2019 20:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4t7F4icG7FK10qm+njYNIEACzuJH42++WTZ6mU1D06E=; b=VJ28nETVahhrF9JTBU9QJrFcsHFrEyCjIefnqXVxBuC+d0FCdHJ4FOf/WdppsEPgbJ zpFRIbAkarrfJPx7muOTA0GoFHEt4mSj3UZa2v5rthXnUq3gqxEjN871sBx/hs8OoUDF gryv0bQzDJdWS1Qgj3M1LHUg4Mogl+2FR/7WnIjYN9/jVNKiJHLR70/LJrO9NWYO8Jcg DLweoXXYSZ45HWBZkS1KJYIHkh+9wBgBoObG/4crOMxaIajEOerr6n0OQSDelhu+5xrG xh8S/R4mxVhcZikXIsL6UshIl/xQrbBpULQm3PTLgfijE6UoeOf8VX7S/zuDZkcDo37R klHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4t7F4icG7FK10qm+njYNIEACzuJH42++WTZ6mU1D06E=; b=aNQsyIHT+bF8UQYI9FwSQ2rhhTfnmjzujnqZVsf1QtWpiNrsb5DnmvzdAAqlMVyWQ+ 2DlncmnBR41hlr+4uVg6BtUGYbWwyD4L4qUOjgIHDpqQV7z/7PtJNHsYYe2RGGCMoGxW NWdMjN0J2f7930vOQlb+QyeaeevCVKvQo+GT5Of5/1jeha3DZDydO9lRivYdoHQ+BoHA EWkpch7Mc7rndpqEd2WwTghTu0hdLyGuzNbvrfIbdTAsfydAdOk2rJAH3uv0xxIJjA81 fnDb9ssAzuWQg1sS8I0kM/xF8KRiVBkOyKGFM30QketDXZWWGBYakLVuj4HghRRe5QVg z0FQ== X-Gm-Message-State: APjAAAXF5LEyRCv8vU69ptdVSMTkOGp0QvskOxie1wTxJuU4cQmUYLfz FzHwkrRgBLZtiR2ITXjaz/GJ4Xlz X-Google-Smtp-Source: APXvYqyAsX+XYA1C5VGHcbrEz5ciFMPiK11aVjmeJ4armZym9u7n9ymMqJoAgfj2eE/vOcOFGPNwoA== X-Received: by 2002:a92:5a10:: with SMTP id o16mr14159987ilb.296.1570161245403; Thu, 03 Oct 2019 20:54:05 -0700 (PDT) From: Matthew Kilgore To: qemu-devel@nongnu.org Subject: [PATCH v2 2/2] curses: correctly pass the color pair to setcchar() Date: Thu, 3 Oct 2019 23:53:38 -0400 Message-Id: <20191004035338.25601-3-mattkilgore12@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191004035338.25601-1-mattkilgore12@gmail.com> References: <20191004035338.25601-1-mattkilgore12@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::d42 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: samuel.thibault@ens-lyon.org, Matthew Kilgore , philmd@redhat.com, Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The current code does not correctly pass the color pair information to setcchar(), it instead always passes zero. This results in the curses output always being in white on black. This patch fixes this by using PAIR_NUMBER() to retrieve the color pair number from the chtype value, and then passes that value as an argument to setcchar(). Signed-off-by: Matthew Kilgore Reviewed-by: Samuel Thibault Tested-by: Samuel Thibault --- ui/curses.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/curses.c b/ui/curses.c index 84003f56a323..3a1b71451c93 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -77,12 +77,14 @@ static void curses_update(DisplayChangeListener *dcl, for (x =3D 0; x < width; x++) { chtype ch =3D line[x] & A_CHARTEXT; chtype at =3D line[x] & A_ATTRIBUTES; + short color_pair =3D PAIR_NUMBER(line[x]); + ret =3D getcchar(&vga_to_curses[ch], wch, &attrs, &colors, NUL= L); if (ret =3D=3D ERR || wch[0] =3D=3D 0) { wch[0] =3D ch; wch[1] =3D 0; } - setcchar(&curses_line[x], wch, at, 0, NULL); + setcchar(&curses_line[x], wch, at, color_pair, NULL); } mvwadd_wchnstr(screenpad, y, 0, curses_line, width); } --=20 2.23.0