public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/3] [gdb/tui] Refactor prefresh call in tui_source_window_base::refresh_window
@ 2023-11-10 13:00 Tom de Vries
  2023-11-10 13:00 ` [PATCH 2/3] [gdb/tui] Add tui_win_info::{box_width,box_size} Tom de Vries
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Tom de Vries @ 2023-11-10 13:00 UTC (permalink / raw)
  To: gdb-patches

Currently the call to prefresh in tui_source_window_base::refresh_window looks
like:
...
  prefresh (m_pad.get (), 0, pad_x, y + 1, x + left_margin,
	    y + m_content.size (), x + left_margin + view_width - 1);
...

This is hard to parse.  It's not obvious what the arguments mean, and there's
repetition in the argument calculation.

Fix this by rewriting the call as follows:
- use sminrow, smincol, smaxrow and smaxcol variables for the last
  4 arguments, and
- calculate the smaxrow and smaxcol variables based on the sminrow and
  smincol variables.

Tested on x86_64-linux.
---
 gdb/tui/tui-winsource.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index dd857656bfc..7eabc522d85 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -347,8 +347,11 @@ tui_source_window_base::refresh_window ()
   gdb_assert (pad_width > 0 || m_pad.get () == nullptr);
   gdb_assert (pad_x + view_width <= pad_width || m_pad.get () == nullptr);
 
-  prefresh (m_pad.get (), 0, pad_x, y + 1, x + left_margin,
-	    y + m_content.size (), x + left_margin + view_width - 1);
+  int sminrow = y + 1;
+  int smincol = x + left_margin;
+  int smaxrow = sminrow + m_content.size () - 1;
+  int smaxcol = smincol + view_width - 1;
+  prefresh (m_pad.get (), 0, pad_x, sminrow, smincol, smaxrow, smaxcol);
 }
 
 void

base-commit: 98712e137edb0bf33acd3bf716a160d16f600c35
-- 
2.35.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-13 17:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-10 13:00 [PATCH 1/3] [gdb/tui] Refactor prefresh call in tui_source_window_base::refresh_window Tom de Vries
2023-11-10 13:00 ` [PATCH 2/3] [gdb/tui] Add tui_win_info::{box_width,box_size} Tom de Vries
2023-11-13 17:42   ` Tom Tromey
2023-11-10 13:00 ` [PATCH 3/3] [gdb/tui] Don't include border_width in left_margin Tom de Vries
2023-11-13 17:42   ` Tom Tromey
2023-11-13 17:41 ` [PATCH 1/3] [gdb/tui] Refactor prefresh call in tui_source_window_base::refresh_window 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).