This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] tui-winsource: Allocate for actual lines only


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

commit 7bc2c8b83ea82b4315c67e7658af815aed062e73
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
Date:   Wed Nov 9 13:02:13 2016 +0100

    tui-winsource: Allocate for actual lines only
    
    The logic for allocating a TUI source window's content buffer allocates
    two more lines than needed, because it does not reduce the window height
    by the highlight box's overhead.  However, it does reduce the line width
    accordingly.  This patch makes the height and width calculation
    consistent and improves the comment.
    
    gdb/ChangeLog:
    
    	* tui/tui-winsource.c (tui_alloc_source_buffer): Subtract
    	highlight box's overhead when calculating the content height.

Diff:
---
 gdb/ChangeLog           | 5 +++++
 gdb/tui/tui-winsource.c | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ca17d84..d6b8b47 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2016-11-09  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
+	* tui/tui-winsource.c (tui_alloc_source_buffer): Subtract
+	highlight box's overhead when calculating the content height.
+
+2016-11-09  Andreas Arnez  <arnez@linux.vnet.ibm.com>
+
 	* tui/tui-disasm.c (tui_set_disassem_content): Fix calculation of
 	the longest disassembly line's length.
 
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 09080b8..4a82ae4 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -604,8 +604,11 @@ tui_alloc_source_buffer (struct tui_win_info *win_info)
   char *src_line_buf;
   int i, line_width, max_lines;
 
-  max_lines = win_info->generic.height;	/* Less the highlight box.  */
-  line_width = win_info->generic.width - 1;
+  /* The window width/height includes the highlight box.  Determine actual
+     content dimensions, including string null-terminators.  */
+  max_lines = win_info->generic.height - 2;
+  line_width = win_info->generic.width - 2 + 1;
+
   /*
    * Allocate the buffer for the source lines.  Do this only once
    * since they will be re-used for all source displays.  The only


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]