From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1757 invoked by alias); 1 Mar 2019 19:40:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 1729 invoked by uid 89); 1 Mar 2019 19:40:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=policies 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; Fri, 01 Mar 2019 19:40:40 +0000 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54708) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzo1C-0003h3-Ve; Fri, 01 Mar 2019 14:40:33 -0500 Received: from [176.228.60.248] (port=1083 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gzo1B-0007Px-Fl; Fri, 01 Mar 2019 14:40:26 -0500 Date: Fri, 01 Mar 2019 19:40:00 -0000 Message-Id: <83va12gz8j.fsf@gnu.org> From: Eli Zaretskii To: Tom Tromey CC: gdb-patches@sourceware.org In-reply-to: <87h8cmh1wg.fsf@tromey.com> (message from Tom Tromey on Fri, 01 Mar 2019 11:42:39 -0700) Subject: Re: [PATCH 00/16] Add styling to the gdb CLI and TUI References: <20181128001435.12703-1-tom@tromey.com> <83k1kxfzwo.fsf@gnu.org> <8736rja4i8.fsf@tromey.com> <83r2brhw8k.fsf@gnu.org> <87h8cmh1wg.fsf@tromey.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00014.txt.bz2 > From: Tom Tromey > Cc: Tom Tromey , gdb-patches@sourceware.org > Date: Fri, 01 Mar 2019 11:42:39 -0700 > > Right now styling works because, in the end, ANSI escape sequences are > emitted via stdio_file::puts, which just calls fputs. > > However, my understanding is that the Windows console instead requires > styling to be done by making various API calls. > > So, the idea is to replace stdio_file::puts with a function that, for > the Windows console only, parses out the ANSI escapes from the output > string and replaces those with the appropriate API calls. Right. My question is about the details, or, more accurately, about stylistic conventions and policies in such cases. > This made sense to me as a host-dependent function of some kind. But I > don't really know. I'm not sure I understand how to call that host-dependent function. You don't mean #ifdef, do you? My idea was to do something like void stdio_file::puts (const char *linebuffer) { #ifdef _WIN32 w32_fputs (linebuffer, m_file); #else /* Calling error crashes when we are called from the exception framework. */ if (fputs (linebuffer, m_file)) { /* Nothing. */ } #endif } where w32_fputs will DTRT for Windows. If this is not what you had in mind, can you maybe point me to a place where host-dependent functions are called? > The TUI does essentially this in order to convert ANSI escapes into > curses calls. See tui-io.c:tui_puts_internal and apply_ansi_escape. > The parsing work is done by the method ui_file_style::parse. Right, but TUI overrides the puts method, which is not what I need to do here. Thanks.