aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-source.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2023-11-13 21:22:50 +0100
committerTom de Vries <tdevries@suse.de>2023-11-13 21:22:50 +0100
commitff3c86a844225a0f8848b2aee0b1628114c01377 (patch)
treee5acefcea5741da303caba64eb4dbd309ba11d15 /gdb/tui/tui-source.c
parent70911fd87f261d3726fea4699a4ffdd5623482b7 (diff)
downloadgdb-ff3c86a844225a0f8848b2aee0b1628114c01377.zip
gdb-ff3c86a844225a0f8848b2aee0b1628114c01377.tar.gz
gdb-ff3c86a844225a0f8848b2aee0b1628114c01377.tar.bz2
[gdb/tui] Add tui_win_info::{box_width,box_size}
In tui_source_window::set_contents we have: ... /* Take hilite (window border) into account, when calculating the number of lines. */ int nlines = height - 2; ... The '2' represents the total size of the window border (or box, in can_box terms), in this case one line at the top and one line at the bottom. Likewise, '1' is used to represent the width of the window border. Introduce new functions: - tui_win_info::box_width () and - tui_win_info::box_size () that can be used instead instead of these hardcoded constants. Implement these such that they return 0 when can_box () == false. Tested patch completeness by making all windows unboxed: ... @@ -85,7 +85,7 @@ struct tui_win_info /* Return true if this window can be boxed. */ virtual bool can_box () const { - return true; + return false; } int box_width () const ... and test-driving TUI. This required eliminating an assert in tui_source_window_base::show_source_content, I've included that part as well. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/tui/tui-source.c')
-rw-r--r--gdb/tui/tui-source.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 6625f0c..5e9a954 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -53,7 +53,7 @@ tui_source_window::set_contents (struct gdbarch *arch,
/* Take hilite (window border) into account, when
calculating the number of lines. */
- int nlines = height - 2;
+ int nlines = height - box_size ();
std::string srclines;
const std::vector<off_t> *offsets;
@@ -201,7 +201,7 @@ tui_source_window::line_is_displayed (int line) const
void
tui_source_window::maybe_update (frame_info_ptr fi, symtab_and_line sal)
{
- int start_line = (sal.line - ((height - 2) / 2)) + 1;
+ int start_line = (sal.line - ((height - box_size ()) / 2)) + 1;
if (start_line <= 0)
start_line = 1;