From patchwork Fri Aug 30 21:28:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34364 Received: (qmail 4317 invoked by alias); 30 Aug 2019 21:28:40 -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 4308 invoked by uid 89); 30 Aug 2019 21:28:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.4 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: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.49.104) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Aug 2019 21:28:38 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 2594D2E76 for ; Fri, 30 Aug 2019 16:28:37 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 3oRhioFIB90on3oRhiZtJa; Fri, 30 Aug 2019 16:28:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=eAtODBrTEarouJsge/Rt4cWSDRjrHZ56vNiVY2+kazw=; b=qABarKWG+0cmsE4uOQRGi3aNmH LqY+erK1SD8GgumRBeq+NIIhsL+IsbQJBkvn9yRJ32egh5Atcu++fzSwtPUlixOe3XkfFisKoogHA 2cJEyrL2Ofg7aL9i2GKsnxYrO; Received: from 71-218-73-27.hlrn.qwest.net ([71.218.73.27]:34620 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1i3oRg-002UjA-SO; Fri, 30 Aug 2019 16:28:37 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Truncate long TUI window titles Date: Fri, 30 Aug 2019 15:28:34 -0600 Message-Id: <20190830212834.22131-1-tom@tromey.com> If a TUI window has a long title, it can overflow the title line. This changes the TUI to use just the tail part of the title in this case. gdb/ChangeLog 2019-08-30 Tom Tromey * tui/tui-wingeneral.c (box_win): Truncate long window titles. gdb/testsuite/ChangeLog 2019-08-30 Tom Tromey * gdb.tui/resize.exp: Remove setup_xfail. * gdb.tui/regs.exp: Remove setup_xfail. * gdb.tui/basic.exp: Remove setup_xfail. --- gdb/ChangeLog | 4 ++++ gdb/testsuite/ChangeLog | 6 ++++++ gdb/testsuite/gdb.tui/basic.exp | 6 ------ gdb/testsuite/gdb.tui/regs.exp | 3 --- gdb/testsuite/gdb.tui/resize.exp | 2 -- gdb/tui/tui-wingeneral.c | 16 +++++++++++++++- 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/gdb/testsuite/gdb.tui/basic.exp b/gdb/testsuite/gdb.tui/basic.exp index f60011c386a..716c52f68a6 100644 --- a/gdb/testsuite/gdb.tui/basic.exp +++ b/gdb/testsuite/gdb.tui/basic.exp @@ -35,9 +35,6 @@ gdb_assert {![string match "No Source Available" $text]} \ Term::command "list main" Term::check_contents "list main" "21 *return 0" -# This check fails because the file name in the title overwrites the -# box. -setup_xfail *-*-* Term::check_box "source box" 0 0 80 15 Term::command "layout asm" @@ -48,8 +45,5 @@ Term::check_box "asm box" 0 0 80 15 Term::command "layout split" Term::check_contents "split layout contents" "21 *return 0.*$hex
" -# This check fails because the file name in the title overwrites the -# box. -setup_xfail *-*-* Term::check_box "source box in split layout" 0 0 80 8 Term::check_box "asm box in split layout" 0 7 80 8 diff --git a/gdb/testsuite/gdb.tui/regs.exp b/gdb/testsuite/gdb.tui/regs.exp index f17b1db8d40..1af943dd152 100644 --- a/gdb/testsuite/gdb.tui/regs.exp +++ b/gdb/testsuite/gdb.tui/regs.exp @@ -38,9 +38,6 @@ Term::check_contents "source at startup" ">|21 *return 0" Term::command "layout regs" Term::check_box "register box" 0 0 80 8 -# This check fails because the file name in the title overwrites the -# box. -setup_xfail *-*-* Term::check_box "source box in regs layout" 0 7 80 8 set text [Term::get_line 1] diff --git a/gdb/testsuite/gdb.tui/resize.exp b/gdb/testsuite/gdb.tui/resize.exp index 8484e03c717..3b885e1198e 100644 --- a/gdb/testsuite/gdb.tui/resize.exp +++ b/gdb/testsuite/gdb.tui/resize.exp @@ -37,6 +37,4 @@ if {![Term::enter_tui]} { Term::check_contents "source at startup" ">|21 *return 0" Term::resize 40 90 -# Resizing seems to be somewhat broken. -setup_xfail *-*-* Term::check_box "source box after resize" 0 0 90 23 diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c index f900eab0133..0291bf1a335 100644 --- a/gdb/tui/tui-wingeneral.c +++ b/gdb/tui/tui-wingeneral.c @@ -74,7 +74,21 @@ box_win (struct tui_win_info *win_info, box (win, tui_border_vline, tui_border_hline); #endif if (!win_info->title.empty ()) - mvwaddstr (win, 0, 3, win_info->title.c_str ()); + { + /* 2 chars for the corners, plus 3 more for the indent that's + used below. */ + int max_len = win_info->width - 2 - 3; + + if (win_info->title.size () <= max_len) + mvwaddstr (win, 0, 3, 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 ()); + } + } wattroff (win, attrs); }