From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106838 invoked by alias); 4 Jul 2019 17:03:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 105611 invoked by uid 89); 4 Jul 2019 17:03:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.5 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=WINDOW, H*RU:esmtpa, H*r:esmtpa X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (192.185.192.36) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jul 2019 17:03:23 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway36.websitewelcome.com (Postfix) with ESMTP id C2345400C5D9E for ; Thu, 4 Jul 2019 11:25:58 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id j58khuwTZ2PzOj58kh7dKn; Thu, 04 Jul 2019 12:03:22 -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=BWg5+jxe3ga/Zzq08EprofT+4aNylfzgfCj8fTg9n5g=; b=bMXQ/PLwb/tXfAySg7y/0EB18x ENUpu114JL8mM5drLtthhGOivNfbOavyagvdM4Ysx3VLWJUGpF/lG9NCvk/6LYN1JJNwWWKnidkH/ vMhF2Nvf1Qp9AquQnl3FFhMqf; Received: from 174-29-58-150.hlrn.qwest.net ([174.29.58.150]:34694 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1hj58k-002sFu-8D; Thu, 04 Jul 2019 12:03:22 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 22/61] Make source windows be self-updating Date: Thu, 04 Jul 2019 17:03:00 -0000 Message-Id: <20190704170311.15982-23-tom@tromey.com> In-Reply-To: <20190704170311.15982-1-tom@tromey.com> References: <20190704170311.15982-1-tom@tromey.com> X-SW-Source: 2019-07/txt/msg00126.txt.bz2 This changes the TUI source window to register itself on the source_styling_changed observable, and removes a bit of code from tui-hooks.c. This reduces the number of uses of the TUI_SRC_WIN global. 2019-07-04 Tom Tromey * tui/tui-source.c (tui_source_window): New constructor. Add observer. (~tui_source_window): New destructor. (tui_source_window::style_changed): New method. * tui/tui-hooks.c (tui_redisplay_source): Remove. (tui_attach_detach_observers): Update. * tui/tui-data.h (struct tui_source_window): Make constructor not inline. Add destructor. (struct tui_source_window) : New method. : New member. --- gdb/ChangeLog | 13 +++++++++++++ gdb/tui/tui-data.h | 14 ++++++++++---- gdb/tui/tui-hooks.c | 14 -------------- gdb/tui/tui-source.c | 20 ++++++++++++++++++++ 4 files changed, 43 insertions(+), 18 deletions(-) diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 76f6bc6102c..c456bd7db84 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -24,6 +24,7 @@ #include "tui/tui.h" /* For enum tui_win_type. */ #include "gdb_curses.h" /* For WINDOW. */ +#include "observable.h" /* This is a point definition. */ struct tui_point @@ -424,10 +425,8 @@ public: struct tui_source_window : public tui_source_window_base { - tui_source_window () - : tui_source_window_base (SRC_WIN) - { - } + tui_source_window (); + ~tui_source_window (); DISABLE_COPY_AND_ASSIGN (tui_source_window); @@ -439,6 +438,13 @@ struct tui_source_window : public tui_source_window_base protected: void do_scroll_vertical (int num_to_scroll) override; + +private: + + void style_changed (); + + /* A token used to register and unregister an observer. */ + gdb::observers::token m_observable; }; /* A TUI disassembly window. */ diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index 71010530749..84acd3ac2e6 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -204,18 +204,6 @@ tui_normal_stop (struct bpstats *bs, int print_frame) tui_refresh_frame_and_register_information (/*registers_too_p=*/1); } -/* Observer for source_cache_cleared. */ - -static void -tui_redisplay_source () -{ - if (tui_is_window_visible (SRC_WIN)) - { - /* Force redisplay. */ - TUI_SRC_WIN->refill (); - } -} - /* Token associated with observers registered while TUI hooks are installed. */ static const gdb::observers::token tui_observers_token {}; @@ -251,8 +239,6 @@ tui_attach_detach_observers (bool attach) tui_normal_stop, attach); attach_or_detach (gdb::observers::register_changed, tui_register_changed, attach); - attach_or_detach (gdb::observers::source_styling_changed, - tui_redisplay_source, attach); } /* Install the TUI specific hooks. */ diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index e62ee4ea5f9..34cb38b31af 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -325,3 +325,23 @@ tui_source_window::do_scroll_vertical (int num_to_scroll) print_source_lines (s, l.u.line_no, l.u.line_no + 1, 0); } } + +tui_source_window::tui_source_window () + : tui_source_window_base (SRC_WIN) +{ + gdb::observers::source_styling_changed.attach + (std::bind (&tui_source_window::style_changed, this), + m_observable); +} + +tui_source_window::~tui_source_window () +{ + gdb::observers::source_styling_changed.detach (m_observable); +} + +void +tui_source_window::style_changed () +{ + if (tui_active && is_visible) + refill (); +} -- 2.17.2