From patchwork Wed Mar 13 19:28:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 31844 Received: (qmail 18976 invoked by alias); 13 Mar 2019 19:28:34 -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 18965 invoked by uid 89); 13 Mar 2019 19:28:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=window's, highlighting X-HELO: mail-wm1-f66.google.com Received: from mail-wm1-f66.google.com (HELO mail-wm1-f66.google.com) (209.85.128.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Mar 2019 19:28:33 +0000 Received: by mail-wm1-f66.google.com with SMTP id o10so5177657wmc.1 for ; Wed, 13 Mar 2019 12:28:32 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:56ee:75ff:fe8d:232b? ([2001:8a0:f913:f700:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id p12sm7335389wrx.50.2019.03.13.12.28.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 12:28:30 -0700 (PDT) Subject: Re: [RFC 8.3 1/3] Make TUI react to "set style enabled" To: Tom Tromey , gdb-patches@sourceware.org References: <20190308210433.32683-1-tromey@adacore.com> <20190308210433.32683-2-tromey@adacore.com> From: Pedro Alves Message-ID: Date: Wed, 13 Mar 2019 19:28:29 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190308210433.32683-2-tromey@adacore.com> On 03/08/2019 09:04 PM, Tom Tromey wrote: > When the user toggles "set style enabled", the TUI should react by > redrawing the source window, if necessary. This patch implements this > behavior. > > No test because the TUI is generally not tested. > > I was not sure of a clean way to force an update of the window's > contents; see the new tui_redisplay_source for the workaround I used. I went looking, and thought that it could be: tui_show_source_content (tui_win_list[SRC_WIN]); That's what tui_refresh_all_win, coming from Ctrl-L, does. But that won't work I think because we'd just refresh the current source code cache, which includes the previous/now-stale highlighting mode. Maybe something like this? From 5b7c86c6666ddc16b206fe04a492e99a33570a7f Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 13 Mar 2019 18:14:14 +0000 Subject: [PATCH] refactor --- gdb/tui/tui-hooks.c | 2 +- gdb/tui/tui-winsource.c | 44 +++++++++++++++++++++++++------------------- gdb/tui/tui-winsource.h | 1 + 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index 162d6ef525..4a1d79e0ad 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -212,7 +212,7 @@ tui_redisplay_source () if (tui_is_window_visible (SRC_WIN)) { /* Force redisplay. */ - tui_horizontal_source_scroll (tui_win_list[SRC_WIN], LEFT_SCROLL, 0); + tui_refill_source_window (tui_win_list[SRC_WIN]); } } diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 9336f7b1f7..ab7756c1c4 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -306,8 +306,32 @@ tui_show_source_content (struct tui_win_info *win_info) win_info->generic.content_in_use = TRUE; } +/* Refill the source window's source cache and update it. If WIN_INFO + is a disassembly window, then just update it. */ + +void +tui_refill_source_window (struct tui_win_info *win_info) +{ + symtab *s = nullptr; + + if (win_info->generic.type == SRC_WIN) + { + symtab_and_line cursal = get_current_source_symtab_and_line (); + s = (cursal.symtab == NULL + ? find_pc_line_symtab (get_frame_pc (get_selected_frame (NULL))) + : cursal.symtab); + } + + tui_update_source_window_as_is (win_info, + win_info->detail.source_info.gdbarch, + s, + win_info->generic.content[0] + ->which_element.source.line_or_addr, + FALSE); +} /* Scroll the source forward or backward horizontally. */ + void tui_horizontal_source_scroll (struct tui_win_info *win_info, enum tui_scroll_direction direction, @@ -315,20 +339,7 @@ tui_horizontal_source_scroll (struct tui_win_info *win_info, { if (win_info->generic.content != NULL) { - struct gdbarch *gdbarch = win_info->detail.source_info.gdbarch; int offset; - struct symtab *s = NULL; - - if (win_info->generic.type == SRC_WIN) - { - struct symtab_and_line cursal - = get_current_source_symtab_and_line (); - - if (cursal.symtab == NULL) - s = find_pc_line_symtab (get_frame_pc (get_selected_frame (NULL))); - else - s = cursal.symtab; - } if (direction == LEFT_SCROLL) offset = win_info->detail.source_info.horizontal_offset @@ -341,13 +352,8 @@ tui_horizontal_source_scroll (struct tui_win_info *win_info, offset = 0; } win_info->detail.source_info.horizontal_offset = offset; - tui_update_source_window_as_is (win_info, gdbarch, s, - win_info->generic.content[0] - ->which_element.source.line_or_addr, - FALSE); + tui_refill_source_window (win_info); } - - return; } diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index db33a4f73e..920032b04e 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -56,6 +56,7 @@ extern void tui_show_source_content (struct tui_win_info *); extern void tui_horizontal_source_scroll (struct tui_win_info *, enum tui_scroll_direction, int); +extern void tui_refill_source_window (struct tui_win_info *); extern enum tui_status tui_set_exec_info_content (struct tui_win_info *); extern void tui_show_exec_info_content (struct tui_win_info *); extern void tui_erase_exec_info_content (struct tui_win_info *);