preps for formatting;
disable #explain in menu, if there is no explainAction.
--- a/CodeView.st Tue Jul 28 21:41:23 1998 +0200
+++ b/CodeView.st Wed Jul 29 17:57:20 1998 +0200
@@ -11,7 +11,7 @@
"
Workspace subclass:#CodeView
- instanceVariableNames:'explainAction'
+ instanceVariableNames:'explainAction formatAction'
classVariableNames:''
poolDictionaries:''
category:'Interface-Workspace'
@@ -80,6 +80,14 @@
"set the action to be performed on explain"
explainAction := aBlock
+!
+
+formatAction:aBlock
+ "set the action to be performed on format"
+
+ formatAction := aBlock
+
+ "Created: / 17.2.1998 / 17:05:13 / cg"
! !
!CodeView methodsFor:'event handling'!
@@ -88,8 +96,9 @@
"catch keyboard shortcuts"
<resource: #keyboard (#Explain #Help
- #CommentSelection #UncommentSelection)>
+ #CommentSelection #UncommentSelection)>
+ (key == #Format) ifTrue:[^ self format].
(key == #Explain) ifTrue:[^ self explain].
(key == #Help) ifTrue:[^ self explain].
(key == #CommentSelection) ifTrue:[^ self commentSelection].
@@ -97,7 +106,7 @@
super keyPress:key x:x y:y
- "Modified: 9.1.1997 / 12:14:00 / cg"
+ "Modified: / 17.2.1998 / 17:05:23 / cg"
! !
!CodeView methodsFor:'menu & menu actions'!
@@ -169,14 +178,15 @@
accelerators:#(nil Explain)
after:#gotoLine.
- self hasSelection ifFalse:[
+ (self hasSelection not
+ or:[explainAction isNil]) ifTrue:[
sub disable:#explain
].
].
].
^ m.
- "Modified: / 7.5.1998 / 02:48:01 / cg"
+ "Modified: / 29.7.1998 / 16:14:52 / cg"
!
explain
@@ -192,10 +202,27 @@
explainAction value:(self contents) value:(text asString)
]
]
+!
+
+format
+ "format action;
+ evaluate the formatBlock passing whole contents as argument."
+
+ |text|
+
+ formatAction notNil ifTrue:[
+ text := self contents.
+ text notNil ifTrue:[
+ formatAction value:(text asString)
+ ]
+ ]
+
+ "Created: / 17.2.1998 / 17:06:18 / cg"
+ "Modified: / 17.2.1998 / 18:25:33 / cg"
! !
!CodeView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/CodeView.st,v 1.39 1998-05-07 17:44:37 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/CodeView.st,v 1.40 1998-07-29 15:57:20 cg Exp $'
! !