Skip to content

Commit

Permalink
Fix unaligned list output when 100+ modules loaded
Browse files Browse the repository at this point in the history
Fix unaligned module list output when 100 or more modules are loaded.

Fixes #496.
  • Loading branch information
xdelaruelle committed Jun 5, 2023
1 parent e5f7f99 commit 4306e07
Show file tree
Hide file tree
Showing 3 changed files with 232 additions and 8 deletions.
2 changes: 2 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Modules 5.3.1 (not yet released)
a requirement and is the sole module to define it. (fix issue #495)
* Script: update :command:`pre-commit` and :command:`commit-msg` git hook
scripts to use `Hunspell`_ as spell checker instead of Aspell.
* Fix unaligned :subcmd:`list` output when 100 or more modules are loaded.
(fix issue #496)

.. _Hunspell: https://hunspell.github.io/

Expand Down
18 changes: 10 additions & 8 deletions tcl/report.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -1501,27 +1501,28 @@ proc displayElementList {header sgrkey hstyle one_per_line display_idx\
}
}
# increase index length when 100+ modules to report
if {$display_idx} {
set idx_len [expr {$elt_cnt > 99 ? {3} : {2}}]
}
if {$json} {
set displist [join $display_list ,\n]
# display one element per line
} elseif {$one_per_line} {
if {$display_idx} {
set idx $start_idx
foreach elt $display_list {
append displist [format {%2d) %s } $idx $elt] \n
append displist [format "%${idx_len}d) %s " $idx $elt] \n
incr idx
}
} else {
append displist [join $display_list \n] \n
}
# elsewhere display elements in columns
} else {
if {$display_idx} {
# save room for numbers and spacing: 2 digits + ) + space
set elt_prefix_len 4
} else {
set elt_prefix_len 0
}
# save room for numbers and spacing: 2 or 3 digits + ) + space
set elt_prefix_len [expr {$display_idx ? $idx_len + 2 : {0}}]
# save room for two spaces after element
set elt_suffix_len 2
Expand Down Expand Up @@ -1623,7 +1624,8 @@ proc displayElementList {header sgrkey hstyle one_per_line display_idx\
set index [expr {$col * $rows + $row}]
if {$index < $elt_cnt} {
if {$display_idx} {
append displist [format "%2d) " [expr {$index +$start_idx}]]
append displist [format "%${idx_len}d) " [expr {$index +\
$start_idx}]]
}
# cannot use 'format' as strings may contain SGR codes
append displist [lindex $display_list $index][string repeat\
Expand Down

0 comments on commit 4306e07

Please sign in to comment.