From patchwork Wed Mar 13 15:50:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Zaretskii X-Patchwork-Id: 31843 Received: (qmail 60211 invoked by alias); 13 Mar 2019 15:50:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 60141 invoked by uid 89); 13 Mar 2019 15:50:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1915, wwwsourcewareorg, www.sourceware.org, sk:wwwsou X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Mar 2019 15:50:09 +0000 Received: from fencepost.gnu.org ([2001:470:142:3::e]:48819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h468q-0004Lz-Ql; Wed, 13 Mar 2019 11:50:05 -0400 Received: from [176.228.60.248] (port=2322 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1h468q-0004Sx-4H; Wed, 13 Mar 2019 11:50:04 -0400 Date: Wed, 13 Mar 2019 17:50:02 +0200 Message-Id: <83k1h23hat.fsf@gnu.org> From: Eli Zaretskii To: tromey@adacore.com CC: gdb-patches@sourceware.org In-reply-to: <8336ns3uv4.fsf@gnu.org> (message from Eli Zaretskii on Tue, 12 Mar 2019 18:44:47 +0200) Subject: Re: [RFC 8.3 0/3] Some style fixes References: <20190308210433.32683-1-tromey@adacore.com> <83pnr08tc8.fsf@gnu.org> <83zhq26fcw.fsf@gnu.org> <874l899nh3.fsf@tromey.com> <8336ns3uv4.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-IsSubscribed: yes For the MinGW-specific problem with TUI colors, described here: https://www.sourceware.org/ml/gdb-patches/2019-03/msg00000.html https://www.sourceware.org/ml/gdb-patches/2019-03/msg00034.html I propose to fix that as in the patch below. Any objections to my pushing this to the master and th gdb-8.3 branch (with suitable ChangeLog entries)? --- gdb/tui/tui-io.c~5 2019-03-12 09:18:11.713960000 +0200 +++ gdb/tui/tui-io.c 2019-03-13 09:09:15.185827600 +0200 @@ -37,6 +37,10 @@ #include "cli-out.h" #include #include +#ifdef __MINGW32__ +#include +static SHORT ncurses_norm_attr; +#endif #include "common/filestuff.h" #include "completer.h" #include "gdb_curses.h" @@ -322,6 +326,16 @@ apply_ansi_escape (WINDOW *w, const char int fgi, bgi; if (get_color (fg, &fgi) && get_color (bg, &bgi)) { +#ifdef __MINGW32__ + /* MS-Windows port of ncurses doesn't support implicit + default foreground and background colors, so we must + specify them explicitly when needed, using the colors we + saw at startup. */ + if (fgi == -1) + fgi = ncurses_norm_attr & 15; + if (bgi == -1) + bgi = (ncurses_norm_attr >> 4) & 15; +#endif int pair = get_color_pair (fgi, bgi); if (last_color_pair != -1) wattroff (w, COLOR_PAIR (last_color_pair)); @@ -803,6 +817,19 @@ tui_initialize_io (void) #else tui_rl_outstream = stdout; #endif + +#ifdef __MINGW32__ + /* MS-Windows port of ncurses doesn't support default foreground and + background colors, so we must record the default colors at startup. */ + HANDLE hstdout = (HANDLE)_get_osfhandle (fileno (stdout)); + DWORD cmode; + CONSOLE_SCREEN_BUFFER_INFO csbi; + + if (hstdout != INVALID_HANDLE_VALUE + && GetConsoleMode (hstdout, &cmode) != 0 + && GetConsoleScreenBufferInfo (hstdout, &csbi)) + ncurses_norm_attr = csbi.wAttributes; +#endif } /* Get a character from the command window. This is called from the