diff mbox

[3/4] tui-winsource: Allocate for actual lines only

Message ID 1478631454-9447-4-git-send-email-arnez@linux.vnet.ibm.com
State New
Headers show

Commit Message

Andreas Arnez Nov. 8, 2016, 6:56 p.m. UTC
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.
---
 gdb/tui/tui-winsource.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Pedro Alves Nov. 8, 2016, 7:31 p.m. UTC | #1
On 11/08/2016 06:56 PM, Andreas Arnez wrote:
> 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.

OK.

Thanks,
Pedro Alves
diff mbox

Patch

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