Use a Stream to construct lines.
Move context variables into block.
--- a/ProcMonitor.st Wed Jul 03 11:04:45 1996 +0200
+++ b/ProcMonitor.st Wed Jul 03 14:59:46 1996 +0200
@@ -19,7 +19,7 @@
category:'Interface-Tools'
!
-!ProcessMonitor class methodsFor:'documentation'!
+!ProcessMonitor class methodsFor:'documentation'!
copyright
"
@@ -64,7 +64,7 @@
"
! !
-!ProcessMonitor class methodsFor:'defaults'!
+!ProcessMonitor class methodsFor:'defaults'!
defaultIcon
|i|
@@ -78,7 +78,7 @@
^ 'Process Monitor'
! !
-!ProcessMonitor class methodsFor:'startup'!
+!ProcessMonitor class methodsFor:'startup'!
open
|top monitor|
@@ -111,9 +111,11 @@
titleLine
showDetail ifTrue:[
- ^ 'id name state prio usedStack totalStack current-segment switches where'.
+ ^ 'id name state prio usedStack totalStack current-segment switches where'.
].
- ^ 'id name state prio usedStack where'.
+ ^ 'id name state prio usedStack where'.
+
+ "Modified: 3.7.1996 / 13:57:38 / stefan"
!
updateList
@@ -127,7 +129,6 @@
] ifFalse:[
newList := ProcessorScheduler knownProcesses asOrderedCollection.
].
- newList := newList select:[:p | p id notNil].
"sort by id - take care of nil ids of dead processes"
newList sort:[:p1 :p2 |
@@ -150,18 +151,22 @@
Processor removeTimedBlock:listUpdateBlock.
Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay
].
+
+ "Modified: 3.7.1996 / 13:37:29 / stefan"
!
updateStatus
"update status display of processes"
- |oldList list line dIndex con interrupted plist
- aProcess nm st c c0 n found sender running sel|
+ |oldList list line dIndex interrupted
+ aProcess nm st n found running sel space|
+
+ space := Character space.
shown ifTrue:[
oldList := listView list.
processes notNil ifTrue:[
- list := OrderedCollection new.
+ list := OrderedCollection new:(processes size + 2).
list add:self titleLine.
list add:(String new:self titleLine size withAll:$-).
@@ -169,23 +174,23 @@
dIndex := 1.
1 to:processes size do:[:index |
- |totalStack|
+ |con c totalStack sender|
aProcess := processes at:index.
aProcess notNil ifTrue:[
(aProcess id notNil or:[hideDead not]) ifTrue:[
- line := aProcess id printStringPaddedTo:5.
+ line := WriteStream on:(String new:200).
+
+ aProcess id printOn:line paddedTo:5.
(nm := aProcess name) isNil ifFalse:[
- nm := nm printString
+ nm := nm printStringPaddedTo:28.
+ nm size >= 29 ifTrue:[
+ nm := (nm contractTo:28).
+ ].
+ line nextPutAll:nm; nextPut:space.
] ifTrue:[
- nm := ' '
+ line next:29 put:space.
].
- nm size >= 29 ifTrue:[
- nm := (nm contractTo:28) , ' '
- ] ifFalse:[
- nm := (nm printStringPaddedTo:29).
- ].
- line := line , nm.
"/ n := cpuUsages at:(aProcess id) ifAbsent:[0].
"/ n ~~ 0 ifTrue:[
"/ line := line , ((n * 4) printStringLeftPaddedTo:3)
@@ -201,40 +206,39 @@
c := ' '.
running := false.
].
- line := line , c , (st printStringPaddedTo:9).
- line := line , (aProcess priority printStringLeftPaddedTo:3).
- line := line , (aProcess usedStackSize printStringLeftPaddedTo:11).
+ line nextPutAll:c; nextPutAll:(st printStringPaddedTo:9).
+ line nextPutAll:(aProcess priority printStringLeftPaddedTo:3).
+ line nextPutAll:(aProcess usedStackSize printStringLeftPaddedTo:11).
- n := aProcess numberOfStackSegments.
- true "showDetail" ifTrue:[
- con := aProcess suspendedContext.
- con isNil ifTrue:[
- aProcess == Processor activeProcess ifTrue:[
- con := thisContext
- ]
- ].
+ con := aProcess suspendedContext.
+ con isNil ifTrue:[
+ aProcess == Processor activeProcess ifTrue:[
+ con := thisContext
+ ]
].
+
showDetail ifTrue:[
aProcess id == 0 ifTrue:[
- line := line , ('unlimited' leftPaddedTo:13).
+ line nextPutAll:('unlimited' leftPaddedTo:13).
] ifFalse:[
- line := line , (aProcess totalStackSize printStringLeftPaddedTo:10).
- line := line , '(' , n printString , ')'.
+ n := aProcess numberOfStackSegments.
+ line nextPutAll:(aProcess totalStackSize printStringLeftPaddedTo:10).
+ line nextPut:$( ; nextPutAll:n printString; nextPut:$).
].
con notNil ifTrue:[
- line := line , ' '.
- line := line , (((ObjectMemory addressOf:con) printStringRadix:16) leftPaddedTo:8 with:$0).
- line := line , ' .. '.
+ line nextPutAll:' '.
+ line nextPutAll:(((ObjectMemory addressOf:con) printStringRadix:16) leftPaddedTo:8 with:$0).
+ line nextPutAll:' .. '.
c := con.
[(sender := c sender) notNil] whileTrue:[
c := sender
].
- line := line , (((ObjectMemory addressOf:c) printStringRadix:16) leftPaddedTo:8 with:$0).
+ line nextPutAll:(((ObjectMemory addressOf:c) printStringRadix:16) leftPaddedTo:8 with:$0).
] ifFalse:[
- line := line , (String new:20)
+ line next:20 put:space.
].
- line := line , ' '.
- line := line , (aProcess numberOfStackBoundaryHits printStringLeftPaddedTo:5).
+ line nextPut:space.
+ line nextPutAll:(aProcess numberOfStackBoundaryHits printStringLeftPaddedTo:6).
].
con notNil ifTrue:[
@@ -287,11 +291,12 @@
sel isNil ifTrue:[
sel := '* unknown *'
].
- n := c receiver class name , '>>' , sel.
- line := line , ' ' , n
+ line nextPutAll:' '.
+ line nextPutAll:c receiver class name.
+ line nextPutAll:'>>'; nextPutAll:sel.
]
].
- list add:line.
+ list add:line contents.
processes at:dIndex put:aProcess.
dIndex := dIndex + 1
]
@@ -322,6 +327,7 @@
]
"Modified: 27.4.1996 / 14:17:15 / cg"
+ "Modified: 3.7.1996 / 13:56:01 / stefan"
!
updateView
@@ -630,7 +636,7 @@
^ (font widthOf:self titleLine) + 40 @ 100
! !
-!ProcessMonitor class methodsFor:'documentation'!
+!ProcessMonitor class methodsFor:'documentation'!
version
-^ '$Header: /cvs/stx/stx/libtool/Attic/ProcMonitor.st,v 1.36 1996-06-12 18:28:14 cg Exp $'! !
+^ '$Header: /cvs/stx/stx/libtool/Attic/ProcMonitor.st,v 1.37 1996-07-03 12:59:46 stefan Exp $'! !
--- a/ProcessMonitor.st Wed Jul 03 11:04:45 1996 +0200
+++ b/ProcessMonitor.st Wed Jul 03 14:59:46 1996 +0200
@@ -19,7 +19,7 @@
category:'Interface-Tools'
!
-!ProcessMonitor class methodsFor:'documentation'!
+!ProcessMonitor class methodsFor:'documentation'!
copyright
"
@@ -64,7 +64,7 @@
"
! !
-!ProcessMonitor class methodsFor:'defaults'!
+!ProcessMonitor class methodsFor:'defaults'!
defaultIcon
|i|
@@ -78,7 +78,7 @@
^ 'Process Monitor'
! !
-!ProcessMonitor class methodsFor:'startup'!
+!ProcessMonitor class methodsFor:'startup'!
open
|top monitor|
@@ -111,9 +111,11 @@
titleLine
showDetail ifTrue:[
- ^ 'id name state prio usedStack totalStack current-segment switches where'.
+ ^ 'id name state prio usedStack totalStack current-segment switches where'.
].
- ^ 'id name state prio usedStack where'.
+ ^ 'id name state prio usedStack where'.
+
+ "Modified: 3.7.1996 / 13:57:38 / stefan"
!
updateList
@@ -127,7 +129,6 @@
] ifFalse:[
newList := ProcessorScheduler knownProcesses asOrderedCollection.
].
- newList := newList select:[:p | p id notNil].
"sort by id - take care of nil ids of dead processes"
newList sort:[:p1 :p2 |
@@ -150,18 +151,22 @@
Processor removeTimedBlock:listUpdateBlock.
Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay
].
+
+ "Modified: 3.7.1996 / 13:37:29 / stefan"
!
updateStatus
"update status display of processes"
- |oldList list line dIndex con interrupted plist
- aProcess nm st c c0 n found sender running sel|
+ |oldList list line dIndex interrupted
+ aProcess nm st n found running sel space|
+
+ space := Character space.
shown ifTrue:[
oldList := listView list.
processes notNil ifTrue:[
- list := OrderedCollection new.
+ list := OrderedCollection new:(processes size + 2).
list add:self titleLine.
list add:(String new:self titleLine size withAll:$-).
@@ -169,23 +174,23 @@
dIndex := 1.
1 to:processes size do:[:index |
- |totalStack|
+ |con c totalStack sender|
aProcess := processes at:index.
aProcess notNil ifTrue:[
(aProcess id notNil or:[hideDead not]) ifTrue:[
- line := aProcess id printStringPaddedTo:5.
+ line := WriteStream on:(String new:200).
+
+ aProcess id printOn:line paddedTo:5.
(nm := aProcess name) isNil ifFalse:[
- nm := nm printString
+ nm := nm printStringPaddedTo:28.
+ nm size >= 29 ifTrue:[
+ nm := (nm contractTo:28).
+ ].
+ line nextPutAll:nm; nextPut:space.
] ifTrue:[
- nm := ' '
+ line next:29 put:space.
].
- nm size >= 29 ifTrue:[
- nm := (nm contractTo:28) , ' '
- ] ifFalse:[
- nm := (nm printStringPaddedTo:29).
- ].
- line := line , nm.
"/ n := cpuUsages at:(aProcess id) ifAbsent:[0].
"/ n ~~ 0 ifTrue:[
"/ line := line , ((n * 4) printStringLeftPaddedTo:3)
@@ -201,40 +206,39 @@
c := ' '.
running := false.
].
- line := line , c , (st printStringPaddedTo:9).
- line := line , (aProcess priority printStringLeftPaddedTo:3).
- line := line , (aProcess usedStackSize printStringLeftPaddedTo:11).
+ line nextPutAll:c; nextPutAll:(st printStringPaddedTo:9).
+ line nextPutAll:(aProcess priority printStringLeftPaddedTo:3).
+ line nextPutAll:(aProcess usedStackSize printStringLeftPaddedTo:11).
- n := aProcess numberOfStackSegments.
- true "showDetail" ifTrue:[
- con := aProcess suspendedContext.
- con isNil ifTrue:[
- aProcess == Processor activeProcess ifTrue:[
- con := thisContext
- ]
- ].
+ con := aProcess suspendedContext.
+ con isNil ifTrue:[
+ aProcess == Processor activeProcess ifTrue:[
+ con := thisContext
+ ]
].
+
showDetail ifTrue:[
aProcess id == 0 ifTrue:[
- line := line , ('unlimited' leftPaddedTo:13).
+ line nextPutAll:('unlimited' leftPaddedTo:13).
] ifFalse:[
- line := line , (aProcess totalStackSize printStringLeftPaddedTo:10).
- line := line , '(' , n printString , ')'.
+ n := aProcess numberOfStackSegments.
+ line nextPutAll:(aProcess totalStackSize printStringLeftPaddedTo:10).
+ line nextPut:$( ; nextPutAll:n printString; nextPut:$).
].
con notNil ifTrue:[
- line := line , ' '.
- line := line , (((ObjectMemory addressOf:con) printStringRadix:16) leftPaddedTo:8 with:$0).
- line := line , ' .. '.
+ line nextPutAll:' '.
+ line nextPutAll:(((ObjectMemory addressOf:con) printStringRadix:16) leftPaddedTo:8 with:$0).
+ line nextPutAll:' .. '.
c := con.
[(sender := c sender) notNil] whileTrue:[
c := sender
].
- line := line , (((ObjectMemory addressOf:c) printStringRadix:16) leftPaddedTo:8 with:$0).
+ line nextPutAll:(((ObjectMemory addressOf:c) printStringRadix:16) leftPaddedTo:8 with:$0).
] ifFalse:[
- line := line , (String new:20)
+ line next:20 put:space.
].
- line := line , ' '.
- line := line , (aProcess numberOfStackBoundaryHits printStringLeftPaddedTo:5).
+ line nextPut:space.
+ line nextPutAll:(aProcess numberOfStackBoundaryHits printStringLeftPaddedTo:6).
].
con notNil ifTrue:[
@@ -287,11 +291,12 @@
sel isNil ifTrue:[
sel := '* unknown *'
].
- n := c receiver class name , '>>' , sel.
- line := line , ' ' , n
+ line nextPutAll:' '.
+ line nextPutAll:c receiver class name.
+ line nextPutAll:'>>'; nextPutAll:sel.
]
].
- list add:line.
+ list add:line contents.
processes at:dIndex put:aProcess.
dIndex := dIndex + 1
]
@@ -322,6 +327,7 @@
]
"Modified: 27.4.1996 / 14:17:15 / cg"
+ "Modified: 3.7.1996 / 13:56:01 / stefan"
!
updateView
@@ -630,7 +636,7 @@
^ (font widthOf:self titleLine) + 40 @ 100
! !
-!ProcessMonitor class methodsFor:'documentation'!
+!ProcessMonitor class methodsFor:'documentation'!
version
-^ '$Header: /cvs/stx/stx/libtool/ProcessMonitor.st,v 1.36 1996-06-12 18:28:14 cg Exp $'! !
+^ '$Header: /cvs/stx/stx/libtool/ProcessMonitor.st,v 1.37 1996-07-03 12:59:46 stefan Exp $'! !