public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Truncate long TUI window titles
@ 2019-09-08 20:07 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2019-09-08 20:07 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8634b4628ea00a95ce3dfe8f9915724e8d710dad

commit 8634b4628ea00a95ce3dfe8f9915724e8d710dad
Author: Tom Tromey <tom@tromey.com>
Date:   Thu Jul 18 15:07:01 2019 -0600

    Truncate long TUI window titles
    
    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-09-08  Tom Tromey  <tom@tromey.com>
    
    	* tui/tui-wingeneral.c (box_win): Truncate long window titles.
    
    gdb/testsuite/ChangeLog
    2019-09-08  Tom Tromey  <tom@tromey.com>
    
    	* gdb.tui/resize.exp: Remove setup_xfail.
    	* gdb.tui/regs.exp: Remove setup_xfail.
    	* gdb.tui/basic.exp: Remove setup_xfail.

Diff:
---
 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/ChangeLog b/gdb/ChangeLog
index d5938be..af1608d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2019-09-08  Tom Tromey  <tom@tromey.com>
+
+	* tui/tui-wingeneral.c (box_win): Truncate long window titles.
+
 2019-09-07  Simon Marchi  <simon.marchi@efficios.com>
 
 	* dwarf2read.c (struct dw2_symtab_iterator) <block_index>:
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a6a645b..6cee478 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2019-09-08  Tom Tromey  <tom@tromey.com>
+
+	* gdb.tui/resize.exp: Remove setup_xfail.
+	* gdb.tui/regs.exp: Remove setup_xfail.
+	* gdb.tui/basic.exp: Remove setup_xfail.
+
 2019-09-06  David Blaikie  <dblaikie@gmail.com>
 
 	* gdb.base/label.exp: un-XFAIL label related tests under Clang.
diff --git a/gdb/testsuite/gdb.tui/basic.exp b/gdb/testsuite/gdb.tui/basic.exp
index f60011c..716c52f 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 <main>"
 
-# 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 f17b1db..1af943d 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 8484e03..3b885e1 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 f900eab..235c17c 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 ());
+    {
+      /* Emit "+-TITLE-+" -- so 2 characters on the right and 2 on
+	 the left.  */
+      int max_len = win_info->width - 2 - 2;
+
+      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);
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-08 20:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-08 20:07 [binutils-gdb] Truncate long TUI window titles Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).