From: Tom de Vries Date: Mon, 13 Nov 2023 20:22:50 +0000 (+0100) Subject: [gdb/tui] Refactor prefresh call in tui_source_window_base::refresh_window X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=70911fd87f261d3726fea4699a4ffdd5623482b7;p=binutils-gdb.git [gdb/tui] Refactor prefresh call in tui_source_window_base::refresh_window 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. Approved-By: Tom Tromey --- 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