From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway31.websitewelcome.com (gateway31.websitewelcome.com [192.185.143.33]) by sourceware.org (Postfix) with ESMTPS id D1FBA3893664 for ; Thu, 18 Jun 2020 02:15:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D1FBA3893664 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 7F808176F1 for ; Wed, 17 Jun 2020 21:15:28 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id lk5QjPbl9QyTQlk5Qjdow2; Wed, 17 Jun 2020 21:15:28 -0500 X-Authority-Reason: nr=8 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=U8rUGEeD4+SpCDitTJWRG6zuCImMfaT5RUkVg3/Q0FU=; b=V2YZb53MbI/vICRj2Sk9xhrpu1 rk+uOYJfNZIOi6rA63MTEubFbaJVtEolcRboSyYlQQLgx/LZigWPu+ZLyZeMPqnz268UXH5cOnpRL PkdajQuQ+EsXu2PG9NMMhMQso; Received: from 174-16-104-48.hlrn.qwest.net ([174.16.104.48]:54316 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1jlk5Q-003VvK-9I; Wed, 17 Jun 2020 20:15:28 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 07/11] Don't derive tui_data_item_window from tui_gen_win_info Date: Wed, 17 Jun 2020 20:15:19 -0600 Message-Id: <20200618021523.10681-8-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200618021523.10681-1-tom@tromey.com> References: <20200618021523.10681-1-tom@tromey.com> 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: 174.16.104.48 X-Source-L: No X-Exim-ID: 1jlk5Q-003VvK-9I X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-104-48.hlrn.qwest.net (bapiya.Home) [174.16.104.48]:54316 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3038.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Thu, 18 Jun 2020 02:15:30 -0000 There's no deep reason that tui_data_item_window should derive from tui_gen_win_info -- it currently uses a curses window to render, but that isn't truly needed, and it adds some hacks to other parts of the TUI. This patch changes tui_data_item_window so that it doesn't have a base class, and updates the register window. This simplifies the code and enables a subsequent cleanup. 2020-06-15 Tom Tromey * tui/tui-regs.c (tui_data_window::display_registers_from) (tui_data_window::display_registers_from) (tui_data_window::first_data_item_displayed) (tui_data_window::delete_data_content_windows): Update. (tui_data_window::refresh_window, tui_data_window::no_refresh): Remove. (tui_data_window::check_register_values): Update. (tui_data_item_window::rerender): Add parameters. Update. (tui_data_item_window::refresh_window): Remove. * tui/tui-data.h (struct tui_gen_win_info) : No longer virtual. * tui/tui-regs.h (struct tui_data_item_window): Don't derive from tui_gen_win_info. : Remove. : Add parameters. : New members. (struct tui_data_window) : Remove. : New member. --- gdb/ChangeLog | 21 ++++++++++++ gdb/tui/tui-data.h | 2 +- gdb/tui/tui-regs.c | 79 ++++++++++++---------------------------------- gdb/tui/tui-regs.h | 27 ++++++---------- 4 files changed, 51 insertions(+), 78 deletions(-) diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index d96384f6ce7..10dd0aedcff 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -102,7 +102,7 @@ struct tui_gen_win_info } /* Disable output until the next call to doupdate. */ - virtual void no_refresh () + void no_refresh () { if (handle != nullptr) wnoutrefresh (handle.get ()); diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index fcabe73a5ea..04d7469de5a 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -272,8 +272,6 @@ tui_data_window::show_register_group (struct reggroup *group, void tui_data_window::display_registers_from (int start_element_no) { - int j, item_win_width, cur_y; - int max_len = 0; for (auto &&data_item_win : m_regs_content) { @@ -282,26 +280,28 @@ tui_data_window::display_registers_from (int start_element_no) if (len > max_len) max_len = len; } - item_win_width = max_len + 1; + m_item_width = max_len + 1; int i = start_element_no; - m_regs_column_count = (width - 2) / item_win_width; + m_regs_column_count = (width - 2) / m_item_width; if (m_regs_column_count == 0) m_regs_column_count = 1; - item_win_width = (width - 2) / m_regs_column_count; + m_item_width = (width - 2) / m_regs_column_count; /* Now create each data "sub" window, and write the display into it. */ - cur_y = 1; + int cur_y = 1; while (i < m_regs_content.size () && cur_y <= height - 2) { - for (j = 0; + for (int j = 0; j < m_regs_column_count && i < m_regs_content.size (); j++) { /* Create the window if necessary. */ - m_regs_content[i].resize (1, item_win_width, - x + (item_win_width * j) + 1, y + cur_y); + m_regs_content[i].x = (m_item_width * j) + 1; + m_regs_content[i].y = cur_y; + m_regs_content[i].visible = true; + m_regs_content[i].rerender (handle.get (), m_item_width); i++; /* Next register. */ } cur_y++; /* Next row. */ @@ -372,10 +372,7 @@ tui_data_window::first_data_item_displayed () { for (int i = 0; i < m_regs_content.size (); i++) { - struct tui_gen_win_info *data_item_win; - - data_item_win = &m_regs_content[i]; - if (data_item_win->is_visible ()) + if (m_regs_content[i].visible) return i; } @@ -387,8 +384,8 @@ tui_data_window::first_data_item_displayed () void tui_data_window::delete_data_content_windows () { - for (auto &&win : m_regs_content) - win.handle.reset (nullptr); + for (auto &win : m_regs_content) + win.visible = false; } @@ -451,24 +448,6 @@ tui_data_window::do_scroll_vertical (int num_to_scroll) } } -/* See tui-regs.h. */ - -void -tui_data_window::refresh_window () -{ - tui_gen_win_info::refresh_window (); - for (auto &&win : m_regs_content) - win.refresh_window (); -} - -void -tui_data_window::no_refresh () -{ - tui_gen_win_info::no_refresh (); - for (auto &&win : m_regs_content) - win.no_refresh (); -} - /* This function check all displayed registers for changes in values, given a particular frame. If the values have changed, they are updated with the new value and highlighted. */ @@ -490,32 +469,28 @@ tui_data_window::check_register_values (struct frame_info *frame) &data_item_win.highlight); if (data_item_win.highlight || was_hilighted) - data_item_win.rerender (); + data_item_win.rerender (handle.get (), m_item_width); } } + + tui_wrefresh (handle.get ()); } /* Display a register in a window. If hilite is TRUE, then the value will be displayed in reverse video. */ void -tui_data_item_window::rerender () +tui_data_item_window::rerender (WINDOW *handle, int field_width) { - int i; - - scrollok (handle.get (), FALSE); if (highlight) /* We ignore the return value, casting it to void in order to avoid a compiler warning. The warning itself was introduced by a patch to ncurses 5.7 dated 2009-08-29, changing this macro to expand to code that causes the compiler to generate an unused-value warning. */ - (void) wstandout (handle.get ()); + (void) wstandout (handle); - wmove (handle.get (), 0, 0); - for (i = 1; i < width; i++) - waddch (handle.get (), ' '); - wmove (handle.get (), 0, 0); - waddstr (handle.get (), content.c_str ()); + mvwaddnstr (handle, y, x, content.c_str (), field_width - 1); + waddstr (handle, n_spaces (field_width - content.size ())); if (highlight) /* We ignore the return value, casting it to void in order to avoid @@ -523,21 +498,7 @@ tui_data_item_window::rerender () to ncurses 5.7 dated 2009-08-29, changing this macro to expand to code that causes the compiler to generate an unused-value warning. */ - (void) wstandend (handle.get ()); - refresh_window (); -} - -void -tui_data_item_window::refresh_window () -{ - if (handle != nullptr) - { - /* This seems to be needed because the data items are nested - windows, which according to the ncurses man pages aren't well - supported. */ - touchwin (handle.get ()); - tui_wrefresh (handle.get ()); - } + (void) wstandend (handle); } /* Helper for "tui reg next", wraps a call to REGGROUP_NEXT, but adds wrap diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index 8b5e941a0a0..29b54a53ef3 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -26,7 +26,7 @@ /* A data item window. */ -struct tui_data_item_window : public tui_gen_win_info +struct tui_data_item_window { tui_data_item_window () = default; @@ -34,23 +34,15 @@ struct tui_data_item_window : public tui_gen_win_info tui_data_item_window (tui_data_item_window &&) = default; - void rerender () override; - - void refresh_window () override; - - int max_height () const override - { - return 1; - } - - int min_height () const override - { - return 1; - } + void rerender (WINDOW *handle, int field_width); + /* Location. */ + int x = 0; + int y = 0; /* The register number. */ int regno = -1; bool highlight = false; + bool visible = false; std::string content; }; @@ -61,10 +53,6 @@ struct tui_data_window : public tui_win_info DISABLE_COPY_AND_ASSIGN (tui_data_window); - void refresh_window () override; - - void no_refresh () override; - const char *name () const override { return DATA_NAME; @@ -138,6 +126,9 @@ struct tui_data_window : public tui_win_info std::vector m_regs_content; int m_regs_column_count = 0; struct reggroup *m_current_group = nullptr; + + /* Width of each register's display area. */ + int m_item_width = 0; }; #endif /* TUI_TUI_REGS_H */ -- 2.17.2