From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 996EA3858C41 for ; Fri, 19 May 2023 21:38:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 996EA3858C41 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684532311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hvYTwclGDOd3wL1HUD9RtLqv1dQdAaIvDr30ktiKZFc=; b=NRxCx+UPcImFpr/XJuu22HDxI6FONsLpUL5TCY2ykH27ie1gJbGbDzLMe9aD4jpPCpcvFq ZM8WYmko9M//mNQ+Xd5Xhf1FSsJO0XbLd3g8Wyyf/Ie62i2uV06aZ2gi9gCaJJsFywcraf OWAfJ0g/ojjGrJ6Ny7UITNqiL9usbjo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-595-M6rPROhgNOmaO51PwkjSIg-1; Fri, 19 May 2023 17:38:29 -0400 X-MC-Unique: M6rPROhgNOmaO51PwkjSIg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 99EA885A5AA; Fri, 19 May 2023 21:38:29 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.16.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62BB57B7C; Fri, 19 May 2023 21:38:29 +0000 (UTC) From: Aaron Merey To: eliz@gnu.org Cc: gdb-patches@sourceware.org, Aaron Merey Subject: [PATCH] gdb/cli-out.c: clear_current_line shouldn't trigger pagination prompt Date: Fri, 19 May 2023 17:38:24 -0400 Message-Id: <20230519213824.117794-1-amerey@redhat.com> In-Reply-To: <831qjh104j.fsf@gnu.org> References: <831qjh104j.fsf@gnu.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, May 15, 2023 at 10:27 PM Eli Zaretskii wrote: > > > From: Aaron Merey > > Date: Mon, 15 May 2023 17:32:48 -0400 > > Cc: gdb-patches@sourceware.org > > > > > I'm not sure we should rely on the fact that the final character of > > > the line is never there. clear_current_line is a general-purpose > > > method, so it should do its job regardless. > > > > > > Can't we do something to handle the last character as well? E.g., > > > could it be possible first to delete one character, so there are > > > really only N-1 characters to fill with blank spaces? > > > > We could rename clear_current_line to something like clear_progress_notify > > to help indicate that this is a special purpose function. We could also > > just disable pagination for the duration of clear_current_line. > > I think we should do both, thanks. I revised the patch with clear_current_line renamed to clear_progress_notify. This function has been changed back to overwriting an entire line with whitespace and pagination is disabled for its duration. Aaron --- gdb/cli-out.c | 11 +++++++---- gdb/cli-out.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gdb/cli-out.c b/gdb/cli-out.c index 4c598883d4b..20d3d93f1ad 100644 --- a/gdb/cli-out.c +++ b/gdb/cli-out.c @@ -378,15 +378,18 @@ cli_ui_out::do_progress_notify (const std::string &msg, return; } -/* Clear the current line of the most recent progress update. Overwrites - the current line with whitespace. */ +/* Clear do_progress_notify output from the current line. Overwrites the + notification with whitespace. */ void -cli_ui_out::clear_current_line () +cli_ui_out::clear_progress_notify () { struct ui_file *stream = m_streams.back (); int chars_per_line = get_chars_per_line (); + scoped_restore save_pagination + = make_scoped_restore (&pagination_enabled, false); + if (!stream->isatty () || !current_ui->input_interactive_p () || chars_per_line < MIN_CHARS_PER_LINE) @@ -413,7 +416,7 @@ cli_ui_out::do_progress_end () m_progress_info.pop_back (); if (stream->isatty ()) - clear_current_line (); + clear_progress_notify (); } /* local functions */ diff --git a/gdb/cli-out.h b/gdb/cli-out.h index 0729834cbc6..34016182269 100644 --- a/gdb/cli-out.h +++ b/gdb/cli-out.h @@ -104,7 +104,7 @@ class cli_ui_out : public ui_out /* Stack of progress info. */ std::vector m_progress_info; - void clear_current_line (); + void clear_progress_notify (); }; extern void cli_display_match_list (char **matches, int len, int max); -- 2.39.2