--- a/InspectorView.st Fri Sep 13 19:05:06 2002 +0200
+++ b/InspectorView.st Sat Sep 14 15:00:19 2002 +0200
@@ -881,6 +881,93 @@
"Modified: 28.6.1996 / 16:04:53 / cg"
!
+displayStringForValue:someValue
+ "return the values displayString"
+
+ |s sel radix|
+
+ sel := listView at:selectionIndex.
+
+ inspectedObject isNumber ifTrue:[
+ (sel startsWith:$-) ifTrue:[
+ (sel startsWith:'-hex') ifTrue:[
+ radix := 16.
+ ].
+ (sel startsWith:'-oct') ifTrue:[
+ radix := 8.
+ ].
+ (sel startsWith:'-bin') ifTrue:[
+ radix := 2.
+ ].
+ radix notNil ifTrue:[
+ ^ inspectedObject radixPrintStringRadix:radix
+ ]
+ ]
+ ].
+
+ (inspectedObject isKindOf:Method) ifTrue:[
+ (sel startsWith:'-code') ifTrue:[
+ ^ String streamContents:[:s | inspectedObject decompileTo:s]
+ ].
+ ].
+
+ (inspectedObject isKindOf:Text) ifTrue:[
+ (sel startsWith:'-text') ifTrue:[
+ ^ inspectedObject
+ ].
+ ].
+
+ (inspectedObject isKindOf:ByteArray) ifTrue:[
+ (sel startsWith:'-hex') ifTrue:[
+ ^ String streamContents:[:s | inspectedObject asByteArray printOn:s base:16 showRadix:true]
+ ].
+ ].
+
+ (sel startsWith:'-all inst vars') ifTrue:[
+ ^ self stringWithAllInstVarValues
+ ].
+ (sel startsWith:'-all indexed vars') ifTrue:[
+ ^ self stringWithAllIndexedVarValues
+ ].
+
+ Error handle:[:ex |
+ s := someValue classNameWithArticle.
+ displayStringMessage == #displayString ifTrue:[
+ s := s , ' "error in displayString: ' , ex description , '"'
+ ] ifFalse:[
+ s := s , ' "error in displayString (' , displayStringMessage , '): ' , ex description , '"'
+ ]
+ ] do:[
+ showHex ifTrue:[
+ someValue isInteger ifTrue:[
+ ^ '16r' , someValue hexPrintString
+ ].
+ (someValue isMemberOf:ByteArray) ifTrue:[
+ ^ String streamContents:[:s | inspectedObject asByteArray printOn:s base:16 showRadix:true]
+"/ s := '' writeStream.
+"/ s nextPutAll:'#['.
+"/ someValue keysAndValuesDo:[:i :byte |
+"/ i ~~ 1 ifTrue:[
+"/ s space
+"/ ].
+"/ s nextPutAll:'16r'.
+"/ s nextPutAll:(byte hexPrintString leftPaddedTo:2 with:$0).
+"/ ].
+"/ s nextPutAll:']'.
+"/ s := s contents
+ ]
+ ].
+
+ "/ displayStringMessage := #classNameWithArticle
+ "/ displayStringMessage := #displayString
+ "/ displayStringMessage := #printString
+ s := someValue perform:displayStringMessage.
+ ].
+ ^ s.
+
+ "Modified: / 31.10.2001 / 10:44:16 / cg"
+!
+
fieldList
"return a list of names to show in the selectionList.
Leave hasMore as true, if a '...' entry should be added."
@@ -926,8 +1013,8 @@
"Modified: 28.6.1996 / 15:13:41 / cg"
!
-indexedFieldList
- "return a list of indexed-variable names to show in the selectionList.
+indexList
+ "return a list of indexes to show in the selectionList.
Set hasMore to true, if a '...' entry should be added."
| n cls|
@@ -942,7 +1029,26 @@
hasMore := true.
].
- ^ (1 to:n) collect:[:i | i printString].
+ ^ (1 to:n)
+!
+
+indexedFieldList
+ "return a list of indexed-variable names to show in the selectionList.
+ Set hasMore to true, if a '...' entry should be added."
+
+ |l|
+
+ l := self indexList.
+ l isNil ifTrue:[^ nil ].
+ ^ l collect:[:i | i printString].
+!
+
+indexedValueAtIndex:idx
+ ^ inspectedObject basicAt:idx
+!
+
+indexedValueAtIndex:idx put:newValue
+ inspectedObject basicAt:idx put:newValue
!
instVarIndexForLine:lineNr
@@ -1135,271 +1241,6 @@
]
"Modified: / 26.8.1998 / 19:05:25 / cg"
-! !
-
-!InspectorView methodsFor:'queries'!
-
-canInspect:anObject
- ^ anObject inspectorClass == self class
-!
-
-labelFor:anObject
- "return the windowLabel to use in my topView, when inspecting anObject."
-
- |lbl|
-
- (self class == InspectorView
- and:[anObject inspectorClass ~~ InspectorView]) ifTrue:[
- lbl := 'BasicInspector on: %1'
- ] ifFalse:[
- lbl := 'Inspector on: %1'
- ].
- ^ self class classResources
- string:lbl with:(self labelNameFor:anObject)
-!
-
-labelNameFor:anObject
- "return the iconLabel to use in my topView, when inspecting anObject.
- Simply returns the className or name of anObjects class"
-
- |s|
-
- anObject isClass ifTrue:[
- s := anObject displayString
- ] ifFalse:[
- s := anObject classNameWithArticle
- ].
- s isNil ifTrue:[
- anObject isBehavior ifTrue:[
- ^ 'someBehavior'
- ].
- ^ 'something'
- ].
- ^ s
-!
-
-selectedKeyName
- selectionIndex notNil ifTrue:[
- ^ listView listAt:selectionIndex.
- ].
- ^ nil
-! !
-
-!InspectorView methodsFor:'user interaction'!
-
-displayStringForValue:someValue
- "return the values displayString"
-
- |s sel radix|
-
- sel := listView at:selectionIndex.
-
- inspectedObject isNumber ifTrue:[
- (sel startsWith:$-) ifTrue:[
- (sel startsWith:'-hex') ifTrue:[
- radix := 16.
- ].
- (sel startsWith:'-oct') ifTrue:[
- radix := 8.
- ].
- (sel startsWith:'-bin') ifTrue:[
- radix := 2.
- ].
- radix notNil ifTrue:[
- ^ inspectedObject radixPrintStringRadix:radix
- ]
- ]
- ].
-
- (inspectedObject isKindOf:Method) ifTrue:[
- (sel startsWith:'-code') ifTrue:[
- ^ String streamContents:[:s | inspectedObject decompileTo:s]
- ].
- ].
-
- (inspectedObject isKindOf:Text) ifTrue:[
- (sel startsWith:'-text') ifTrue:[
- ^ inspectedObject
- ].
- ].
-
- (inspectedObject isKindOf:ByteArray) ifTrue:[
- (sel startsWith:'-hex') ifTrue:[
- ^ String streamContents:[:s | inspectedObject asByteArray printOn:s base:16 showRadix:true]
- ].
- ].
-
- (sel startsWith:'-all inst vars') ifTrue:[
- ^ self stringWithAllInstVarValues
- ].
- (sel startsWith:'-all indexed vars') ifTrue:[
- ^ self stringWithAllIndexedVarValues
- ].
-
- Error handle:[:ex |
- s := someValue classNameWithArticle.
- displayStringMessage == #displayString ifTrue:[
- s := s , ' "error in displayString: ' , ex description , '"'
- ] ifFalse:[
- s := s , ' "error in displayString (' , displayStringMessage , '): ' , ex description , '"'
- ]
- ] do:[
- showHex ifTrue:[
- someValue isInteger ifTrue:[
- ^ '16r' , someValue hexPrintString
- ].
- (someValue isMemberOf:ByteArray) ifTrue:[
- ^ String streamContents:[:s | inspectedObject asByteArray printOn:s base:16 showRadix:true]
-"/ s := '' writeStream.
-"/ s nextPutAll:'#['.
-"/ someValue keysAndValuesDo:[:i :byte |
-"/ i ~~ 1 ifTrue:[
-"/ s space
-"/ ].
-"/ s nextPutAll:'16r'.
-"/ s nextPutAll:(byte hexPrintString leftPaddedTo:2 with:$0).
-"/ ].
-"/ s nextPutAll:']'.
-"/ s := s contents
- ]
- ].
-
- "/ displayStringMessage := #classNameWithArticle
- "/ displayStringMessage := #displayString
- "/ displayStringMessage := #printString
- s := someValue perform:displayStringMessage.
- ].
- ^ s.
-
- "Modified: / 31.10.2001 / 10:44:16 / cg"
-!
-
-doAccept:theText
- |sel newValue|
-
- sel := listView at:selectionIndex.
- (sel startsWith:'-all') ifTrue:[
- workspace flash.
- ^ self.
- ].
-
- Object errorSignal handle:[:ex |
- workspace flash
- ] do:[
- newValue := inspectedObject class evaluatorClass
- evaluate:theText
- receiver:inspectedObject
- notifying:workspace.
-
- self valueAtLine:selectionIndex put:newValue.
- ]
-!
-
-doCopyKey
- "put the instVar-name into the text-copy-buffer"
-
- |nm|
-
- selectionIndex notNil ifTrue:[
- nm := listView listAt:selectionIndex.
- nm notNil ifTrue:[
- self setTextSelection:(nm asString)
- ]
- ]
-
-!
-
-doInspect:basic
- "user selected inspect-menu entry"
-
- |objectToInspect|
-
- selectionIndex notNil ifTrue:[
- objectToInspect := self selection.
- basic == #new ifTrue:[
- NewInspector::NewInspectorView inspect:objectToInspect
- ] ifFalse:[
- basic ifTrue:[
- objectToInspect basicInspect
- ] ifFalse:[
- objectToInspect inspect
- ]
- ]
- ]
-
- "Modified: / 31.10.1997 / 12:46:53 / cg"
-!
-
-doUpdate
- self reinspect
-!
-
-indexedValueAtIndex:idx
- ^ inspectedObject basicAt:idx
-!
-
-indexedValueAtIndex:idx put:newValue
- inspectedObject basicAt:idx put:newValue
-!
-
-keyPress:aKey x:x y:y
- "all my input is passed on to the workspace-field"
-
- x notNil ifTrue:[
- "/ not already delegated
-
- workspace keyPress:aKey x:-1 y:-1
- ].
-
- "Modified: 4.3.1996 / 22:21:37 / cg"
-!
-
-monitor:anInstVarName
- "start a monitoring process, showing the given instVar
- in regular intervals."
-
- |ivName|
-
- (ivName := anInstVarName) isInteger ifTrue:[
- ivName := anInstVarName printString
- ].
- listView selectElement:ivName.
- self doStartMonitor
-
- "Created: / 1.3.1996 / 19:31:45 / cg"
- "Modified: / 12.2.1999 / 16:05:47 / cg"
-!
-
-selection
- "helper - return the value of the selected entry"
-
- ^ self valueAtLine:selectionIndex
-!
-
-showLast
- "user clicked on an instvar - show value in workspace"
-
- |lastIdx|
-
- lastIdx := listView list size.
- lastIdx ~~ 0 ifTrue:[
- self showSelection:lastIdx.
- listView selection:lastIdx.
- ]
-
- "Created: 28.6.1996 / 15:06:38 / cg"
- "Modified: 18.3.1997 / 18:22:54 / cg"
-!
-
-showReferences
- "user selected references-menu entry"
-
- self selection class hasImmediateInstances ifTrue:[
- ^ self warn:'Sorry - cannot show references to immediate objects'
- ].
- ObjectMemory displayRefChainTo:(self selection)
-
- "Modified: / 30.7.1998 / 14:03:16 / cg"
!
showSelection:lineNr
@@ -1440,18 +1281,30 @@
!
stringWithAllIndexedVarValues
- |nIdx s names maxLen varString|
+ |nIdx s names maxLen varString padLeft|
nIdx := inspectedObject size.
s := '' writeStream.
- names := (1 to:(nIdx min:nShown)).
+ names := self indexList.
- maxLen := nIdx printString size.
+ maxLen := (names collect:[:eachName | eachName printString size]) max.
+ padLeft := names conform:[:eachIdx | eachIdx isInteger].
+
names do:[:eachIdx |
- s nextPutAll:(eachIdx printStringLeftPaddedTo:maxLen+1).
+ |val|
+
+ padLeft ifTrue:[
+ s nextPutAll:(eachIdx printStringLeftPaddedTo:maxLen).
+ ] ifFalse:[
+ s nextPutAll:((eachIdx printString , ' ') paddedTo:maxLen+1 with:$.).
+ ].
+
s nextPutAll:' : '.
- varString := (self indexedValueAtIndex:eachIdx) displayString.
+ "/ val := self indexedValueAtIndex:eachIdx.
+ val := inspectedObject at:eachIdx.
+
+ varString := val displayString.
(varString includes:Character cr) ifTrue:[
varString := varString copyTo:(varString indexOf:Character cr)-1.
varString := varString , '...'.
@@ -1484,29 +1337,6 @@
^ s contents
!
-toggleHex
- |sel|
-
- showHex := showHex not.
- sel := listView selection.
- sel notNil ifTrue:[
- self showSelection:sel
- ]
-
- "Created: / 7.5.1998 / 01:54:52 / cg"
- "Modified: / 7.5.1998 / 02:00:10 / cg"
-!
-
-tryToSelectKeyNamed:aString
- |idx|
-
- (idx := listView list indexOf:aString) ~= 0 ifTrue:[
- listView selection:idx
- ].
-
- "Created: / 16.11.2001 / 13:48:51 / cg"
-!
-
valueAtLine:lineNr
"helper - return the value of the selected entry"
@@ -1595,8 +1425,201 @@
"Created: / 31.10.2001 / 09:17:45 / cg"
! !
+!InspectorView methodsFor:'queries'!
+
+canInspect:anObject
+ ^ anObject inspectorClass == self class
+!
+
+labelFor:anObject
+ "return the windowLabel to use in my topView, when inspecting anObject."
+
+ |lbl|
+
+ (self class == InspectorView
+ and:[anObject inspectorClass ~~ InspectorView]) ifTrue:[
+ lbl := 'BasicInspector on: %1'
+ ] ifFalse:[
+ lbl := 'Inspector on: %1'
+ ].
+ ^ self class classResources
+ string:lbl with:(self labelNameFor:anObject)
+!
+
+labelNameFor:anObject
+ "return the iconLabel to use in my topView, when inspecting anObject.
+ Simply returns the className or name of anObjects class"
+
+ |s|
+
+ anObject isClass ifTrue:[
+ s := anObject displayString
+ ] ifFalse:[
+ s := anObject classNameWithArticle
+ ].
+ s isNil ifTrue:[
+ anObject isBehavior ifTrue:[
+ ^ 'someBehavior'
+ ].
+ ^ 'something'
+ ].
+ ^ s
+!
+
+selectedKeyName
+ selectionIndex notNil ifTrue:[
+ ^ listView listAt:selectionIndex.
+ ].
+ ^ nil
+! !
+
+!InspectorView methodsFor:'user interaction'!
+
+doAccept:theText
+ |sel newValue|
+
+ sel := listView at:selectionIndex.
+ (sel startsWith:'-all') ifTrue:[
+ workspace flash.
+ ^ self.
+ ].
+
+ Object errorSignal handle:[:ex |
+ workspace flash
+ ] do:[
+ newValue := inspectedObject class evaluatorClass
+ evaluate:theText
+ receiver:inspectedObject
+ notifying:workspace.
+
+ self valueAtLine:selectionIndex put:newValue.
+ ]
+!
+
+doCopyKey
+ "put the instVar-name into the text-copy-buffer"
+
+ |nm|
+
+ selectionIndex notNil ifTrue:[
+ nm := listView listAt:selectionIndex.
+ nm notNil ifTrue:[
+ self setTextSelection:(nm asString)
+ ]
+ ]
+
+!
+
+doInspect:basic
+ "user selected inspect-menu entry"
+
+ |objectToInspect|
+
+ selectionIndex notNil ifTrue:[
+ objectToInspect := self selection.
+ basic == #new ifTrue:[
+ NewInspector::NewInspectorView inspect:objectToInspect
+ ] ifFalse:[
+ basic ifTrue:[
+ objectToInspect basicInspect
+ ] ifFalse:[
+ objectToInspect inspect
+ ]
+ ]
+ ]
+
+ "Modified: / 31.10.1997 / 12:46:53 / cg"
+!
+
+doUpdate
+ self reinspect
+!
+
+keyPress:aKey x:x y:y
+ "all my input is passed on to the workspace-field"
+
+ x notNil ifTrue:[
+ "/ not already delegated
+
+ workspace keyPress:aKey x:-1 y:-1
+ ].
+
+ "Modified: 4.3.1996 / 22:21:37 / cg"
+!
+
+monitor:anInstVarName
+ "start a monitoring process, showing the given instVar
+ in regular intervals."
+
+ |ivName|
+
+ (ivName := anInstVarName) isInteger ifTrue:[
+ ivName := anInstVarName printString
+ ].
+ listView selectElement:ivName.
+ self doStartMonitor
+
+ "Created: / 1.3.1996 / 19:31:45 / cg"
+ "Modified: / 12.2.1999 / 16:05:47 / cg"
+!
+
+selection
+ "helper - return the value of the selected entry"
+
+ ^ self valueAtLine:selectionIndex
+!
+
+showLast
+ "user clicked on an instvar - show value in workspace"
+
+ |lastIdx|
+
+ lastIdx := listView list size.
+ lastIdx ~~ 0 ifTrue:[
+ self showSelection:lastIdx.
+ listView selection:lastIdx.
+ ]
+
+ "Created: 28.6.1996 / 15:06:38 / cg"
+ "Modified: 18.3.1997 / 18:22:54 / cg"
+!
+
+showReferences
+ "user selected references-menu entry"
+
+ self selection class hasImmediateInstances ifTrue:[
+ ^ self warn:'Sorry - cannot show references to immediate objects'
+ ].
+ ObjectMemory displayRefChainTo:(self selection)
+
+ "Modified: / 30.7.1998 / 14:03:16 / cg"
+!
+
+toggleHex
+ |sel|
+
+ showHex := showHex not.
+ sel := listView selection.
+ sel notNil ifTrue:[
+ self showSelection:sel
+ ]
+
+ "Created: / 7.5.1998 / 01:54:52 / cg"
+ "Modified: / 7.5.1998 / 02:00:10 / cg"
+!
+
+tryToSelectKeyNamed:aString
+ |idx|
+
+ (idx := listView list indexOf:aString) ~= 0 ifTrue:[
+ listView selection:idx
+ ].
+
+ "Created: / 16.11.2001 / 13:48:51 / cg"
+! !
+
!InspectorView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/InspectorView.st,v 1.131 2002-09-12 11:09:07 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/InspectorView.st,v 1.132 2002-09-14 13:00:16 cg Exp $'
! !