CodeView.st
changeset 1396 4e019d312d6f
parent 1293 c0806b73dc48
child 1516 677fbbd9b32f
--- a/CodeView.st	Tue Nov 11 14:52:24 1997 +0100
+++ b/CodeView.st	Tue Nov 11 14:52:51 1997 +0100
@@ -11,7 +11,7 @@
 "
 
 Workspace subclass:#CodeView
-	instanceVariableNames:'explainAction commentStrings'
+	instanceVariableNames:'explainAction'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-Workspace'
@@ -76,165 +76,12 @@
 
 !CodeView methodsFor:'accessing'!
 
-commentStrings:anArrayOfCommentStrings
-    "define the comment strings"
-
-    commentStrings := anArrayOfCommentStrings
-
-    "Created: 7.1.1997 / 20:25:06 / cg"
-!
-
 explainAction:aBlock
     "set the action to be performed on explain"
 
     explainAction := aBlock
 ! !
 
-!CodeView methodsFor:'editing'!
-
-commentFrom:line1 to:line2
-    "convenient function to comment out a block.
-     All lines from line1 to line2 get an end-of-line comment
-     in the first col."
-
-    |eolComment opening closing|
-
-    eolComment := commentStrings at:1.
-    eolComment isNil ifTrue:[
-        opening := (commentStrings at:2) at:1.
-        closing := (commentStrings at:2) at:2.
-        (opening isNil or:[closing isNil]) ifTrue:[^ self].
-    ].
-
-    line1 to:line2 do:[:lineNr |
-        |l|
-
-        l := self listAt:lineNr.
-        l isNil ifTrue:[l := ''].
-        eolComment notNil ifTrue:[
-            l := eolComment , l
-        ] ifFalse:[
-            l := opening , l , closing
-        ].
-        self at:lineNr put:l
-    ].
-    self textChanged.
-
-    "Modified: 7.1.1997 / 20:15:06 / cg"
-!
-
-commentSelection
-    "convenient function to comment out a block.
-     All lines from line1 to line2 get an end-of-line comment
-     in the first col."
-
-    |e commentPair opening closing|
-
-    selectionStartLine notNil ifTrue:[
-        (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
-            self commentFrom:selectionStartLine to:selectionEndLine-1
-        ] ifFalse:[
-            commentPair := commentStrings at:2.
-            opening := commentPair at:1.
-            closing := commentPair at:2.
-            (opening isNil or:[closing isNil]) ifTrue:[^ self].
-
-            e := selectionEndCol.
-
-            self insertString:closing atLine:selectionEndLine col:e+1.
-            self insertString:opening atLine:selectionStartLine col:selectionStartCol.
-
-            selectionStartLine == selectionEndLine ifTrue:[e := e + opening size].
-            self selectFromLine:selectionStartLine col:selectionStartCol
-                         toLine:selectionEndLine col:e+closing size.
-        ]
-    ]
-
-    "Modified: 7.1.1997 / 20:13:25 / cg"
-!
-
-uncommentFrom:line1 to:line2
-    "convenient function to comment out a block.
-     All lines from line1 to line2 get an end-of-line comment
-     in the first col."
-
-    |eolComment opening closing rest|
-
-    eolComment := commentStrings at:1.
-    eolComment isNil ifTrue:[
-        opening := (commentStrings at:2) at:1.
-        closing := (commentStrings at:2) at:2.
-        (opening isNil or:[closing isNil]) ifTrue:[^ self].
-    ] ifFalse:[
-        rest := eolComment size + 1.
-    ].
-
-    line1 to:line2 do:[:lineNr |
-        |l|
-
-        l := self listAt:lineNr.
-        l notNil ifTrue:[
-            eolComment notNil ifTrue:[
-                (l startsWith:eolComment) ifTrue:[
-                    l := l copyFrom:rest
-                ]
-            ] ifFalse:[
-                ((l startsWith:opening)
-                and:[l endsWith:closing]) ifTrue:[
-                    l := l copyFrom:opening size + 1.
-                    l := l copyWithoutLast:closing size.
-                ]
-            ].
-            self at:lineNr put:l
-        ]
-    ].
-    self textChanged.
-
-    "Modified: 7.1.1997 / 20:17:44 / cg"
-!
-
-uncommentSelection
-    "convenient function to comment out a block.
-     All lines from line1 to line2 get an end-of-line comment
-     in the first col."
-
-    |e commentPair opening closing sz1 sz2|
-
-    selectionStartLine notNil ifTrue:[
-        (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
-            self uncommentFrom:selectionStartLine to:selectionEndLine-1
-        ] ifFalse:[
-            commentPair := commentStrings at:2.
-            opening := commentPair at:1.
-            closing := commentPair at:2.
-            (opening isNil or:[closing isNil]) ifTrue:[^ self].
-
-            sz1 := opening size.
-            sz2 := closing size.
-
-            ((self 
-                stringAtLine:selectionStartLine 
-                from:selectionStartCol
-                to:selectionStartCol+sz1 - 1) = opening
-            and:[(self 
-                stringAtLine:selectionEndLine 
-                from:selectionEndCol - sz2 + 1
-                to:selectionEndCol) = closing ]) ifTrue:[
-
-                self deleteCharsAtLine:selectionEndLine fromCol:selectionEndCol-sz2+1 toCol:selectionEndCol.
-                self deleteCharsAtLine:selectionStartLine fromCol:selectionStartCol toCol:selectionStartCol+sz1-1.
-
-                e := selectionEndCol - sz2.
-                selectionStartLine == selectionEndLine ifTrue:[e := e - sz1].
-                self selectFromLine:selectionStartLine col:selectionStartCol
-                             toLine:selectionEndLine col:e.
-            ]
-        ]
-    ]
-
-    "Modified: 7.1.1997 / 20:13:32 / cg"
-! !
-
 !CodeView methodsFor:'event handling'!
 
 keyPress:key x:x y:y
@@ -253,17 +100,6 @@
     "Modified: 9.1.1997 / 12:14:00 / cg"
 ! !
 
-!CodeView methodsFor:'initialization'!
-
-initialize
-    super initialize.
-
-    commentStrings := #('"/'
-                        ('"' '"'))
-
-    "Created: 7.1.1997 / 19:47:13 / cg"
-! !
-
 !CodeView methodsFor:'menu & menu actions'!
 
 accept
@@ -308,17 +144,7 @@
 
     m := super editMenu.
 
-    self sensor ctrlDown ifTrue:[
-        m addLabels:(resources array:#('-' 'commentIt' 'uncommentIt'))
-          selectors:#(nil commentSelection uncommentSelection)
-          accelerators:#(nil CommentSelection UncommentSelection)
-          after:#again.
-
-        self hasSelection ifFalse:[
-            m disableAll:#(commentSelection uncommentSelection) 
-        ].
-    ] ifFalse:[
-
+    self sensor ctrlDown ifFalse:[
         "
          codeViews do support #accept
          ... add it after #inspectIt
@@ -350,7 +176,7 @@
     ].
     ^ m.
 
-    "Modified: 1.8.1997 / 21:47:55 / cg"
+    "Modified: / 9.11.1997 / 01:07:03 / cg"
 !
 
 explain
@@ -371,5 +197,5 @@
 !CodeView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/CodeView.st,v 1.37 1997-08-01 19:48:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/CodeView.st,v 1.38 1997-11-11 13:52:51 cg Exp $'
 ! !