[66307] branches/xterm-titles/base/src

raimue at macports.org raimue at macports.org
Thu Apr 8 17:30:54 PDT 2010


Revision: 66307
          http://trac.macports.org/changeset/66307
Author:   raimue at macports.org
Date:     2010-04-08 17:30:52 -0700 (Thu, 08 Apr 2010)
Log Message:
-----------
Add new proc ui_phase, which sets xterm title and writes to defined chans if
ports_xterm_titles is set.

Modified Paths:
--------------
    branches/xterm-titles/base/src/macports1.0/macports.tcl
    branches/xterm-titles/base/src/port/port.tcl

Modified: branches/xterm-titles/base/src/macports1.0/macports.tcl
===================================================================
--- branches/xterm-titles/base/src/macports1.0/macports.tcl	2010-04-09 00:27:16 UTC (rev 66306)
+++ branches/xterm-titles/base/src/macports1.0/macports.tcl	2010-04-09 00:30:52 UTC (rev 66307)
@@ -63,7 +63,7 @@
 
     variable open_mports {}
 
-    variable ui_priorities "error warn msg info debug any"
+    variable ui_priorities "error warn phase msg info debug any"
     variable port_phases "any fetch checksum"
     variable current_phase "main"
 }
@@ -189,6 +189,22 @@
     }
 }
 
+proc xterm_title {chan str} {
+    if {[macports::ui_isset ports_xterm_titles]} {
+        puts -nonewline $chan "\033]0;$str\007"
+    }
+}
+
+proc ui_phase {phase args} {
+    # set_phase $phase
+    foreach chan $macports::channels(phase) {
+        if {$chan == "stdout"} {
+            xterm_title $chan "port: [lindex $args 0]"
+        }
+        puts $chan "--->  [lindex $args 0]"
+    }
+}
+
 proc ui_message {priority prefix phase args} {
     global macports::channels ::debuglog macports::current_phase
     foreach chan $macports::channels($priority) {
@@ -237,9 +253,11 @@
     try {
         eval ::ui_init $priority $prefix $channels($priority) $args
     } catch * {
-        interp alias {} ui_$priority {} ui_message $priority $prefix ""
-        foreach phase $phases {
-            interp alias {} ui_${priority}_${phase} {} ui_message $priority $prefix $phase
+        if {[llength [info commands ::ui_$priority]] == 0} {
+            interp alias {} ui_$priority {} ui_message $priority $prefix ""
+            foreach phase $phases {
+                interp alias {} ui_${priority}_${phase} {} ui_message $priority $prefix $phase
+            }
         }
     }
 }

Modified: branches/xterm-titles/base/src/port/port.tcl
===================================================================
--- branches/xterm-titles/base/src/port/port.tcl	2010-04-09 00:27:16 UTC (rev 66306)
+++ branches/xterm-titles/base/src/port/port.tcl	2010-04-09 00:30:52 UTC (rev 66307)
@@ -4346,6 +4346,11 @@
 # Get arguments remaining after option processing
 set remaining_args [lrange $cmd_argv $cmd_argn end]
 
+# If we have a tty, enable xterm titles
+if [isatty stdout] {
+    set ui_options(ports_xterm_titles) yes
+}
+
 # Initialize mport
 # This must be done following parse of global options, as some options are
 # evaluated by mportinit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100408/44af00cb/attachment.html>


More information about the macports-changes mailing list