Projects
New Ticket     Wiki     Browse Source     Timeline     Roadmap     Bug Reports     Search

Changeset 37316 for trunk/base/src

Show
Ignore:
Timestamp:
06/02/08 16:37:43 (6 months ago)
Author:
raimue@…
Message:

port/port.tcl, macports1.0/macports.tcl:
Use current terminal size instead of a hardcoded width. This uses the COLUMNS
environment variable which therefore should be preserved by the env cleanup in
macports.tcl. See #15488.

Location:
trunk/base/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/base/src/macports1.0/macports.tcl

    r37046 r37316  
    659659        USER GROUP 
    660660        http_proxy HTTPS_PROXY FTP_PROXY ALL_PROXY NO_PROXY 
     661        COLUMNS LINES 
    661662    } 
    662663    if {[info exists extra_env]} { 
  • trunk/base/src/port/port.tcl

    r37314 r37316  
    398398 
    399399## 
     400# Makes sure we get the current terminal size 
     401proc set_term_size {} { 
     402    global env 
     403 
     404    if {![info exists env(COLUMNS)] || ![info exists env(LINES)]} { 
     405        if {![catch {exec stty size} err]} { 
     406            regexp {(\d+) (\d+)} $err -> rows cols 
     407            set env(COLUMNS) $cols 
     408            set env(LINES) $rows 
     409        } else { 
     410            puts stderr "Warning: Unable to get terminal size, using 80x24!" 
     411            set cols 80 
     412            set rows 24 
     413        } 
     414    } 
     415} 
     416 
     417## 
    400418# Wraps a multi-line string at specified textwidth 
    401419# 
     
    403421# 
    404422# @param string input string 
    405 # @param maxlen text width (indent length not counted) 
     423# @param maxlen text width (0 defaults to current terminal width) 
    406424# @param indent prepend to every line 
    407425# @return wrapped string 
    408426proc wrap {string maxlen {indent ""} {indentfirstline 1}} { 
     427    global env 
     428 
     429    if {$maxlen == 0} { 
     430        set maxlen $env(COLUMNS) 
     431    } 
     432 
    409433    set splitstring {} 
    410434    foreach line [split $string "\n"] { 
     
    420444# 
    421445# @param line input line 
    422 # @param maxlen text width (indent length not counted) 
     446# @param maxlen text width (0 defaults to current terminal width) 
    423447# @param indent prepend to every line 
    424448# @return wrapped string 
    425449proc wrapline {line maxlen {indent ""} {indentfirstline 1}} { 
     450    global env 
     451 
     452    if {$maxlen == 0} { 
     453        set maxlen $env(COLUMNS) 
     454    } 
     455 
    426456    set string [split $line " "] 
    427457    if {$indentfirstline == 0} { 
     
    11841214        set ret "Usage: " 
    11851215        set len [string length $action] 
    1186         append ret [wrap "$action$cmds$args" 80 [string repeat " " [expr 8 + $len]] 0] 
     1216        append ret [wrap "$action$cmds$args" 0 [string repeat " " [expr 8 + $len]] 0] 
    11871217        append ret "\n" 
    11881218 
     
    14111441                } 
    14121442                puts -nonewline "Variants:    " 
    1413                 puts [wrap $vars 80 [string repeat " " 13] 0] 
     1443                puts [wrap $vars 0 [string repeat " " 13] 0] 
    14141444            } 
    14151445            puts "" 
    14161446            if {[info exists portinfo(long_description)]} { 
    1417                 puts [wrap [join $portinfo(long_description)] 80] 
     1447                puts [wrap [join $portinfo(long_description)] 0] 
    14181448            } else { 
    14191449                if {[info exists portinfo(description)]} { 
    1420                     puts [wrap [join $portinfo(description)] 80] 
     1450                    puts [wrap [join $portinfo(description)] 0] 
    14211451                } 
    14221452            } 
     
    21012131                    } 
    21022132                    puts "" 
    2103                     puts [wrap [join $portinfo(description)] 80 [string repeat " " 4]] 
     2133                    puts [wrap [join $portinfo(description)] 0 [string repeat " " 4]] 
    21042134                } 
    21052135            } 
     
    30513081array set private_options {} 
    30523082 
     3083# Make sure we get the size of the terminal 
     3084# We do this here to save it in the boot_env, in case we determined it manually 
     3085set_term_size 
     3086 
    30533087# Save off a copy of the environment before mportinit monkeys with it 
    30543088global env boot_env