extensions.st
branchjv
changeset 17215 4a42de8e888a
parent 17146 066dbce019f9
parent 17171 e74741ba46ba
child 17217 fdcba4359aff
--- a/extensions.st	Fri Dec 16 23:51:53 2016 +0000
+++ b/extensions.st	Sun Dec 18 11:24:54 2016 +0000
@@ -459,9 +459,11 @@
     
     "/ ouch - ever tried to inspect a 5Mb string?
     self size < 10000 ifTrue:[
-        bytesShown := self
+        bytesShown := self asByteArray hexPrintStringWithSeparator:Character space
     ] ifFalse:[
-        bytesShown := (self copyTo:10000)
+        bytesShown := ((self copyTo:10000) asByteArray hexPrintStringWithSeparator:Character space),
+                      Character cr,
+                      '... (only the first 10000 bytes are shown)'
     ].
     
     ^ self newInspector2Tab
@@ -469,8 +471,13 @@
         priority: 39;
         view: ((HVScrollableView for:EditTextView) 
                 autoHideVerticalScrollBar:true;        
-                contents: (bytesShown asByteArray hexPrintStringWithSeparator:Character space); 
-                yourself)
+                contents:bytesShown; 
+                yourself);
+        yourself        
+
+    "
+     (String new:100000) inspect
+    "
 
     "Created: / 17-02-2008 / 10:10:50 / janfrog"
     "Created: / 20-07-2011 / 16:36:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -486,10 +493,11 @@
     diffApp labelA: 'self'; textA: self.
     diffApp labelB: 'pasted'; textB: 'Paste some text here'.
     diffApp diffView leftTextView readOnly: true.
-    diffApp diffView rightTextView acceptAction:[:contents |
-        diffApp textBHolder value: contents asString.
-        diffApp updateViews.   
-    ].
+    diffApp diffView rightTextView 
+        acceptAction:[:contents |
+            diffApp textBHolder value: contents asString.
+            diffApp updateViews.   
+        ].
 
     ^self newInspector2Tab
         label: 'Diff';
@@ -503,13 +511,15 @@
 !CharacterArray methodsFor:'inspecting'!
 
 inspector2TabHTML
-
-    ((self startsWith:'<!!DOCTYPE html') and:[ HTMLDocumentView ]) ifTrue:[
-        ^self newInspector2Tab
-            label: 'HTML';
-            priority: 35;
-            view: ((ScrollableView for:HTMLDocumentView) setText: self; yourself);
-            yourself
+    "/ use smalltalk at, to prevent HTMLDocumentView becoming a prereq of libbasic
+    (Smalltalk at:#HTMLDocumentView) notNil ifTrue:[
+        ((self startsWith:'<!!DOCTYPE html') or:[ (self startsWith:'<html>') ]) ifTrue:[
+            ^self newInspector2Tab
+                label: 'HTML';
+                priority: 35;
+                view: ((ScrollableView for:(Smalltalk at:#HTMLDocumentView)) setText: self; yourself);
+                yourself
+        ].
     ].
     "/ If nil is returned, tab is not shown...
     ^ nil
@@ -523,13 +533,14 @@
 
 inspector2TabText
 
-    ^self newInspector2Tab
+    ^ self newInspector2Tab
         label: 'String';
         priority: 50;
         view: ((ScrollableView for:EditTextView) 
                     autoHideVerticalScrollBar:true;        
                     contents: self; 
-                    yourself)
+                    yourself);
+        yourself            
 
     "Created: / 17-02-2008 / 10:10:50 / janfrog"
     "Modified: / 21-08-2011 / 08:02:57 / cg"
@@ -559,7 +570,8 @@
     ^ tab
         label: 'XML DOM';
         priority: 45;
-        view: sub
+        view: sub;
+        yourself
 ! !
 
 !CharacterArray methodsFor:'inspecting'!
@@ -587,6 +599,7 @@
 
     d := super inspectorExtraAttributes
         add:'-utf8String' -> [ self utf8Encoded ];
+        add:'-utf8Bytes' -> [ self utf8Encoded asByteArray ];
         add:'-utf8' -> [ self utf8Encoded asByteArray hexPrintStringWithSeparator:Character space ];
         yourself.
 
@@ -1847,9 +1860,10 @@
                 ifTrue:[#( inspector2TabCommon inspector2TabForBasicInspect )]
                 ifFalse:[#( inspector2TabCommon )].
 
-    ((self class whichClassIncludesSelector:#displayOn:x:y:) ~~ Object
-     or:[(self class whichClassIncludesSelector:#displayOn:x:y:opaque:) ~~ Object
-     or:[(self class whichClassIncludesSelector:#displayOpaqueOn:x:y:) ~~ Object]]) ifTrue:[
+    (self isString not
+     and:[ (self class whichClassIncludesSelector:#displayOn:x:y:) ~~ Object
+           or:[(self class whichClassIncludesSelector:#displayOn:x:y:opaque:) ~~ Object
+           or:[(self class whichClassIncludesSelector:#displayOpaqueOn:x:y:) ~~ Object]]]) ifTrue:[
         tabs := tabs copyWith:#inspector2TabDisplayObject.
     ].