From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 176563858D20 for ; Sun, 12 Nov 2023 15:04:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 176563858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 176563858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2178:6::1c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699801476; cv=none; b=l4ip114hkHJCQ4dpOO/3fiopMRWdUB4Bxuu+BJLZpVP62Fpys2UPggZxf30a1a7DdpMQFDOFjYfv+IPbwIHaKHRcsqxe/Ah8z+iSMKEIbqiW2DEGS8flm2QHCs3GULLDHgt1DMdhodbl1udIxkTkCwwgas6NGNF+LTEbFTYJDaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699801476; c=relaxed/simple; bh=jfzO51jF35H0DiQESp0pUfcgzO1MG7PS/wI57u575pY=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=srpSzAOyawShrZiDN9Uleyq7TsgYE1vH1LOfyT2GVx/zDLzLgKu8gdXlEH8g0R1SpLk+yh8DVZdyF+CDFHdlReo1jDnGHXvvhDwc+zK3s2yAty6ecgHedo01aL/TfSZy0xJAQRRNveGQKOr9bTBcZs/jL61ockqQZChbKXm5Des= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BB3EE218E5 for ; Sun, 12 Nov 2023 15:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1699801473; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=57yQX0mZxnnZK3dOLqRMFLd/rvK1V0a94tl2ee8YVRQ=; b=Q/W0eSDbvB8VCd1NHGBEz/Ego7NAtHpxyPOASXMOqxsSgka5hmKBjtvi3YjhGxtYxQY5aO +2GCagEMTeZ5IIDj2tQuYSWTdRYQTg27uV8543UkFFqJr8so7OZKpbVw143Yp0WeWB6OCz JzO35PP9tlLj3XAvo2PXPEPZo5nRwgs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1699801473; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=57yQX0mZxnnZK3dOLqRMFLd/rvK1V0a94tl2ee8YVRQ=; b=e05FvSnvTX5rC1IyYW1cTFy8opFjmr8wotZlHnINW6WSpBJyy559K4db9LYY85TepEvVA3 EH5X8SSXqeLwdfDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A738313915 for ; Sun, 12 Nov 2023 15:04:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id P6XCJ4HpUGXsdAAAMHmgww (envelope-from ) for ; Sun, 12 Nov 2023 15:04:33 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/tui] Factor out tui_noscroll_window et al Date: Sun, 12 Nov 2023 16:06:01 +0100 Message-Id: <20231112150601.25484-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,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: I noticed that tui_locator_window has an empty do_scroll_vertical and do_scroll_horizontal, like tui_cmd_window, but unlike tui_cmd_window doesn't have: ... bool can_scroll () const override { return false; } ... I suspect that it probably doesn't matter, but regardless it's good to have the same implementations of basic properties in all windows. Ensure this by adding a class tui_noscroll_window, that has: - an empty do_scroll_vertical and do_scroll_horizontal, and - a can_scroll returning false which both tui_locator_window and tui_cmd_window inherit. Make all methods final to ensure no accidental overrides are left in the inheriting classes. Likewise add new classes representing basic window properties: - tui_nofocus_window, - tui_oneline_window, - tui_nobox_window, - tui_norefresh_window, and - tui_always_visible_window. The changes are only a refactoring, apart from adding the "final", which does limit the range of behaviours for subclasses. Tested on x86_64-linux. --- gdb/tui/tui-command.h | 33 ++--------------- gdb/tui/tui-data.h | 85 ++++++++++++++++++++++++++++++++++++++++--- gdb/tui/tui-stack.h | 34 ++--------------- 3 files changed, 86 insertions(+), 66 deletions(-) diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h index f6842880bb2..d743dd87a1b 100644 --- a/gdb/tui/tui-command.h +++ b/gdb/tui/tui-command.h @@ -25,49 +25,22 @@ #include "tui/tui-data.h" /* The TUI command window. */ -struct tui_cmd_window : public tui_win_info +struct tui_cmd_window + : public tui_noscroll_window, tui_nobox_window, tui_norefresh_window, + tui_always_visible_window { tui_cmd_window () = default; DISABLE_COPY_AND_ASSIGN (tui_cmd_window); - void refresh_window () override - { - } - const char *name () const override { return CMD_NAME; } - bool can_scroll () const override - { - return false; - } - - bool can_box () const override - { - return false; - } - void resize (int height, int width, int origin_x, int origin_y) override; - void make_visible (bool visible) override - { - /* The command window can't be made invisible. */ - } - int start_line = 0; - -protected: - - void do_scroll_vertical (int num_to_scroll) override - { - } - - void do_scroll_horizontal (int num_to_scroll) override - { - } }; /* Refresh the command window. */ diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index a1e44f77cc1..37d566c0186 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -182,6 +182,76 @@ struct tui_win_info std::string m_title; }; +/* A TUI window that doesn't scroll. */ + +struct tui_noscroll_window : public virtual tui_win_info { +public: + virtual bool can_scroll () const final override + { + return false; + } + +protected: + virtual void do_scroll_vertical (int num_to_scroll) final override + { + } + + /* Scroll the contents horizontally. This is only called via + left_scroll and right_scroll. */ + virtual void do_scroll_horizontal (int num_to_scroll) final override + { + } +}; + +/* A TUI window that cannot have focus. */ + +struct tui_nofocus_window : public virtual tui_win_info { +public: + virtual bool can_focus () const final override + { + return false; + } +}; + +/* A TUI window that occupies a single line. */ + +struct tui_oneline_window : public virtual tui_win_info { + int max_height () const final override + { + return 1; + } + + int min_height () const final override + { + return 1; + } +}; + +/* A TUI window that has no border. */ + +struct tui_nobox_window : public virtual tui_win_info { + bool can_box () const final override + { + return false; + } +}; + +/* A TUI window that is not refreshed. */ + +struct tui_norefresh_window : public virtual tui_win_info { + virtual void refresh_window () final override + { + } +}; + +/* A TUI window that is always visible. */ + +struct tui_always_visible_window : public virtual tui_win_info { + virtual void make_visible (bool visible) final override + { + } +}; + /* Constant definitions. */ #define SRC_NAME "src" #define CMD_NAME "cmd" @@ -192,11 +262,16 @@ struct tui_win_info /* Global Data. */ extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS]; -#define TUI_SRC_WIN ((tui_source_window *) tui_win_list[SRC_WIN]) -#define TUI_DISASM_WIN ((tui_disasm_window *) tui_win_list[DISASSEM_WIN]) -#define TUI_DATA_WIN ((tui_data_window *) tui_win_list[DATA_WIN]) -#define TUI_CMD_WIN ((tui_cmd_window *) tui_win_list[CMD_WIN]) -#define TUI_STATUS_WIN ((tui_locator_window *) tui_win_list[STATUS_WIN]) +#define TUI_SRC_WIN \ + (dynamic_cast (tui_win_list[SRC_WIN])) +#define TUI_DISASM_WIN \ + (dynamic_cast (tui_win_list[DISASSEM_WIN])) +#define TUI_DATA_WIN \ + (dynamic_cast (tui_win_list[DATA_WIN])) +#define TUI_CMD_WIN \ + (dynamic_cast (tui_win_list[CMD_WIN])) +#define TUI_STATUS_WIN \ + (dynamic_cast (tui_win_list[STATUS_WIN])) /* All the windows that are currently instantiated, in layout order. */ diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h index d542f215771..ca95b2bf78a 100644 --- a/gdb/tui/tui-stack.h +++ b/gdb/tui/tui-stack.h @@ -28,7 +28,9 @@ class frame_info_ptr; /* Locator window class. */ -struct tui_locator_window : public tui_win_info +struct tui_locator_window + : public tui_nofocus_window, tui_noscroll_window, tui_oneline_window, + tui_nobox_window { tui_locator_window () = default; @@ -37,38 +39,8 @@ struct tui_locator_window : public tui_win_info return STATUS_NAME; } - int max_height () const override - { - return 1; - } - - int min_height () const override - { - return 1; - } - - bool can_box () const override - { - return false; - } - - bool can_focus () const override - { - return false; - } - void rerender () override; -protected: - - void do_scroll_vertical (int n) override - { - } - - void do_scroll_horizontal (int n) override - { - } - private: /* Create the status line to display as much information as we can base-commit: 328e01595436e937a0cc00cc8451f17beda26799 -- 2.35.3