1 # Copyright 2023-2024 Free Software Foundation, Inc. 2 3 # This program is free software; you can redistribute it and/or modify 4 # it under the terms of the GNU General Public License as published by 5 # the Free Software Foundation; either version 3 of the License, or 6 # (at your option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 # Check that "set tui compact-source on" has the intended effect. 17 18 require allow_tui_tests 19 20 tuiterm_env 21 22 standard_testfile 23 24 # Let's generate the source file. We want a short file, with less than 10 25 # lines, and the copyright notice by itself is already more that that. 26 set src_list \ 27 [list \ 28 "int" \ 29 "main (void)" \ 30 "{" \ 31 " return 0;" \ 32 "}"] 33 set re_line_four [string_to_regexp [lindex $src_list 3]] 34 set src_txt [join $src_list "\n"] 35 set srcfile [standard_output_file $srcfile] 36 set fd [open $srcfile w] 37 puts $fd $src_txt 38 close $fd 39 40 if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} { 41 return -1 42 } 43 44 Term::clean_restart 24 80 $binfile 45 46 gdb_test_no_output "maint set tui-left-margin-verbose on" 47 gdb_test_no_output "set tui compact-source on" 48 49 if {![Term::enter_tui]} { 50 unsupported "TUI not supported" 51 return 52 } 53 54 set re_border "\\|" 55 56 set max_line_nr_in_source_file [llength $src_list] 57 # Ensure there are more lines in the window than in the source file. 58 set src_window_lines [expr $max_line_nr_in_source_file + 2] 59 # Account for border size. 60 set src_window_size [expr $src_window_lines + 2] 61 Term::command "wh src $src_window_size" 62 63 set re_left_margin "___4_" 64 65 Term::check_contents "compact source format" \ 66 "$re_border$re_left_margin$re_line_four *$re_border" 67 68 set re_left_margin "___0*[expr $max_line_nr_in_source_file + 1]_" 69 Term::check_contents_not "no surplus line number" \ 70 "$re_border$re_left_margin *$re_border" 71