#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Mon, 29 Oct 2018 15:33:46 +0100
changeset 18504 33708933d184
parent 18503 a104045b61c8
child 18505 4972f3ec73de
#FEATURE by cg class: ExternalStreamMonitor comment/format in: #updateList changed: #numberOfHeadlines #titleLine #updateStatus:
ExternalStreamMonitor.st
--- a/ExternalStreamMonitor.st	Mon Oct 29 15:33:04 2018 +0100
+++ b/ExternalStreamMonitor.st	Mon Oct 29 15:33:46 2018 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1997 by Claus Gittinger
 	      All Rights Reserved
@@ -222,16 +224,17 @@
 
 titleLine
     OperatingSystem isMSWINDOWSlike ifTrue:[
-        ^ 'Type                 Global                     Handle Detail'.
+        ^ 'Type                           Global                          Handle Detail'.
     ] ifFalse:[    
-        ^ 'Type                 Global                     FD Detail'.
+        ^ 'Type                           Global                          FD Detail'.
     ].
     
     "
      ExternalStreamMonitor open
     "
 
-    "Modified: / 17.6.1998 / 14:52:48 / cg"
+    "Modified: / 17-06-1998 / 14:52:48 / cg"
+    "Modified: / 29-10-2018 / 15:28:22 / Claus Gittinger"
 !
 
 updateList
@@ -253,9 +256,6 @@
             newList := newList select:[:eachStream | eachStream isSocket and:[eachStream isConnected]].
         ].
         
-        "sort by hashKey - will not always generate unique numbers,
-         but most of the time, this works ... for now"
-
         newList sort:[:s1 :s2 | 
                     s1 className < s2 className
                     or:[ s1 className = s2 className
@@ -267,6 +267,8 @@
         ].
     ].
     self installDelayedUpdate.
+
+    "Modified (comment): / 29-10-2018 / 15:32:00 / Claus Gittinger"
 !
 
 updateStatus:newStreamsList
@@ -287,8 +289,9 @@
         ].
         streams notNil ifTrue:[
             list := OrderedCollection new:(streams size + self numberOfHeadlines).
+            list add:'Time: ',(Time now printString).        
             list add:self titleLine.
-            list add:(String new:self titleLine size withAll:$-).
+            list add:(String new:(self titleLine size+20) withAll:$-).
 
             streams validElementsDo:[:aStream |
                 |waiters waitersNames type globalNameOrNil handleString
@@ -326,16 +329,27 @@
 "/                    nm := ''
 "/                ].
                 type := aStream className.
-
-                globalNameOrNil := Smalltalk keyAtValue:aStream.
-                
+                "/ beware of aliases...
+                aStream = Stdin ifTrue:[
+                    globalNameOrNil := 'Stdin'.
+                ] ifFalse:[
+                    aStream = Stdout ifTrue:[
+                        globalNameOrNil := 'Stdout'.
+                    ] ifFalse:[
+                        aStream = Stderr ifTrue:[
+                            globalNameOrNil := 'Stderr'.
+                        ] ifFalse:[
+                            globalNameOrNil := Smalltalk keyAtValue:aStream.
+                        ]
+                    ]
+                ].
                 aStream isFileStream ifTrue:[
                     detail := aStream pathName.
                 ] ifFalse:[
                     aStream isSocket ifTrue:[
                         detail := ''.
                         aStream getPeer notNil ifTrue:[
-                            detail := detail,(aStream getPeerName printString),(aStream getPeer printString).
+                            detail := detail,(aStream getPeerName printString),'[',(aStream getPeer printString),']'.
                         ].
                         aStream port notNil ifTrue:[
                             detail := detail,':',aStream port printString
@@ -360,15 +374,15 @@
                 ] ifFalse:[
                     aStream isOpen ifTrue:[
                         [
+                            handleString := aStream fileDescriptor printString
                         ] on:StreamError do:[
-                            handleString := aStream fileDescriptor printString
                         ].    
                     ].
                     handleString := (handleString ? '') leftPaddedTo:3
                 ].
 
-                line := (type contractTo:20) paddedTo:20.
-                line := line , ' ' , (((globalNameOrNil ? '') contractTo:25) paddedTo:25).
+                line := (type contractTo:30) paddedTo:30.
+                line := line , ' ' , (((globalNameOrNil ? '') contractTo:30) paddedTo:30).
                 line := line , ' ' , handleString.
                 line := line , ' ' , (detail ? '').
 
@@ -422,6 +436,7 @@
     self installDelayedUpdate.
 
     "Modified: / 11-10-2017 / 13:56:14 / cg"
+    "Modified: / 29-10-2018 / 15:33:31 / Claus Gittinger"
 ! !
 
 !ExternalStreamMonitor methodsFor:'menu'!
@@ -487,7 +502,9 @@
 !ExternalStreamMonitor methodsFor:'queries'!
 
 numberOfHeadlines
-    ^ 2
+    ^ 3
+
+    "Modified: / 29-10-2018 / 15:24:14 / Claus Gittinger"
 ! !
 
 !ExternalStreamMonitor methodsFor:'user actions'!