From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id 84CA53858C60 for ; Sat, 22 Jan 2022 01:38:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 84CA53858C60 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id E5A7A100474A5 for ; Sat, 22 Jan 2022 01:38:07 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id B5LznMKgtikTnB5LznyZpk; Sat, 22 Jan 2022 01:38:07 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=CeHNWJnl c=1 sm=1 tr=0 ts=61eb5fff a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=DghFqjY3_ZEA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=qLm4pIFyaQINpkgqLdUA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=HY84GyNM8nxk7yl635UlI/uoMhx3C70pBYlqi6VFL/I=; b=dr6N+JNZD/cTYnIPKhfiaKB9DN amfJAJbehn9bVgf2psP9hPskQfnpNyaScZqjHxLy3USugTXXtyblCybjxUwlz4kgDj91PuTibqUHk U+lOxdd66obO/FFbH62l1krFm; Received: from 75-166-128-165.hlrn.qwest.net ([75.166.128.165]:40602 helo=prentzel.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nB5Ly-001DeE-Bh; Fri, 21 Jan 2022 18:38:06 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 05/19] Add style-escape methods to ui_file Date: Fri, 21 Jan 2022 18:37:47 -0700 Message-Id: <20220122013801.666659-6-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220122013801.666659-1-tom@tromey.com> References: <20220122013801.666659-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.128.165 X-Source-L: No X-Exim-ID: 1nB5Ly-001DeE-Bh X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-128-165.hlrn.qwest.net (prentzel.Home) [75.166.128.165]:40602 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3031.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Jan 2022 01:38:09 -0000 This adds emit_style_escape and reset_style methods to ui_file. These aren't used yet, but they will be once the pager is converted to be a ui_file subclass. --- gdb/ui-file.c | 24 ++++++++++++++++++++++++ gdb/ui-file.h | 19 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/gdb/ui-file.c b/gdb/ui-file.c index 354a7c3e3b6..2072fd81954 100644 --- a/gdb/ui-file.c +++ b/gdb/ui-file.c @@ -73,6 +73,30 @@ ui_file::vprintf (const char *format, va_list args) /* See ui-file.h. */ +void +ui_file::emit_style_escape (const ui_file_style &style) +{ + if (can_emit_style_escape () && style != m_applied_style) + { + m_applied_style = style; + this->puts (style.to_ansi ().c_str ()); + } +} + +/* See ui-file.h. */ + +void +ui_file::reset_style () +{ + if (can_emit_style_escape ()) + { + m_applied_style = ui_file_style (); + this->puts (m_applied_style.to_ansi ().c_str ()); + } +} + +/* See ui-file.h. */ + void ui_file::printchar (int c, int quoter, bool async_safe) { diff --git a/gdb/ui-file.h b/gdb/ui-file.h index 101769d73a2..1ea2f60591c 100644 --- a/gdb/ui-file.h +++ b/gdb/ui-file.h @@ -109,6 +109,12 @@ class ui_file void wrap_here (int indent); + /* Emit an ANSI style escape for STYLE. */ + virtual void emit_style_escape (const ui_file_style &style); + + /* Rest the current output style to the empty style. */ + virtual void reset_style (); + /* Print STR, bypassing any paging that might be done by this ui_file. Note that nearly no code should call this -- it's intended for use by printf_filtered, but nothing else. */ @@ -117,6 +123,11 @@ class ui_file this->puts (str); } +protected: + + /* The currently applied style. */ + ui_file_style m_applied_style; + private: /* Helper function for putstr and putstrn. Print the character C on @@ -351,6 +362,14 @@ class no_terminal_escape_file : public stdio_file sequences. */ void write (const char *buf, long length_buf) override; void puts (const char *linebuffer) override; + + void emit_style_escape (const ui_file_style &style) override + { + } + + void reset_style () override + { + } }; /* A ui_file that optionally puts a timestamp at the start of each -- 2.31.1