[38941] trunk/base/src/port/port.tcl

raimue at macports.org raimue at macports.org
Sun Aug 3 01:10:26 PDT 2008


Revision: 38941
          http://trac.macosforge.org/projects/macports/changeset/38941
Author:   raimue at macports.org
Date:     2008-08-03 01:10:26 -0700 (Sun, 03 Aug 2008)
Log 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.

Modified Paths:
--------------
    trunk/base/src/port/port.tcl

Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl	2008-08-03 08:05:42 UTC (rev 38940)
+++ trunk/base/src/port/port.tcl	2008-08-03 08:10:26 UTC (rev 38941)
@@ -41,6 +41,7 @@
 catch {source \
     [file join "@TCL_PACKAGE_DIR@" macports1.0 macports_fastload.tcl]}
 package require macports
+package require Pextlib 1.0
 
 
 # Standard procedures
@@ -400,14 +401,20 @@
 
 ##
 # Makes sure we get the current terminal size
-proc set_term_size {} {
+proc term_init_size {} {
     global env
 
     if {![info exists env(COLUMNS)] || ![info exists env(LINES)]} {
-        if {![catch {exec stty size} err]} {
-            regexp {(\d+) (\d+)} $err -> rows cols
-            set env(COLUMNS) $cols
-            set env(LINES) $rows
+        if {[isatty stdout]} {
+            set size [term_get_size stdout]
+
+            if {![info exists env(LINES)]} {
+                set env(LINES) [lindex $size 0]
+            }
+
+            if {![info exists env(COLUMNS)]} {
+                set env(COLUMNS) [lindex $size 1]
+            }
         }
     }
 }
@@ -3143,7 +3150,7 @@
 
 # Make sure we get the size of the terminal
 # We do this here to save it in the boot_env, in case we determined it manually
-set_term_size
+term_init_size
 
 # Save off a copy of the environment before mportinit monkeys with it
 global env boot_env
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080803/2aa880f8/attachment.html 


More information about the macports-changes mailing list