class: MiniInspector
authorClaus Gittinger <cg@exept.de>
Mon, 03 Feb 2014 10:20:49 +0100
changeset 15926 2a89ee50988c
parent 15925 80810829f468
child 15927 65b8082c8e68
class: MiniInspector class definition comment/format in: #documentation changed: #commandLoop #getCommand:
MiniInspector.st
--- a/MiniInspector.st	Sun Feb 02 00:13:55 2014 +0100
+++ b/MiniInspector.st	Mon Feb 03 10:20:49 2014 +0100
@@ -12,7 +12,7 @@
 "{ Package: 'stx:libbasic' }"
 
 Object subclass:#MiniInspector
-	instanceVariableNames:'inspectedObject'
+	instanceVariableNames:'inspectedObject commandArg'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'System-Debugging-Support'
@@ -37,7 +37,11 @@
 documentation
 "
     a primitive (non graphical) inspector for use on systems without
-    graphics or when the real inspector dies.
+    graphics or when the real inspector dies (i.e. the UI is locked).
+    Sometimes useful as a last chance to fix a broken UI / event handling.
+    Needs a console.
+
+    MiniInspector openOn: Display
 
     [author:]
         Claus Gittinger
@@ -68,10 +72,10 @@
         cmd isNil ifTrue:[   "/ EOF -> quit
             cmd := $q
         ].
-	cmd isNumber ifTrue:[
-	    valid := true.
-	    self inspectInstvar:cmd of:inspectedObject
-	].
+        cmd isNumber ifTrue:[
+            valid := true.
+            self inspectInstvar:cmd of:inspectedObject
+        ].
         (cmd == $i) ifTrue:[
             valid := true.
             self printInstVarsOf:inspectedObject
@@ -87,45 +91,58 @@
         (cmd == $C) ifTrue:[
             valid := true.
             MiniInspector openOn:inspectedObject class.
-	    'back in previous inspector; inspecting ' print.  inspectedObject displayString printCR.
+            'back in previous inspector; inspecting ' print.  inspectedObject displayString printCR.
+        ].
+        (cmd == $d) ifTrue:[
+            valid := true.
+            ObjectMemory dumpObject:inspectedObject
+        ].
+        (cmd == $E) ifTrue:[
+            valid := true.
+            Parser evaluate:commandArg receiver:inspectedObject.
+        ].
+        (cmd == $e) ifTrue:[
+            valid := true.
+            (Parser evaluate:commandArg receiver:inspectedObject) printCR.
         ].
-	(cmd == $d) ifTrue:[
-	    valid := true.
-	    ObjectMemory dumpObject:inspectedObject
-	].
-	(cmd == $*) ifTrue:[
-	    valid := true.
-	    inspectedObject becomeNil.
-	    ^ cmd. 
-	].
-	(cmd == $I) ifTrue:[
-	    valid := true.
+        (cmd == $e) ifTrue:[
+            valid := true.
+            ObjectMemory dumpObject:inspectedObject
+        ].
+        (cmd == $*) ifTrue:[
+            valid := true.
+            inspectedObject becomeNil.
+            ^ cmd. 
+        ].
+        (cmd == $I) ifTrue:[
+            valid := true.
             self interpreterLoopWith:inspectedObject
-	].
+        ].
 
         (cmd == $q) ifTrue:[
-	    ^ cmd. 
-	].
+            ^ cmd. 
+        ].
 
         valid ifFalse: [
             'valid commands:
- p     .... print inspected object
- c     .... print inspected objects class
- i     .... print instvars
- d     .... VM-dump inspected object
+ p ...... print inspected object
+ c ...... print inspected objects class
+ i ...... print instvars
+ d ...... VM-dump inspected object
 
- I     .... interpreter
+ I ...... interpreter
+ e expr   evaluate expression & print result ("E" to not print)
 
- C     .... inspect class
- <Num> .... inspect instvar num (1..)
+ C ...... inspect class
+ <Num> .. inspect instvar num (1..)
 
- *     .... becomeNil and quit (dangerous)
- q     .... quit
+ * ...... becomeNil and quit (dangerous)
+ q ...... quit
 '       errorPrintCR
         ]
     ].
 
-    "Modified: 24.7.1997 / 10:00:24 / cg"
+    "Modified: / 03-02-2014 / 10:19:46 / cg"
 !
 
 enter
@@ -154,7 +171,7 @@
 !
 
 getCommand:prompt
-    |cmd c num|
+    |cmd c num arg|
 
     prompt print.
 
@@ -169,10 +186,17 @@
         ^ num "/ numeric
     ].
 
+    c := Character fromUser.
+    [c notNil and:[c isEndOfLineCharacter not and:[c isSeparator ]]] whileTrue:[ c := Character fromUser ].
+    arg := ''.
     [c notNil and:[c isEndOfLineCharacter]] whileFalse:[
+        arg := arg copyWith:c.
         c := Character fromUser
     ].
+    commandArg := arg.
     ^ cmd
+
+    "Modified: / 03-02-2014 / 10:16:49 / cg"
 !
 
 initializeFor:anObject
@@ -262,6 +286,6 @@
 !MiniInspector class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/MiniInspector.st,v 1.28 2014-01-23 16:11:52 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/MiniInspector.st,v 1.29 2014-02-03 09:20:49 cg Exp $'
 ! !