*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Mon, 06 Mar 2006 09:46:46 +0100
changeset 3272 0e5fdbce3724
parent 3271 41c18a8008b7
child 3273 4694bbb6498f
*** empty log message ***
Workspace.st
--- a/Workspace.st	Mon Mar 06 09:46:31 2006 +0100
+++ b/Workspace.st	Mon Mar 06 09:46:46 2006 +0100
@@ -359,6 +359,22 @@
     super selectAll
 !
 
+selectionOrTextOfCursorLine
+    |sel lNr line|
+
+    sel := self selectionAsString.
+    sel notNil ifTrue:[^ sel].
+
+    lNr := self cursorLine.
+    line := self listAt:lNr.
+    line notEmptyOrNil ifTrue:[
+        self selectLine:lNr.
+        ^ line
+    ].
+
+    ^ nil
+!
+
 simulatedSelf:anObject
     "define what self is in an evaluation"
 
@@ -973,7 +989,7 @@
      and open a browser on the resulting class (if it evaluates to one)"
 
     ^ self 
-        do:(self selection) 
+        do:(self selectionAsString) 
         withValueDo:[:result | result isBehavior ifTrue:[
                                   result browserClass openInClass:result selector:nil
                                ] ifFalse:[
@@ -1016,7 +1032,7 @@
 
     |codeToEvaluate idx selector|
 
-    codeToEvaluate := self selection asString withoutSeparators.
+    codeToEvaluate := self selectionOrTextOfCursorLine withoutSeparators.
     idx := codeToEvaluate indexOfSubCollection:'>>'.
     idx ~~ 0 ifTrue:[
         selector := (codeToEvaluate copyFrom:idx+2) withoutSeparators string.
@@ -1043,7 +1059,7 @@
      and open a browser on the results class"
 
     ^ self 
-        do:(self selection) 
+        do:(self selectionAsString) 
         withValueDo:[:result | 
                         result class browserClass openInClass:result class selector:nil
                     ]
@@ -1091,7 +1107,7 @@
      and finally restore cursor; return result of evaluation"
 
     ^ self 
-        do:(self selection) 
+        do:(self selectionOrTextOfCursorLine) 
         withValueDo:[:result | ]
 
     "Modified: / 16.5.1998 / 16:45:01 / cg"
@@ -1147,8 +1163,8 @@
         ].
 
         self hasSelection ifFalse:[
-            sub disableAll:#(browseIt browseImplementorsOfIt browseSendersOfIt browseReferencesToIt timeIt spyOnIt
-                              commentSelection uncommentSelection ) 
+            sub disableAll:#(browseImplementorsOfIt browseSendersOfIt browseReferencesToIt timeIt spyOnIt
+                             commentSelection uncommentSelection ) 
         ] ifTrue:[
             s := self selectionAsString.
             s2 := Parser selectorInExpression:s.
@@ -1191,8 +1207,14 @@
             
         ].
 
-        self hasSelection ifFalse:[
-            m disableAll:#(printIt doIt inspectIt) 
+        (self selectionOrTextOfCursorLine) isNil ifTrue:[
+            |lNr line|
+
+            lNr := self cursorLine.
+            line := self listAt:lNr.
+            line isEmptyOrNil ifTrue:[
+                m disableAll:#(printIt doIt inspectIt browseIt) 
+            ].
         ].
         self isReadOnly ifTrue:[
             m disable:#printIt 
@@ -1214,7 +1236,7 @@
     shifted := self sensor shiftDown.
 
     ^ self 
-        do:(self selection) 
+        do:(self selectionOrTextOfCursorLine) 
         withValueDo:[:result | shifted ifTrue:[result basicInspect] ifFalse:[result inspect] ]
 
     "Modified: / 16.5.1998 / 16:44:56 / cg"
@@ -1229,7 +1251,7 @@
         self beep
     ] ifFalse:[ 
         self 
-            do:(self selection) 
+            do:(self selectionOrTextOfCursorLine) 
             withValueDo:[:result | 
                 self cursorLine:selectionEndLine col:(selectionEndCol + 1).
                 self insertSelectedStringAtCursor:(result displayString "printString")
@@ -1245,7 +1267,7 @@
 
     |code|
 
-    code := 'MessageTally spyOn:[' , self selection asString string, ']'.
+    code := 'MessageTally spyOn:[' , self selectionAsString, ']'.
     self do:code withValueDo:[:result | ]
 
     "Modified: / 22.4.1998 / 22:03:53 / ca"
@@ -1257,7 +1279,7 @@
 
     |code|
 
-    code := '|t| t := Time millisecondsToRun:[' , self selection asString string, '].
+    code := '|t| t := Time millisecondsToRun:[' , self selectionAsString, '].
 
     Transcript showCR:''execution time: '' , t printString , '' ms''.'.
     self do:code withValueDo:[:result | ]
@@ -1274,5 +1296,5 @@
 !Workspace class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.154 2006-02-21 12:17:30 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.155 2006-03-06 08:46:46 cg Exp $'
 ! !