1 Delta define: #CommentOutliner as: (
\r
2 (Class subclassOf: 'MirrorOutliner[Mirror]' instanceVariables: 'codeView <CodeView>')) !
\r
4 (Delta mirrorFor: #CommentOutliner) revision: '$Revision: 1.5 $'!
\r
6 (Delta mirrorFor: #CommentOutliner) group: 'outliner'!
\r
8 (Delta mirrorFor: #CommentOutliner)
\r
10 '(c) 1995-1997 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
\r
11 Use and distribution of this software is subject to the terms of the attached source license.'!
\r
13 ! (Delta mirrorFor: #CommentOutliner) methodsFor: 'private' !
\r
16 buildBody ^ <Visual>
\r
20 self codeView: (self buildCodeViewGetModel: [ self commentAsGlyphs ]
\r
21 setModelOnSuccess: [ :blk <[]> | self storeAndOnSuccess: blk ]).
\r
22 result := self editorBorderFor: self codeView.
\r
23 self addLicenseButton. "Hack!!"
\r
27 buildClosedHeader ^ <Visual>
\r
29 ^(StringGlyph for: self closedHeaderTitle painter: self sectionPainter) asVisual!
\r
31 buildOpenHeader ^ <Visual>
\r
33 ^(StringGlyph for: self openHeaderTitle painter: self sectionPainter) asVisual!
\r
35 closedHeaderTitle ^ <Str>
\r
38 s := self comment readStream upTo: Character cr.
\r
39 (s isEmpty or: [ (s includes: $.) not ])
\r
40 ifTrue: [ ^self openHeaderTitle ].
\r
42 ('*copyright*' platformMatch: s) "Temporary solution for Dave :-)"
\r
43 ifTrue: [ ^self openHeaderTitle ].
\r
45 ^(s readStream upTo: $.), '.'
\r
48 codeView ^<CodeView>
\r
52 codeView: cv <CodeView>
\r
58 ^self mirror comment!
\r
62 self mirror comment: s!
\r
64 commentAsGlyphs ^ <CharGlyphs>
\r
66 ^self standardTextForString: self mirror comment painter:self codePainter.!
\r
68 openHeaderTitle ^ <Str>
\r
72 storeAndOnSuccess: blk <[]>
\r
74 self comment: (self charGlyphModelAsString: self codeView).
\r
75 self updateClosedHeader.
\r
80 ! (Delta mirrorFor: #CommentOutliner) methodsFor: 'menus' !
\r
90 add: (MenuAction new
\r
91 name: '&Remove comment';
\r
92 active: [ self comment isEmpty not ];
\r
93 action: [ self removeComment ])! !
\r
95 ! (Delta mirrorFor: #CommentOutliner) methodsFor: 'dependencies' !
\r
98 update: aspect <Object> with: value <Object>
\r
100 self inSessionProcessDo: [
\r
102 ifTrue: [ self updateClosedHeader.
\r
103 self codeView notNil
\r
104 ifTrue: [ self codeView model = self commentAsGlyphs
\r
105 ifFalse: [ self codeView model: self commentAsGlyphs ] ] ] ]
\r
108 ! (Delta mirrorFor: #CommentOutliner) methodsFor: 'control' !
\r
116 self updateClosedHeader.
\r
118 self open: false ].
\r
120 self codeView isNil
\r
122 ifFalse: [ self codeView closeRequest: removeBlk ]
\r
125 ! (Delta mirrorFor: #CommentOutliner) methodsFor: 'private-licensing' !
\r
130 | glyphs <OrderedCollection[SeqCltn[Glyph]]> i <Integer> j <Integer> |
\r
132 ('*Sun Microsystems, Inc. ALL RIGHTS RESERVED*' match: self mirror comment)
\r
133 ifFalse:[^self]. "Only insert license link for Sun copyrighted code"
\r
134 glyphs := OrderedCollection[SeqCltn[Glyph]] new.
\r
135 "Add a cr so the license button is on the last line by itself"
\r
136 glyphs add: (OrderedCollection[Glyph] with:
\r
137 (self codeView charGlyphFor: Character cr)).
\r
139 OrderedCollection[Glyph] new
\r
140 add: self licenseButton;
\r
142 i := self codeView linearIndexFor: self codeView endSpot.
\r
143 i = 1 ifTrue:[ j := 1] ifFalse:[ j := i - 1].
\r
144 self codeView linearSelection: j ,, i.
\r
145 self codeView replaceSelectionWithGlyphs: glyphs.
\r
146 self codeView hasBeenChanged: false.
\r
147 self adjustCodeViewFrame.!
\r
149 adjustCodeViewFrame
\r
153 frame := Frame coerce: self codeView visual parent else: [ nil ].
\r
154 frame notNil ifTrue: [ frame border: self defaultEditorBorder ]!
\r
156 licenseButton ^ <Button>
\r
161 blockToEvaluateFor: 'Smalltalk license'
\r
162 receiver: Smalltalk
\r
163 ifError: [ :err <Str> :pos <Int> |
\r
164 Transcript cr; show: 'Error in CommentOutliner.'; cr.
\r
166 ^Button labeled: 'View Source License' action: [ :b <Button> | blk fork ].! !
\r