From patchwork Sun Jun 23 22:42:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33312 Received: (qmail 56420 invoked by alias); 23 Jun 2019 23:25:50 -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 56401 invoked by uid 89); 23 Jun 2019 23:25:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.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=Answer 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; Sun, 23 Jun 2019 23:25:48 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 1C84C2D314 for ; Sun, 23 Jun 2019 18:25:47 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id fBrnhwzNwdnCefBrnhX8KT; Sun, 23 Jun 2019 18:25:47 -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=I9tg9M4Ei65EOCp0quvIM0B4IMk/spORQFoHJpijXr0=; b=emf/M4nE3uIYhhrHDsxzP5k5RG l6/b6/Ooviwd4x2SsdmTGsnFjvGwDog6dK57grqKnZ7j5I/XuL7m6VFjC9vz5hAxwEUMMSYixont0 xdTpQpX35Hd7IT58AyYKOhMK1; Received: from 75-166-12-78.hlrn.qwest.net ([75.166.12.78]:54396 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hfBD9-000vDQ-N0; Sun, 23 Jun 2019 17:43:47 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 35/66] Introduce tui_gen_win_info::name method Date: Sun, 23 Jun 2019 16:42:58 -0600 Message-Id: <20190623224329.16060-36-tom@tromey.com> In-Reply-To: <20190623224329.16060-1-tom@tromey.com> References: <20190623224329.16060-1-tom@tromey.com> This removes tui_win_name and replaces it with a method on tui_gen_win_info, removing another spot that switched on window type. 2019-06-23 Tom Tromey * tui/tui-win.c (window_name_completer, tui_set_focus) (tui_all_windows_info): Use name method. * tui/tui-data.h (struct tui_gen_win_info) (struct tui_source_window, struct tui_disasm_window) (struct tui_data_window, struct tui_cmd_window) : New method. (tui_win_name): Don't declare. * tui/tui-data.c (tui_partial_win_by_name): Use name method. (tui_win_name): Remove. --- gdb/ChangeLog | 12 ++++++++++++ gdb/tui/tui-data.c | 31 +------------------------------ gdb/tui/tui-data.h | 27 ++++++++++++++++++++++++++- gdb/tui/tui-win.c | 8 ++++---- 4 files changed, 43 insertions(+), 35 deletions(-) diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 63afec57141..5bb79156e70 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -337,7 +337,7 @@ tui_partial_win_by_name (const char *name) { if (tui_win_list[i] != 0) { - const char *cur_name = tui_win_name (tui_win_list[i]); + const char *cur_name = tui_win_list[i]->name (); if (strlen (name) <= strlen (cur_name) && startswith (cur_name, name)) @@ -351,35 +351,6 @@ tui_partial_win_by_name (const char *name) } -/* Answer the name of the window. */ -const char * -tui_win_name (const struct tui_gen_win_info *win_info) -{ - const char *name = NULL; - - switch (win_info->type) - { - case SRC_WIN: - name = SRC_NAME; - break; - case CMD_WIN: - name = CMD_NAME; - break; - case DISASSEM_WIN: - name = DISASSEM_NAME; - break; - case DATA_WIN: - name = DATA_NAME; - break; - default: - name = ""; - break; - } - - return name; -} - - void tui_initialize_static_data (void) { diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 78c17102218..01c0f167cde 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -51,6 +51,12 @@ struct tui_gen_win_info /* Call to refresh this window. */ virtual void refresh_window (); + /* Return the name of this type of window. */ + virtual const char *name () const + { + return ""; + } + /* Window handle. */ WINDOW *handle = nullptr; /* Type of window. */ @@ -383,6 +389,11 @@ struct tui_source_window : public tui_source_window_base DISABLE_COPY_AND_ASSIGN (tui_source_window); + const char *name () const override + { + return SRC_NAME; + } + protected: void do_scroll_vertical (enum tui_scroll_direction, @@ -400,6 +411,11 @@ struct tui_disasm_window : public tui_source_window_base DISABLE_COPY_AND_ASSIGN (tui_disasm_window); + const char *name () const override + { + return DISASSEM_NAME; + } + protected: void do_scroll_vertical (enum tui_scroll_direction, @@ -423,6 +439,11 @@ struct tui_data_window : public tui_win_info void refresh_window () override; + const char *name () const override + { + return DATA_NAME; + } + /* Start of data display content. */ tui_win_content data_content = NULL; int data_content_count = 0; @@ -465,6 +486,11 @@ struct tui_cmd_window : public tui_win_info { } + const char *name () const override + { + return CMD_NAME; + } + int start_line = 0; protected: @@ -502,7 +528,6 @@ extern void tui_free_win_content (struct tui_gen_win_info *); extern void tui_free_data_content (tui_win_content, int); extern void tui_free_all_source_wins_content (void); extern struct tui_win_info *tui_partial_win_by_name (const char *); -extern const char *tui_win_name (const struct tui_gen_win_info *); extern enum tui_layout_type tui_current_layout (void); extern void tui_set_current_layout_to (enum tui_layout_type); extern int tui_term_height (void); diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index c8fd267f362..33dcb3b2f6c 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -376,7 +376,7 @@ window_name_completer (completion_tracker &tracker, || !tui_win_list[win_type]->is_visible) continue; - completion_name = tui_win_name (tui_win_list [win_type]); + completion_name = tui_win_list[win_type]->name (); gdb_assert (completion_name != NULL); completion_name_vec.push_back (completion_name); } @@ -869,7 +869,7 @@ The window name specified must be valid and visible.\n")); TUI_DATA_WIN->refresh_all (); xfree (buf_ptr); printf_filtered (_("Focus set to %s window.\n"), - tui_win_name (tui_win_with_focus ())); + tui_win_with_focus ()->name ()); } else warning (_("Incorrect Number of Arguments.\n%s"), FOCUS_USAGE); @@ -896,11 +896,11 @@ tui_all_windows_info (const char *arg, int from_tty) { if (win_with_focus == tui_win_list[type]) printf_filtered (" %s\t(%d lines) \n", - tui_win_name (tui_win_list[type]), + tui_win_list[type]->name (), tui_win_list[type]->height); else printf_filtered (" %s\t(%d lines)\n", - tui_win_name (tui_win_list[type]), + tui_win_list[type]->name (), tui_win_list[type]->height); } }