From patchwork Thu Jul 4 17:02:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33566 Received: (qmail 107507 invoked by alias); 4 Jul 2019 17:03:42 -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 106194 invoked by uid 89); 4 Jul 2019 17:03:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=screen X-HELO: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.60.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 17:03:26 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 4D602400D746B for ; Thu, 4 Jul 2019 11:01:14 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j58nhuwWd2PzOj58nh7dNr; Thu, 04 Jul 2019 12:03:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=FahdpEoKexN4PbCO2tyLenCgF1lkSWSaD3j8gkn3NDw=; b=szdZyY/1C14EV/WO88WBCJit70 n7Nvv/B58F2VlJ/EJS/UHpjp5eO+BYVbSfooAKRvTUlNP1KT2CZORu/KUaOO6+UVO3HaKaBC92osB Mo5yJFjjGuCgIwWtv2FsX6UBc; Received: from 174-29-58-150.hlrn.qwest.net ([174.29.58.150]:34696 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1hj58n-002sIW-Fp; Thu, 04 Jul 2019 12:03:25 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 30/61] Simplify source window clearing Date: Thu, 4 Jul 2019 11:02:40 -0600 Message-Id: <20190704170311.15982-31-tom@tromey.com> In-Reply-To: <20190704170311.15982-1-tom@tromey.com> References: <20190704170311.15982-1-tom@tromey.com> When a TUI source window is empty, it displays a "No Source Available" message. The function tui_set_source_content_nil also made sure to put this message into the window's "content" field. However, I believe this isn't really necessary. Instead, it's simpler to just empty the contents and let curses handle the refreshing. 2019-07-04 Tom Tromey * tui/tui-winsource.c (tui_erase_source_content): Clear the window's contents. * tui/tui-source.h (tui_set_source_content_nil): Don't declare. * tui/tui-source.c (tui_set_source_content_nil): Remove. --- gdb/ChangeLog | 7 +++++ gdb/tui/tui-source.c | 63 ----------------------------------------- gdb/tui/tui-source.h | 3 -- gdb/tui/tui-winsource.c | 8 +----- 4 files changed, 8 insertions(+), 73 deletions(-) diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 2fcb42d9299..d3cce1c3003 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -209,69 +209,6 @@ tui_set_source_content (tui_source_window_base *win_info, } -/* elz: This function sets the contents of the source window to empty - except for a line in the middle with a warning message about the - source not being available. This function is called by - tui_erase_source_contents(), which in turn is invoked when the - source files cannot be accessed. */ - -void -tui_set_source_content_nil (struct tui_source_window_base *win_info, - const char *warning_string) -{ - int line_width; - int n_lines; - int curr_line = 0; - - line_width = win_info->width - 1; - n_lines = win_info->height - 2; - - /* Set to empty each line in the window, except for the one which - contains the message. */ - while (curr_line < win_info->content.size ()) - { - /* Set the information related to each displayed line to null: - i.e. the line number is 0, there is no bp, it is not where - the program is stopped. */ - - struct tui_source_element *element = &win_info->content[curr_line]; - - element->line_or_addr.loa = LOA_LINE; - element->line_or_addr.u.line_no = 0; - element->is_exec_point = false; - element->break_mode = 0; - - /* Set the contents of the line to blank. */ - element->line[0] = (char) 0; - - /* If the current line is in the middle of the screen, then we - want to display the 'no source available' message in it. - Note: the 'weird' arithmetic with the line width and height - comes from the function tui_erase_source_content(). We need - to keep the screen and the window's actual contents in - synch. */ - - if (curr_line == (n_lines / 2 + 1)) - { - int xpos; - int warning_length = strlen (warning_string); - char *src_line; - - if (warning_length >= ((line_width - 1) / 2)) - xpos = 1; - else - xpos = (line_width - 1) / 2 - warning_length; - - src_line = xstrprintf ("%s%s", n_spaces (xpos), warning_string); - xfree (element->line); - element->line = src_line; - } - - curr_line++; - } -} - - /* Function to display source in the source window. This function initializes the horizontal scroll to 0. */ void diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h index e4b23133af9..fc129ab8f26 100644 --- a/gdb/tui/tui-source.h +++ b/gdb/tui/tui-source.h @@ -27,9 +27,6 @@ struct symtab; struct tui_win_info; -extern void tui_set_source_content_nil (struct tui_source_window_base *, - const char *); - extern enum tui_status tui_set_source_content (tui_source_window_base *, struct symtab *, int, int); diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 65aa5164122..2be20492f47 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -250,13 +250,7 @@ tui_erase_source_content (struct tui_source_window_base *win_info) x_pos, (char *) no_src_str); - /* elz: Added this function call to set the real contents of - the window to what is on the screen, so that later calls - to refresh, do display the correct stuff, and not the old - image. */ - - tui_set_source_content_nil (win_info, no_src_str); - + win_info->content.clear (); win_info->refresh_window (); } }