Projects
New Ticket     Wiki     Browse Source     Timeline     Roadmap     Bug Reports     Search

Changeset 38941 for trunk/base/src

Show
Ignore:
Timestamp:
08/03/08 01:10:26 (4 months ago)
Author:
raimue@…
Message:

port/port.tcl:
Use isatty and term_get_size from pextlib to determine the size of the
connected terminal. This requires the Pextlib package.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port/port.tcl

    r38255 r38941  
    4242    [file join "@TCL_PACKAGE_DIR@" macports1.0 macports_fastload.tcl]} 
    4343package require macports 
     44package require Pextlib 1.0 
    4445 
    4546 
     
    401402## 
    402403# Makes sure we get the current terminal size 
    403 proc set_term_size {} { 
     404proc term_init_size {} { 
    404405    global env 
    405406 
    406407    if {![info exists env(COLUMNS)] || ![info exists env(LINES)]} { 
    407         if {![catch {exec stty size} err]} { 
    408             regexp {(\d+) (\d+)} $err -> rows cols 
    409             set env(COLUMNS) $cols 
    410             set env(LINES) $rows 
     408        if {[isatty stdout]} { 
     409            set size [term_get_size stdout] 
     410 
     411            if {![info exists env(LINES)]} { 
     412                set env(LINES) [lindex $size 0] 
     413            } 
     414 
     415            if {![info exists env(COLUMNS)]} { 
     416                set env(COLUMNS) [lindex $size 1] 
     417            } 
    411418        } 
    412419    } 
     
    31443151# Make sure we get the size of the terminal 
    31453152# We do this here to save it in the boot_env, in case we determined it manually 
    3146 set_term_size 
     3153term_init_size 
    31473154 
    31483155# Save off a copy of the environment before mportinit monkeys with it