From patchwork Mon Jun 24 18:48:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33351 Received: (qmail 60158 invoked by alias); 24 Jun 2019 18:48:57 -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 60079 invoked by uid 89); 24 Jun 2019 18:48:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.4 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= X-HELO: gateway24.websitewelcome.com Received: from gateway24.websitewelcome.com (HELO gateway24.websitewelcome.com) (192.185.50.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Jun 2019 18:48:54 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 701DF54B8 for ; Mon, 24 Jun 2019 13:48:53 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id fU1NhYuX64FKpfU1NhpMFh; Mon, 24 Jun 2019 13:48:53 -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=/ATAsY8G7eGAtkjs7Rkmpg9FyTQFybxodyR5oi+hmRQ=; b=kIiP2FawVwSF6xP0ohBh28/zIh vhhxcT2munpJZFN8zZi0n+xTSa+MV+pX5yy7pHBk/dED48FcnYoPMXezHwg+wBujZxXXoVNtfkdo+ Ck0NrTK966eAKaVpbL6zE1e8y; Received: from 75-166-12-78.hlrn.qwest.net ([75.166.12.78]:56746 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hfU1N-003qDK-7I; Mon, 24 Jun 2019 13:48:53 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 56/66] Turn tui_first_data_item_displayed into a method Date: Mon, 24 Jun 2019 12:48:31 -0600 Message-Id: <20190624184841.3492-7-tom@tromey.com> In-Reply-To: <20190624184841.3492-1-tom@tromey.com> References: <20190623224329.16060-1-tom@tromey.com> <20190624184841.3492-1-tom@tromey.com> tui_first_data_item_displayed is only called from tui_data_window methods, so turn it into a method as well. 2019-06-23 Tom Tromey * tui/tui-windata.h (tui_first_data_item_displayed): Don't declare. * tui/tui-windata.c (tui_data_window::first_data_item_displayed): Rename from tui_first_data_item_displayed. Update. (tui_data_window::refresh_all) (tui_data_window::do_scroll_vertical): Update. * tui/tui-data.h (struct tui_data_window) : Declare new method. --- gdb/ChangeLog | 11 +++++++++++ gdb/tui/tui-data.h | 4 ++++ gdb/tui/tui-windata.c | 23 ++++++++--------------- gdb/tui/tui-windata.h | 1 - 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 2306abe1292..3416c413dc2 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -505,6 +505,10 @@ protected: { } void do_make_visible_with_new_height () override; + + /* Return the index of the first element displayed. If none are + displayed, then return -1. */ + int first_data_item_displayed (); }; struct tui_cmd_window : public tui_win_info diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c index c5593454580..82436a31d92 100644 --- a/gdb/tui/tui-windata.c +++ b/gdb/tui/tui-windata.c @@ -42,25 +42,18 @@ /* Answer the index first element displayed. If none are displayed, then return (-1). */ int -tui_first_data_item_displayed (void) +tui_data_window::first_data_item_displayed () { - int element_no = (-1); - int i; - - for (i = 0; - i < TUI_DATA_WIN->content_size && element_no < 0; - i++) + for (int i = 0; i < content_size; i++) { struct tui_gen_win_info *data_item_win; - data_item_win - = TUI_DATA_WIN->content[i]->which_element.data_window; - if (data_item_win->handle != NULL - && data_item_win->is_visible) - element_no = i; + data_item_win = content[i]->which_element.data_window; + if (data_item_win->handle != NULL && data_item_win->is_visible) + return i; } - return element_no; + return -1; } @@ -198,7 +191,7 @@ tui_data_window::refresh_all () tui_erase_data_content (NULL); if (content_size > 0) { - int first_element = tui_first_data_item_displayed (); + int first_element = first_data_item_displayed (); if (first_element >= 0) /* Re-use existing windows. */ tui_display_data_from (first_element, TRUE); @@ -248,7 +241,7 @@ tui_data_window::do_scroll_vertical (int num_to_scroll) int first_element_no; int first_line = (-1); - first_element_no = tui_first_data_item_displayed (); + first_element_no = first_data_item_displayed (); if (first_element_no < regs_content_count) first_line = tui_line_from_reg_element_no (first_element_no); else diff --git a/gdb/tui/tui-windata.h b/gdb/tui/tui-windata.h index c070f76c392..4aa8cb0b38c 100644 --- a/gdb/tui/tui-windata.h +++ b/gdb/tui/tui-windata.h @@ -28,7 +28,6 @@ extern void tui_erase_data_content (const char *); extern void tui_display_all_data (void); extern void tui_check_data_values (struct frame_info *); extern void tui_display_data_from_line (int); -extern int tui_first_data_item_displayed (void); extern void tui_delete_data_content_windows (void); extern void tui_refresh_data_win (void); extern void tui_display_data_from (int, int);