#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Tue, 12 Mar 2019 16:37:29 +0100
changeset 6555 3af24552a8e0
parent 6554 f65b459a7d91
child 6556 2b8c8e4fbfcb
#FEATURE by cg class: Workspace CTRL-SHIFT-q -> basicInspectIt added: #basicInspectIt #withValueOfSelectionDo: comment/format in: #inspectIt changed: #browseClass #browseItsClass #doIt #editMenu #keyPress:x:y: #printIt #replaceIt
Workspace.st
--- a/Workspace.st	Fri Mar 01 22:02:36 2019 +0100
+++ b/Workspace.st	Tue Mar 12 16:37:29 2019 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
@@ -1370,8 +1372,8 @@
 
 keyPress:key x:x y:y
     <resource: #keyboard (#DoIt #InspectIt #PrintIt #ReplaceIt
-			  #BrowseIt #ImplementorsOfIt #ExpandAbbreviation
-			  #CommentSelection #UncommentSelection)>
+                          #BrowseIt #ImplementorsOfIt #ExpandAbbreviation
+                          #CommentSelection #UncommentSelection)>
 
     (key == #DoIt)      ifTrue:[self doIt. ^ self].
     (key == #InspectIt) ifTrue:[self inspectIt. ^ self].
@@ -1383,9 +1385,12 @@
     (key == #CommentSelection)    ifTrue:[self commentSelection. ^ self].
     (key == #UncommentSelection)  ifTrue:[self uncommentSelection. ^ self].
 
+    (key == #CtrlQ)  ifTrue:[self basicInspectIt. ^ self].
+
     super keyPress:key x:x y:y
 
     "Modified: / 08-11-2007 / 11:29:45 / cg"
+    "Modified: / 12-03-2019 / 16:35:44 / Claus Gittinger"
 ! !
 
 !Workspace methodsFor:'executing'!
@@ -1518,6 +1523,18 @@
 
     "Modified: / 24-06-2013 / 15:31:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified (format): / 01-11-2017 / 11:18:31 / cg"
+!
+
+withValueOfSelectionDo:aBlock
+    "helper for doIt, printIt, inspectIt, etc.
+     Evaluate the selection and, if all went well, evaluate the argument,
+     aBlock with the value."
+
+    self
+        do:(self selectionOrTextOfCursorLine)
+        withValueDo:aBlock
+
+    "Created: / 12-03-2019 / 16:31:47 / Claus Gittinger"
 ! !
 
 !Workspace methodsFor:'initialization & release'!
@@ -1576,21 +1593,29 @@
 
 !Workspace methodsFor:'menu & menu actions'!
 
+basicInspectIt
+    "user selected 'basicInspectIt' from menu; use doIt to evaluate the code
+     and start a basicInspector on the result"
+
+    self withValueOfSelectionDo:#basicInspect
+
+    "Created: / 12-03-2019 / 16:29:21 / Claus Gittinger"
+!
+
 browseClass
     "user selected 'browseClass' from menu; evaluate the code
      and open a browser on the resulting class (if it evaluates to one)"
 
-    ^ self
-	do:(self selectionAsString)
-	withValueDo:[:result |
-	    result isBehavior ifTrue:[
-		result browserClass openInClass:result selector:nil
-	    ] ifFalse:[
-		self warn:'Selection does not evaluate to a class'
-	    ]
-	].
-
-    "Modified: / 26.9.2001 / 17:37:35 / cg"
+    self withValueOfSelectionDo:[:result |
+        result isBehavior ifTrue:[
+            result browserClass openInClass:result selector:nil
+        ] ifFalse:[
+            self warn:'Selection does not evaluate to a class'
+        ]
+    ].
+
+    "Modified: / 26-09-2001 / 17:37:35 / cg"
+    "Modified (format): / 12-03-2019 / 16:33:29 / Claus Gittinger"
 !
 
 browseClassesContainingInName
@@ -1756,7 +1781,7 @@
 
     "/ check for expr >> selector...
     "/ i.e. given a whoString
-    idx := codeToEvaluate indexOf:'»'.
+    idx := codeToEvaluate indexOf:'»'.
     idx ~~ 0 ifTrue:[
         possibleSelectorString := codeToEvaluate copyFrom:idx+1.
         codeToEvaluate := codeToEvaluate copyTo:idx-1.
@@ -1867,13 +1892,12 @@
     "user selected 'browseItsClass' from menu; evaluate the code
      and open a browser on the results class"
 
-    ^ self
-	do:(self selectionAsString)
-	withValueDo:[:result |
-			result class browserClass openInClass:result class selector:nil
-		    ]
-
-    "Modified: / 26.9.2001 / 17:38:06 / cg"
+    self withValueOfSelectionDo:[:result |
+        result class browserClass openInClass:result class selector:nil
+    ]
+
+    "Modified: / 26-09-2001 / 17:38:06 / cg"
+    "Modified (format): / 12-03-2019 / 16:33:22 / Claus Gittinger"
 !
 
 browseMethodsContainingInName
@@ -2127,18 +2151,17 @@
     "user selected 'doIt' from menu; show a wait-cursor, evaluate the code
      and finally restore cursor; return result of evaluation"
 
-    ^ self
-	do:(self selectionOrTextOfCursorLine)
-	withValueDo:nil
-
-    "Modified: / 16.5.1998 / 16:45:01 / cg"
+    self withValueOfSelectionDo:[] "/ do nothing with it
+
+    "Modified: / 16-05-1998 / 16:45:01 / cg"
+    "Modified: / 12-03-2019 / 16:33:52 / Claus Gittinger"
 !
 
 editMenu
     "return my popUpMenu; that's the superclasses menu
      PLUS st-evaluation items: doIt, printIt and inspectIt."
 
-    <resource: #keyboard (#DoIt #PrintIt #InspectIt
+    <resource: #keyboard (#DoIt #PrintIt #InspectIt 
                           #CommentSelection #UncommentSelection
                           #BrowseIt #ImplementorsOfIt
                          )>
@@ -2206,6 +2229,7 @@
             subsub
                 addItemList:#(
                     ('Inspect Instances'       inspectInstances          nil)       
+                    ('Basic Inspect'           basicInspectIt            CtrlQ)       
                 )
                 resources:resources  
 
@@ -2327,11 +2351,11 @@
             lNr := self cursorLine.
             line := self listAt:lNr.
             line isEmptyOrNil ifTrue:[
-                m disableAll:#(printIt doIt inspectIt browseIt)
+                m disableAll:#(printIt doIt inspectIt browseIt basicInspectIt inspectInstances)
             ].
         ].
         doItAction isNil ifTrue:[
-            m disableAll:#(printIt doIt inspectIt timeIt spyOnIt)
+            m disableAll:#(printIt doIt inspectIt timeIt spyOnIt basicInspectIt inspectInstances)
         ].
         self isReadOnly ifTrue:[
             m disable:#printIt
@@ -2342,6 +2366,7 @@
 
     "Modified: / 22-04-1998 / 21:49:06 / ca"
     "Modified: / 20-12-2011 / 11:22:20 / cg"
+    "Modified: / 12-03-2019 / 16:36:22 / Claus Gittinger"
 !
 
 inspectInstances
@@ -2364,17 +2389,20 @@
 
 inspectIt
     "user selected 'inspectIt' from menu; use doIt to evaluate the code
-     and start an inspector on the result"
+     and start an inspector (or basicInspector if Shift pressed) on the result"
 
     |shifted|
 
     shifted := self sensor shiftDown.
 
-    ^ self
-	do:(self selectionOrTextOfCursorLine)
-	withValueDo:[:result | shifted ifTrue:[result basicInspect] ifFalse:[result inspect] ]
-
-    "Modified: / 16.5.1998 / 16:44:56 / cg"
+    self withValueOfSelectionDo:[:result | 
+        shifted 
+            ifTrue:[result basicInspect] 
+            ifFalse:[result inspect] 
+    ]
+
+    "Modified: / 16-05-1998 / 16:44:56 / cg"
+    "Modified: / 12-03-2019 / 16:34:06 / Claus Gittinger"
 !
 
 printIt
@@ -2389,8 +2417,7 @@
     self
         undoableDo:[
             self
-                do:(self selectionOrTextOfCursorLine)
-                withValueDo:[:result |
+                withValueOfSelectionDo:[:result |
                     |s printer lang|
 
                     self cursorLine:selectionEndLine col:(selectionEndCol + 1).
@@ -2432,6 +2459,7 @@
         info:'PrintIt'
 
     "Modified: / 08-03-2012 / 16:14:34 / cg"
+    "Modified: / 12-03-2019 / 16:34:16 / Claus Gittinger"
 !
 
 profileIt
@@ -2453,8 +2481,7 @@
     self
         undoableDo:[
             self
-                do:(self selectionOrTextOfCursorLine)
-                withValueDo:[:result |
+                withValueOfSelectionDo:[:result |
                     self replaceSelectionBy:(result displayString "printString")
                 ].
                 undoSupport actionInfo:'ReplaceIt'.
@@ -2462,6 +2489,7 @@
         info:'ReplaceIt'
 
     "Created: / 08-11-2007 / 11:31:54 / cg"
+    "Modified: / 12-03-2019 / 16:34:23 / Claus Gittinger"
 !
 
 spyOnIt