From patchwork Fri Jan 10 00:09:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 37281 Received: (qmail 35397 invoked by alias); 10 Jan 2020 00:09:35 -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 35385 invoked by uid 89); 10 Jan 2020 00:09:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=borders X-HELO: mail-wm1-f65.google.com Received: from mail-wm1-f65.google.com (HELO mail-wm1-f65.google.com) (209.85.128.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Jan 2020 00:09:33 +0000 Received: by mail-wm1-f65.google.com with SMTP id p17so136105wma.1 for ; Thu, 09 Jan 2020 16:09:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id; bh=ihH2BkstzC7gWjJD8WtLyEKLs/Q5NDCaYcGHvIE5n+A=; b=cvr27+bTmcx8qCmwrLSuIk3YqDzl3o2Sc30se0XNbMfIaa4YtaGWOY+xdZVGMciSY4 lAs1MM2yO2eyXAMC3T+rnJJHkhImmuDhA5PGuUxHHacFevAxCWTZqg2E0umtzXs780Sj TESDhBp29U9wHJr2GGDubycrawtrXGTgkAt+epRvK0pQ/UWAsIrCI5ju/F3/r5RSPsAY aHeqG84azmladkpK7Fukq/kSYkJ8UYvw4B4b83sVDZpdEW3C4Y6IUGQJgnMDAU7yMF2A tfGoUuYzfXpzO0N/L2+Qss1EgBNx4vPXEQ9lHuzVzA4LqCu93XZqJLTXhR11iPrb9YWn M3Cg== Return-Path: Received: from localhost (host86-186-80-236.range86-186.btcentralplus.com. [86.186.80.236]) by smtp.gmail.com with ESMTPSA id q11sm214798wrp.24.2020.01.09.16.09.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Jan 2020 16:09:30 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Tom Tromey , Andrew Burgess Subject: [PATCH] gdb/tui: Place window titles in the center of the border Date: Fri, 10 Jan 2020 00:09:26 +0000 Message-Id: <20200110000926.21645-1-andrew.burgess@embecosm.com> X-IsSubscribed: yes In tui-wingeneral.c:box_win () a comment suggest we should display titles like this: +-WINDOW TITLE GOES HERE-+ However, we actually display them like this: +--WINDOW TITLE GOES HERE+ The former seems nicer to me, so that's what this commit does. Short titles will appear as: +-SHORT TITLE------------+ We previously didn't test the horizontal windows borders in the test suite, however, I've updated things so that we do now check for the '+-' and '-+' on the upper border, this will give us some protection. gdb/ChangeLog: * tui/tui-wingeneral.c (box_win): Position the title in the center of the border. gdb/testsuite/ChangeLog: * lib/tuiterm.exp (Term::_check_box): Check some parts of the top border. Change-Id: Iead6910e3b4e68bdf6871f861f23d2efd699faf0 --- gdb/ChangeLog | 5 +++++ gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/lib/tuiterm.exp | 17 ++++++++++++++--- gdb/tui/tui-wingeneral.c | 4 ++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 7adaf1b71ab..da5580324a9 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -569,9 +569,20 @@ namespace eval Term { return "lr corner" } - # Note we do not check the horizonal borders of the box. The - # top will contain a title, and the bottom may as well, if it - # is overlapped by some other border. + # Note we do not check the full horizonal borders of the box. + # The top will contain a title, and the bottom may as well, if + # it is overlapped by some other border. However, at most a + # title should appear as '+-VERY LONG TITLE-+', so we can + # check for the '+-' on the left, and '-+' on the right. + if {[get_char [expr {$x + 1}] $y] != "-"} { + return "ul title padding" + } + + if {[get_char [expr {$x2 - 1}] $y] != "-"} { + return "ul title padding" + } + + # Now check the vertical borders. for {set i [expr {$y + 1}]} {$i < $y2 - 1} {incr i} { if {[get_char $x $i] != "|"} { return "left side $i" diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c index dae4255ada2..bf43485b0a7 100644 --- a/gdb/tui/tui-wingeneral.c +++ b/gdb/tui/tui-wingeneral.c @@ -74,13 +74,13 @@ box_win (struct tui_win_info *win_info, int max_len = win_info->width - 2 - 2; if (win_info->title.size () <= max_len) - mvwaddstr (win, 0, 3, win_info->title.c_str ()); + mvwaddstr (win, 0, 2, win_info->title.c_str ()); else { std::string truncated = "..." + win_info->title.substr (win_info->title.size () - max_len + 3); - mvwaddstr (win, 0, 3, truncated.c_str ()); + mvwaddstr (win, 0, 2, truncated.c_str ()); } } wattroff (win, attrs);