CodeView.st
changeset 419 2bd5f73fffd2
parent 365 cb7a40a691f3
child 430 022b667e0d70
--- a/CodeView.st	Tue Feb 27 15:31:51 1996 +0100
+++ b/CodeView.st	Tue Feb 27 15:35:33 1996 +0100
@@ -11,10 +11,10 @@
 "
 
 Workspace subclass:#CodeView
-	 instanceVariableNames:'explainAction'
-	 classVariableNames:''
-	 poolDictionaries:''
-	 category:'Interface-Workspace'
+	instanceVariableNames:'explainAction'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Interface-Workspace'
 !
 
 !CodeView class methodsFor:'documentation'!
@@ -36,21 +36,26 @@
 documentation
 "
     a view for text which is known to be smalltalk code. 
-    It adds explain to the menu, and defines another action: 
+    It adds 'explain' to the menu, and defines another action: 
       explainAction to be performed for explain.
 
     This action is to be defined by the user of this view 
     (i.e. ususally the owning browser)
 
+    In addition, uncomment/comment are added to the controlMenu.
+    These are smalltalk specific - if you plan to edit other language code,
+    you need a different kind of CodeView for that.
+
     If used with a model, accept sends the changeMsg to it (as defined in EditTextView).
-    (however, it is possible to define moth changeMsg and acceptAction)
+    (however, it is possible to define both changeMsg and acceptAction)
 
+    See how doIt/printIt/inspectIt are handled in the superclass: Workspace.
 
     Caveat:
-	in this version, CodeView does not yet support MVC setups for doIt
-	and explain.
-	If required, simulate this by setting the doItAction and
-	explainAction, to notify the model manually about whats going on.
+        in this version, CodeView does not yet support MVC setups for doIt
+        and explain.
+        If required, simulate this by setting the doItAction and
+        explainAction, to notify the model manually about whats going on.
 "
 ! !
 
@@ -111,7 +116,48 @@
     super keyPress:key x:x y:y
 ! !
 
-!CodeView methodsFor:'initialization'!
+!CodeView methodsFor:'menu & menu actions'!
+
+accept
+    "redefined accept action;
+     save cursor and selection to allow restore in case of an error
+     (we are typically compiling here ... and the compiler may show
+     errors by highlighting them)"
+
+    codeStartPosition := 1.
+    [
+	AbortSignal handle:[:ex |
+	    self cursor:Cursor normal.
+	    "redraw selection in normal color"
+	    self selectFromLine:selectionStartLine col:selectionStartCol 
+			 toLine:selectionEndLine col:selectionEndCol.
+	    ex return
+	] do:[
+	    super accept.
+	]
+    ] valueNowOrOnUnwindDo:[
+	self unselect.
+    ]
+!
+
+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|
+
+    (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
+	self commentFrom:selectionStartLine to:selectionEndLine-1
+    ] ifFalse:[
+	self insert:$" atLine:selectionStartLine col:selectionStartCol.
+	e := selectionEndCol + 1.
+	selectionStartLine == selectionEndLine ifTrue:[e := e + 1].
+	self insert:$" atLine:selectionEndLine col:e.
+	self selectFromLine:selectionStartLine col:selectionStartCol
+		     toLine:selectionEndLine col:e.
+    ]
+!
 
 editMenu
     "return the popUpMenu;
@@ -157,49 +203,6 @@
 	].
     ].
     ^ m.
-! !
-
-!CodeView methodsFor:'user actions'!
-
-accept
-    "redefined accept action;
-     save cursor and selection to allow restore in case of an error
-     (we are typically compiling here ... and the compiler may show
-     errors by highlighting them)"
-
-    codeStartPosition := 1.
-    [
-	AbortSignal handle:[:ex |
-	    self cursor:Cursor normal.
-	    "redraw selection in normal color"
-	    self selectFromLine:selectionStartLine col:selectionStartCol 
-			 toLine:selectionEndLine col:selectionEndCol.
-	    ex return
-	] do:[
-	    super accept.
-	]
-    ] valueNowOrOnUnwindDo:[
-	self unselect.
-    ]
-!
-
-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|
-
-    (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
-	self commentFrom:selectionStartLine to:selectionEndLine-1
-    ] ifFalse:[
-	self insert:$" atLine:selectionStartLine col:selectionStartCol.
-	e := selectionEndCol + 1.
-	selectionStartLine == selectionEndLine ifTrue:[e := e + 1].
-	self insert:$" atLine:selectionEndLine col:e.
-	self selectFromLine:selectionStartLine col:selectionStartCol
-		     toLine:selectionEndLine col:e.
-    ]
 !
 
 explain
@@ -242,5 +245,5 @@
 !CodeView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/CodeView.st,v 1.25 1996-02-19 22:59:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/CodeView.st,v 1.26 1996-02-27 14:35:33 cg Exp $'
 ! !