From patchwork Sat Jan 4 18:33:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37181 Received: (qmail 635 invoked by alias); 4 Jan 2020 18:34:24 -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 130959 invoked by uid 89); 4 Jan 2020 18:34:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 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= X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.47.228) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 04 Jan 2020 18:34:16 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway22.websitewelcome.com (Postfix) with ESMTP id A7AFB4F50E for ; Sat, 4 Jan 2020 12:34:15 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id noFbiWgDYW4frnoFbinK1T; Sat, 04 Jan 2020 12:34:15 -0600 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=KPlxEnJk3JZ9y8lF/KthID886+Yyo2k8ZBl66q4Rs+8=; b=n/9xUlEq3czplTJkQwdOuhcDqO k1navfrC4ykmGBr3fbBlcqvA35j9TySQF9cSlcr3nuBQGpBG8fvlW7bAZgJXXfmPGnGS/wZ6oonKb T7BQoe8JVor0KM/h32ugqXaGh; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:48942 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1inoFb-0026Lh-H3; Sat, 04 Jan 2020 11:34:15 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 13/24] Reimplement tui_next_win and tui_prev_win Date: Sat, 4 Jan 2020 11:33:59 -0700 Message-Id: <20200104183410.17114-14-tom@tromey.com> In-Reply-To: <20200104183410.17114-1-tom@tromey.com> References: <20200104183410.17114-1-tom@tromey.com> This reimplements tui_next_win and tui_prev_win. Now they account for the possibility of windows not on tui_win_list. 2020-01-04 Tom Tromey * tui/tui-data.c (tui_next_win, tui_prev_win): Reimplement. Change-Id: Ifcd402f76fe0a16e0fe9275a185d550279c01660 --- gdb/ChangeLog | 4 ++++ gdb/tui/tui-data.c | 55 +++++++++++----------------------------------- 2 files changed, 17 insertions(+), 42 deletions(-) diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 06bd42ee536..5d42fafccca 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -26,6 +26,7 @@ #include "tui/tui-wingeneral.h" #include "tui/tui-winsource.h" #include "gdb_curses.h" +#include struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS]; @@ -103,28 +104,13 @@ tui_set_term_width_to (int w) struct tui_win_info * tui_next_win (struct tui_win_info *cur_win) { - int type = cur_win->type; - struct tui_win_info *next_win = NULL; - - if (cur_win->type == CMD_WIN) - type = SRC_WIN; - else - type = cur_win->type + 1; - while (type != cur_win->type && (next_win == NULL)) - { - if (tui_win_list[type] - && tui_win_list[type]->is_visible ()) - next_win = tui_win_list[type]; - else - { - if (type == CMD_WIN) - type = SRC_WIN; - else - type++; - } - } + auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win); + gdb_assert (iter != tui_windows.end ()); - return next_win; + ++iter; + if (iter == tui_windows.end ()) + return tui_windows[0]; + return *iter; } @@ -133,28 +119,13 @@ tui_next_win (struct tui_win_info *cur_win) struct tui_win_info * tui_prev_win (struct tui_win_info *cur_win) { - int type = cur_win->type; - struct tui_win_info *prev = NULL; - - if (cur_win->type == SRC_WIN) - type = CMD_WIN; - else - type = cur_win->type - 1; - while (type != cur_win->type && (prev == NULL)) - { - if (tui_win_list[type] - && tui_win_list[type]->is_visible ()) - prev = tui_win_list[type]; - else - { - if (type == SRC_WIN) - type = CMD_WIN; - else - type--; - } - } + auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win); + gdb_assert (iter != tui_windows.end ()); - return prev; + if (iter == tui_windows.begin ()) + return tui_windows.back (); + --iter; + return *iter; }