Skip to content

Commit

Permalink
Merge pull request #6203 from gadfort/man-pager
Browse files Browse the repository at this point in the history
utl: fix pager behavior
  • Loading branch information
maliberty authored Nov 20, 2024
2 parents f827c10 + cb1777c commit b2b6c95
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/utl/src/Utl.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ proc man { args } {
set no_pager 1
}

#set MAN_PATH [utl::get_input]
#if { [utl::check_valid_man_path $MAN_PATH] == false } {
# puts "Using default manpath."
# set MAN_PATH $DEFAULT_MAN_PATH
#}
if { [gui::enabled] && !$no_pager } {
set no_pager 1
}

set man_path $MAN_PATH
set man_sections {}
Expand Down Expand Up @@ -107,11 +105,12 @@ proc man { args } {
set page_size 40

for { set i 0 } { $i < $num_lines } { incr i $page_size } {
set page [lrange $lines $i [expr { $i + $page_size - 1 }]]
set page_end [expr { $i + $page_size - 1 }]
set page [lrange $lines $i $page_end]
puts [join $page "\n"]

# Ask user to continue or quit
if { !$no_pager && [llength $lines] > $page_size } {
if { !$no_pager && $num_lines > $page_size && $page_end < $num_lines } {
puts -nonewline "---\nPress 'q' to quit or any other key to continue: \n---"
flush stdout
set input [gets stdin]
Expand Down

0 comments on commit b2b6c95

Please sign in to comment.