From 8634b4628ea00a95ce3dfe8f9915724e8d710dad Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 18 Jul 2019 15:07:01 -0600 Subject: 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 * tui/tui-wingeneral.c (box_win): Truncate long window titles. gdb/testsuite/ChangeLog 2019-09-08 Tom Tromey * gdb.tui/resize.exp: Remove setup_xfail. * gdb.tui/regs.exp: Remove setup_xfail. * gdb.tui/basic.exp: Remove setup_xfail. --- gdb/tui/tui-wingeneral.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'gdb/tui') 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); } -- cgit v1.1