author | Claus Gittinger <cg@exept.de> |
Fri, 24 Apr 2020 12:05:44 +0200 | |
changeset 6847 | 22dc78cb5436 |
parent 6830 | 1c99812db765 |
permissions | -rw-r--r-- |
6668 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
59 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2259 | 14 |
"{ Package: 'stx:libwidg' }" |
15 |
||
5246 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
EditTextView subclass:#TextCollector |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
19 |
instanceVariableNames:'entryStream lineLimit destroyAction outstandingLines |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
20 |
outstandingLine flushBlock flushPending inFlush collecting |
3710 | 21 |
timeDelay access currentEmphasis alwaysAppendAtEnd collectSize |
5137 | 22 |
autoRaise' |
4365 | 23 |
classVariableNames:'TranscriptQuerySignal DebugSendersOfMessagePattern |
5455 | 24 |
TraceSendersOfMessagePattern TimestampMessages DefaultLineLimit |
5301 | 25 |
DefaultTimeDelay DefaultCollectSize' |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
26 |
poolDictionaries:'' |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
27 |
category:'Views-Text' |
0 | 28 |
! |
29 |
||
928 | 30 |
!TextCollector class methodsFor:'documentation'! |
15 | 31 |
|
34
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
32 |
copyright |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
33 |
" |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
34 |
COPYRIGHT (c) 1989 by Claus Gittinger |
59 | 35 |
All Rights Reserved |
34
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
36 |
|
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
37 |
This software is furnished under a license and may be used |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
38 |
only in accordance with the terms of that license and with the |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
39 |
inclusion of the above copyright notice. This software may not |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
40 |
be provided or otherwise made available to, or used by, any |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
41 |
other person. No title to or ownership of the software is |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
42 |
hereby transferred. |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
43 |
" |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
44 |
! |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
45 |
|
15 | 46 |
documentation |
47 |
" |
|
34
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
48 |
a view for editable text, which also understands some stream messages. |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
49 |
Instances of this view can take the place of a stream and display the |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
50 |
received text. |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
51 |
Its main use in the system is the Transcript, but it can also be used for |
110 | 52 |
things like trace-windows, errorLogs etc. |
4650 | 53 |
It is also inherited by TerminalView, which especially uses the buffering and |
54 |
delayed output features for high performance output (compare to a windows console). |
|
0 | 55 |
|
60 | 56 |
If collecting is turned on, a textcollector will not immediately display |
34
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
57 |
entered text, but wait for some short time (timeDelay) and collect incoming |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
58 |
data - finally updating the whole chunk in one piece. |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
59 |
This helps slow display devices, which would otherwise scroll a lot. |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
60 |
(on fast displays this is less of a problem). |
15 | 61 |
|
60 | 62 |
The total number of lines kept is controlled by lineLimit, if more lines |
63 |
than this limit are added at the bottom, the textcollector will forget lines |
|
4650 | 64 |
at the top. You can set linelimit to nil (i.e. no limit), but you may need a lot |
34
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
65 |
of memory then ... |
77 | 66 |
|
586 | 67 |
[StyleSheet paramters (transcript only):] |
68 |
||
69 |
transcriptForegroundColor defaults to textForegroundColor |
|
70 |
transcriptBackgroundColor' defaults to textBackgroundColor. |
|
77 | 71 |
|
586 | 72 |
transcriptCursorForegroundColor |
73 |
transcriptCursorBackgroundColor |
|
77 | 74 |
|
586 | 75 |
[author:] |
76 |
Claus Gittinger |
|
77 |
||
78 |
[see also:] |
|
79 |
CodeView EditTextView |
|
80 |
ActorStream |
|
15 | 81 |
" |
82 |
! ! |
|
0 | 83 |
|
928 | 84 |
!TextCollector class methodsFor:'instance creation'! |
0 | 85 |
|
2025
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
86 |
initialize |
5534 | 87 |
TranscriptQuerySignal isNil ifTrue:[ |
88 |
TranscriptQuerySignal := QuerySignal new. |
|
89 |
] |
|
2025
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
90 |
! |
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
91 |
|
0 | 92 |
newTranscript |
778
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
93 |
"create and open a new transcript. |
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
94 |
This is a leftOver method from times were the Launcher & Transcript |
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
95 |
were two different views. It is no longer recommended." |
110 | 96 |
|
3852
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
97 |
^ self newTranscript:#Transcript |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
98 |
|
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
99 |
" |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
100 |
TextCollector newTranscript. |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
101 |
Transcript lineLimit:3000. |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
102 |
" |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
103 |
|
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
104 |
"Modified: 17.2.1997 / 18:20:27 / cg" |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
105 |
! |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
106 |
|
5609 | 107 |
newTranscript:nameSymbol |
5301 | 108 |
"create and open a new transcript, unless one already exists by that name. |
109 |
The transcript is remembered in a global by that name. |
|
3852
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
110 |
This is a leftOver method from times were the Launcher & Transcript |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
111 |
were two different views. It is no longer recommended." |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
112 |
|
1900
d334ab9d32d5
removed minExtent - let topView decide.
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
113 |
|topView transcript defSz f v lines cols| |
0 | 114 |
|
5609 | 115 |
transcript := Smalltalk at:nameSymbol. |
4476 | 116 |
(transcript isTextView and:[transcript isOpen and:[transcript device == Screen current]]) ifTrue:[ |
117 |
"if there is already an open Transcript on the same device, |
|
118 |
do not open an additional one. |
|
119 |
expecco StandardLibrary <= 2.0.0.3 checked for Transcript>>#isStream and |
|
120 |
tries to opens a new Transcript window for each new Transcribe with expecco >=2.4" |
|
121 |
^ transcript. |
|
122 |
]. |
|
123 |
||
5609 | 124 |
topView := StandardSystemView label:nameSymbol "minExtent:(100 @ 100)". |
0 | 125 |
|
60 | 126 |
v := HVScrollableView for:self miniScrollerH:true miniScrollerV:false in:topView. |
0 | 127 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
128 |
transcript := v scrolledView. |
|
129 |
"transcript partialLines:false." |
|
130 |
||
131 |
f := transcript font. |
|
60 | 132 |
|
133 |
" |
|
134 |
should add the height of the frame & scrollbars to be exact ... |
|
135 |
" |
|
1900
d334ab9d32d5
removed minExtent - let topView decide.
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
136 |
defSz := self defaultTranscriptSize. |
d334ab9d32d5
removed minExtent - let topView decide.
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
137 |
cols := defSz x. |
d334ab9d32d5
removed minExtent - let topView decide.
Claus Gittinger <cg@exept.de>
parents:
1822
diff
changeset
|
138 |
lines := defSz y. |
60 | 139 |
topView extent:(((f widthOf:'x') * cols) @ (f height * lines)). |
0 | 140 |
|
5609 | 141 |
transcript beTranscript:nameSymbol. |
59 | 142 |
|
80 | 143 |
" |
144 |
run it at a slightly higher prio, to allow for |
|
145 |
delayed buffered updates to be performed |
|
146 |
" |
|
147 |
topView openWithPriority:(Processor userSchedulingPriority + 1). |
|
15 | 148 |
|
0 | 149 |
^ transcript |
110 | 150 |
|
151 |
" |
|
3852
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
152 |
TextCollector newTranscript:#T2. |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
153 |
T2 showCR:'Hello world'. |
5908 | 154 |
Smalltalk removeKey:#T2 |
110 | 155 |
" |
778
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
156 |
|
1026 | 157 |
"Modified: 17.2.1997 / 18:20:27 / cg" |
0 | 158 |
! ! |
159 |
||
2025
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
160 |
!TextCollector class methodsFor:'Signal constants'! |
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
161 |
|
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
162 |
transcriptQuerySignal |
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
163 |
^ TranscriptQuerySignal |
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
164 |
! ! |
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
165 |
|
4105
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
166 |
!TextCollector class methodsFor:'debugging'! |
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
167 |
|
4365 | 168 |
debugSendersOfMessagePattern |
169 |
^ DebugSendersOfMessagePattern |
|
170 |
||
171 |
"Created: / 02-02-2012 / 12:05:27 / cg" |
|
172 |
! |
|
173 |
||
4105
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
174 |
debugSendersOfMessagePattern:aGLOBMatchPattern |
4233
ae8979201707
changed: #debugSendersOfMessagePattern:
Claus Gittinger <cg@exept.de>
parents:
4124
diff
changeset
|
175 |
"ever want to know, who sends a particular text-message to the transcript ? |
4365 | 176 |
Call this with a match string and get a halt, when a matching text is sent to the transcript" |
4105
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
177 |
|
4654 | 178 |
DebugSendersOfMessagePattern := aGLOBMatchPattern asNilIfEmpty |
4105
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
179 |
|
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
180 |
" |
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
181 |
self debugSendersOfMessagePattern:'no such*' |
4233
ae8979201707
changed: #debugSendersOfMessagePattern:
Claus Gittinger <cg@exept.de>
parents:
4124
diff
changeset
|
182 |
self debugSendersOfMessagePattern:'remove*' |
4105
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
183 |
self debugSendersOfMessagePattern:nil. |
4284
3e487b994a8b
changed: #debugSendersOfMessagePattern:
Claus Gittinger <cg@exept.de>
parents:
4233
diff
changeset
|
184 |
self debugSendersOfMessagePattern:'*'. |
4105
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
185 |
" |
4233
ae8979201707
changed: #debugSendersOfMessagePattern:
Claus Gittinger <cg@exept.de>
parents:
4124
diff
changeset
|
186 |
|
4365 | 187 |
"Modified: / 02-02-2012 / 12:07:11 / cg" |
188 |
! |
|
189 |
||
4643 | 190 |
timestampMessages |
6668 | 191 |
"if true, all messages are shown with a timestamp in front" |
192 |
||
193 |
^ TimestampMessages ? false |
|
4643 | 194 |
! |
195 |
||
196 |
timestampMessages:aBoolean |
|
197 |
"if true, all messages are shown with a timestamp in front" |
|
198 |
||
199 |
TimestampMessages := aBoolean |
|
200 |
||
201 |
" |
|
202 |
self timestampMessages:true |
|
203 |
self timestampMessages:false. |
|
204 |
" |
|
205 |
! |
|
206 |
||
4365 | 207 |
traceSendersOfMessagePattern |
208 |
^ TraceSendersOfMessagePattern |
|
209 |
||
210 |
"Created: / 02-02-2012 / 12:05:32 / cg" |
|
211 |
! |
|
212 |
||
213 |
traceSendersOfMessagePattern:aGLOBMatchPattern |
|
214 |
"ever want to know, who sends a particular text-message to the transcript ? |
|
215 |
Call this with a match string and get a trace, when a matching text is sent to the transcript" |
|
216 |
||
4654 | 217 |
TraceSendersOfMessagePattern := aGLOBMatchPattern asNilIfEmpty |
4365 | 218 |
|
219 |
" |
|
220 |
self traceSendersOfMessagePattern:'removed unreached*' |
|
221 |
self traceSendersOfMessagePattern:nil. |
|
222 |
self traceSendersOfMessagePattern:'*'. |
|
223 |
" |
|
224 |
||
225 |
"Created: / 02-02-2012 / 11:59:22 / cg" |
|
4105
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
226 |
! ! |
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
227 |
|
928 | 228 |
!TextCollector class methodsFor:'defaults'! |
0 | 229 |
|
1610
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
230 |
defaultCollectSize |
5301 | 231 |
"the number of lines buffered for delayed update. |
232 |
At most this number of lines to be shown are buffered (without redrawing), |
|
233 |
before a redraw is done. Thus, if a lot of output is generated fast, |
|
234 |
the redrawing is performed in chunks. |
|
235 |
This has a significant effect on the performane, |
|
236 |
as the view does not have to scroll and redraw for each |
|
237 |
individual line, but does junp-scrolling instead. |
|
238 |
See also defaultTimeDelay" |
|
239 |
||
240 |
^ DefaultCollectSize ? 1000 |
|
1610
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
241 |
|
5301 | 242 |
"Modified: / 27.7.1998 / 16:14:51 / cg" |
243 |
! |
|
244 |
||
245 |
defaultCollectSize:numberOfLines |
|
246 |
"the number of lines buffered for delayed update. |
|
247 |
At most this number of lines to be shown are buffered (without redrawing), |
|
248 |
before a redraw is done. Thus, if a lot of output is generated fast, |
|
249 |
the redrawing is performed in chunks. |
|
250 |
This has a significant effect on the performane, |
|
251 |
as the view does not have to scroll and redraw for each |
|
252 |
individual line, but does junp-scrolling instead. |
|
253 |
See also defaultTimeDelay" |
|
254 |
||
255 |
DefaultCollectSize := numberOfLines |
|
1610
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
256 |
|
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
257 |
"Modified: / 27.7.1998 / 16:14:51 / cg" |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
258 |
! |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
259 |
|
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
260 |
defaultLineLimit |
5301 | 261 |
"the number of lines remembered by default. |
262 |
Only the last n lines are remembered and can be seen by scrolling. |
|
263 |
Older lines are forgotten. |
|
264 |
This limit can be changed by the userPreferences dialog" |
|
265 |
||
266 |
^ DefaultLineLimit ? 1000 |
|
267 |
! |
|
59 | 268 |
|
5301 | 269 |
defaultLineLimit:numberOfLines |
270 |
"the number of lines remembered by default. |
|
271 |
Only the last n lines are remembered and can be seen by scrolling. |
|
272 |
Older lines are forgotten. |
|
273 |
This limit can be changed by the userPreferences dialog" |
|
274 |
||
275 |
DefaultLineLimit := numberOfLines |
|
59 | 276 |
! |
277 |
||
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
278 |
defaultTimeDelay |
5301 | 279 |
"the time in seconds to wait & collect by default. |
280 |
At most this number of seconds incoming text is buffered (without redrawing), |
|
281 |
before a redraw is done. Thus, if a lot of output is generated fast, |
|
282 |
the redrawing is performed in chunks. |
|
283 |
This has a significant effect on the performane, |
|
284 |
as the view does not have to scroll and redraw for each |
|
285 |
individual line, but does junp-scrolling instead. |
|
286 |
The value may be a float (eg. 0.5) |
|
287 |
See also defaultCollectSize" |
|
288 |
||
289 |
^ DefaultTimeDelay ? 0.5 |
|
290 |
! |
|
36 | 291 |
|
5301 | 292 |
defaultTimeDelay:seconds |
293 |
"the time in seconds to wait & collect by default. |
|
294 |
At most this number of seconds incoming text is buffered (without redrawing), |
|
295 |
before a redraw is done. Thus, if a lot of output is generated fast, |
|
296 |
the redrawing is performed in chunks. |
|
297 |
This has a significant effect on the performane, |
|
298 |
as the view does not have to scroll and redraw for each |
|
299 |
individual line, but does junp-scrolling instead. |
|
300 |
The argument may be a float (eg. 0.5) |
|
301 |
See also defaultCollectSize" |
|
302 |
||
303 |
DefaultTimeDelay := seconds |
|
34
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
304 |
! |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
305 |
|
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
306 |
defaultTranscriptSize |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
307 |
"the number of cols/lines by which the Transcript should come up" |
110 | 308 |
|
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
309 |
^ 70@11 |
110 | 310 |
! ! |
311 |
||
2744 | 312 |
!TextCollector methodsFor:'Compatibility-ST80'! |
1500 | 313 |
|
314 |
deselect |
|
315 |
self unselect |
|
1504
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
316 |
! |
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
317 |
|
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
318 |
flush |
6830 | 319 |
"write out all buffered data" |
320 |
||
1504
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
321 |
self endEntry. |
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
322 |
super flush |
1500 | 323 |
! ! |
324 |
||
0 | 325 |
!TextCollector methodsFor:'accessing'! |
326 |
||
3710 | 327 |
autoRaise |
328 |
^ autoRaise ? false |
|
329 |
! |
|
330 |
||
331 |
autoRaise:something |
|
332 |
autoRaise := something. |
|
333 |
! |
|
334 |
||
0 | 335 |
collect:aBoolean |
34
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
336 |
"turn on/off collecting - if on, do not output immediately |
15 | 337 |
but collect text and output en-bloque after some time delta" |
0 | 338 |
|
339 |
collecting := aBoolean |
|
340 |
! |
|
341 |
||
1610
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
342 |
collectSize:numberOfLines |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
343 |
"set the collect buffer size. If collect is enabled, |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
344 |
the receiver will force update of the view, |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
345 |
whenever that many lines have been collected |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
346 |
(or the updateTimeDelay interval has passed). |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
347 |
With collect turned off, an immediate update is performed." |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
348 |
|
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
349 |
collectSize := numberOfLines |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
350 |
|
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
351 |
"Modified: / 27.7.1998 / 16:16:00 / cg" |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
352 |
! |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
353 |
|
0 | 354 |
destroyAction:aBlock |
34
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
355 |
"define the action to be performed when I get destroyed. |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
356 |
This is a special feature, to allow resetting Transcript to Stderr |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
357 |
when closed. (see TextCollectorclass>>newTranscript)" |
0 | 358 |
|
359 |
destroyAction := aBlock |
|
360 |
! |
|
361 |
||
5486 | 362 |
entryStream |
6731 | 363 |
"returns something which is a stream, sending its input to me. |
364 |
Typically, this will be an ActorStream" |
|
6529 | 365 |
|
5486 | 366 |
^ entryStream |
6529 | 367 |
|
368 |
"Modified (comment): / 19-02-2019 / 22:37:47 / Claus Gittinger" |
|
5486 | 369 |
! |
370 |
||
6726 | 371 |
entryStream:aStream |
372 |
"changes the entryStream. |
|
373 |
This is the stream which gets all of my lines via nextPut/nextPutLine/nextPutAll. |
|
374 |
Can be changed to (temporarily) divert the output to some file |
|
375 |
and/or to duplicate (send to multiple destinations) via a splitter or filterStream. |
|
376 |
(see example in SplittingWriteStream)" |
|
6727 | 377 |
|
378 |
self endEntry. |
|
6726 | 379 |
entryStream := aStream. |
380 |
! |
|
381 |
||
2103 | 382 |
lineLimit |
5989 | 383 |
"return the number of text-lines I am supposed to hold when collecting. |
384 |
Nil means: unlimited" |
|
2103 | 385 |
|
386 |
^ lineLimit |
|
387 |
||
388 |
" |
|
389 |
Transcript lineLimit:5000 |
|
390 |
Transcript lineLimit |
|
391 |
" |
|
392 |
||
393 |
"Modified: / 16.5.1998 / 01:33:52 / cg" |
|
394 |
! |
|
395 |
||
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
396 |
lineLimit:aNumber |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
397 |
"define the number of text-lines I am supposed to hold" |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
398 |
|
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
399 |
lineLimit := aNumber |
1611 | 400 |
|
401 |
" |
|
402 |
Transcript lineLimit:5000 |
|
403 |
" |
|
404 |
||
405 |
"Modified: / 16.5.1998 / 01:33:52 / cg" |
|
1610
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
406 |
! |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
407 |
|
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
408 |
updateTimeDelay:seconds |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
409 |
"if collect is enabled, the receiver will update its view, |
4643 | 410 |
after that time delay (i.e. it collects output during that period), |
1610
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
411 |
or when collectSize lines have been collected without update. |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
412 |
With collect turned off, an immediate update is performed." |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
413 |
|
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
414 |
timeDelay := seconds |
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
415 |
|
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
416 |
"Modified: / 27.7.1998 / 16:16:41 / cg" |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
417 |
! ! |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
418 |
|
2750 | 419 |
!TextCollector methodsFor:'initialization & release'! |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
420 |
|
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
421 |
destroy |
928 | 422 |
"destroy this view" |
423 |
||
3201 | 424 |
destroyAction value. |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
425 |
super destroy |
928 | 426 |
|
1714 | 427 |
"Modified: / 9.11.1998 / 21:18:17 / cg" |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
428 |
! |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
429 |
|
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
430 |
initialize |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
431 |
super initialize. |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
432 |
|
2164
ed46136cb2cf
honor scrollWhenUpdating setting
Claus Gittinger <cg@exept.de>
parents:
2103
diff
changeset
|
433 |
scrollWhenUpdating := #endOfText. |
ed46136cb2cf
honor scrollWhenUpdating setting
Claus Gittinger <cg@exept.de>
parents:
2103
diff
changeset
|
434 |
|
928 | 435 |
outstandingLines := nil. |
1562
9b7557a81849
made the number of buffered lines an instVar.
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
436 |
alwaysAppendAtEnd := true. |
1610
b05a3e405b33
allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents:
1598
diff
changeset
|
437 |
collectSize := self class defaultCollectSize. |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
438 |
|
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
439 |
flushPending := inFlush := false. |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
440 |
collecting := true. |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
441 |
timeDelay := self class defaultTimeDelay. |
6189 | 442 |
access := RecursionLock name:'TextCollector access lock'. |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
443 |
|
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
444 |
lineLimit := self class defaultLineLimit. |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
445 |
entryStream := ActorStream new. |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
446 |
entryStream nextPutBlock:[:something | self nextPut:something]. |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
447 |
entryStream nextPutAllBlock:[:something | self nextPutAll:something] |
928 | 448 |
|
2086
95ec18a17198
give my access sema a name (for the semaphoreMonitor)
Claus Gittinger <cg@exept.de>
parents:
2025
diff
changeset
|
449 |
"Modified: / 14.12.1999 / 21:13:54 / cg" |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
450 |
! |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
451 |
|
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
452 |
mapped |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
453 |
"view became visible - show collected lines (if any)" |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
454 |
|
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
455 |
super mapped. |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
456 |
self endEntry |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
457 |
! |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
458 |
|
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
459 |
reinitialize |
2259 | 460 |
"reinit after a snapIn. |
461 |
recreate access-semaphore; image could have been save (theoretically) |
|
1467
5c09bb2dadef
Add (dummy fore now) #beginEntry for ST80 compat.
Stefan Vogel <sv@exept.de>
parents:
1421
diff
changeset
|
462 |
with the semaphore locked - in this case, we had a deadlock" |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
463 |
|
4645 | 464 |
flushPending := inFlush := false. |
6189 | 465 |
access := RecursionLock name:'TextCollector access lock'. |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
466 |
super reinitialize. |
1467
5c09bb2dadef
Add (dummy fore now) #beginEntry for ST80 compat.
Stefan Vogel <sv@exept.de>
parents:
1421
diff
changeset
|
467 |
|
6108 | 468 |
"Modified: / 20-02-2017 / 21:29:13 / stefan" |
2591 | 469 |
! |
470 |
||
471 |
release |
|
472 |
flushBlock notNil ifTrue:[ |
|
473 |
Processor removeTimedBlock:flushBlock. |
|
474 |
flushBlock := nil. |
|
475 |
]. |
|
476 |
outstandingLines := nil. |
|
477 |
outstandingLine := ''. |
|
478 |
||
479 |
super release |
|
480 |
||
481 |
"Modified: / 9.11.1998 / 21:18:17 / cg" |
|
0 | 482 |
! ! |
483 |
||
5783 | 484 |
!TextCollector methodsFor:'menu - actions'! |
485 |
||
486 |
doSetLineLimit |
|
6595 | 487 |
|nLines makeDefault newNLines| |
5783 | 488 |
|
6595 | 489 |
makeDefault := false. |
490 |
Dialog withOptoutOption:[makeDefault := true] labelled:'Make this the default for the future' do:[ |
|
491 |
nLines := Dialog requestNumber:'Enter Line Limit:' initialAnswer:lineLimit. |
|
492 |
]. |
|
5783 | 493 |
nLines notNil ifTrue:[ |
6595 | 494 |
newNLines := nLines asInteger max:100. |
495 |
self lineLimit:newNLines. |
|
496 |
makeDefault ifTrue:[ |
|
497 |
self class defaultLineLimit:newNLines |
|
498 |
]. |
|
5783 | 499 |
]. |
6595 | 500 |
|
501 |
"Modified: / 06-06-2019 / 10:21:08 / Claus Gittinger" |
|
6731 | 502 |
! |
503 |
||
504 |
isDivertingOutput |
|
505 |
"is the output currently being diverted to a file?" |
|
506 |
||
507 |
^ (entryStream class == SplittingWriteStream) |
|
508 |
! |
|
509 |
||
510 |
startDivertingOutput |
|
511 |
"ask for a filename to divert (i.e. send) the output to" |
|
512 |
||
513 |
|fn| |
|
514 |
||
515 |
fn := Dialog requestFileName:'Append Output to File:' default:'transcript.log'. |
|
516 |
fn isEmptyOrNil ifTrue:[^ self]. |
|
517 |
self startDivertingOutputTo:fn |
|
518 |
! |
|
519 |
||
520 |
startDivertingOutputTo:aFilename |
|
521 |
"divert (i.e. send) the output to the given logFile" |
|
522 |
||
523 |
|originalEntryStream fileStream splitter| |
|
524 |
||
525 |
(entryStream class == SplittingWriteStream) ifTrue:[ |
|
526 |
originalEntryStream := entryStream outStream2. |
|
527 |
] ifFalse:[ |
|
528 |
originalEntryStream := entryStream. |
|
529 |
]. |
|
530 |
fileStream := aFilename asFilename appendingWriteStream. |
|
531 |
splitter := SplittingWriteStream on:fileStream and:originalEntryStream. |
|
532 |
self entryStream:splitter. |
|
533 |
! |
|
534 |
||
535 |
stopDivertingOutput |
|
536 |
"no longer send the output to the logFile (see startDivertingOutput)" |
|
537 |
||
538 |
|originalEntryStream fileStream| |
|
539 |
||
540 |
(entryStream class == SplittingWriteStream) ifTrue:[ |
|
541 |
fileStream := entryStream outStream1. |
|
542 |
originalEntryStream := entryStream outStream2. |
|
543 |
self entryStream:originalEntryStream. |
|
544 |
fileStream close. |
|
545 |
]. |
|
5783 | 546 |
! ! |
547 |
||
6680 | 548 |
!TextCollector methodsFor:'printing'! |
549 |
||
550 |
classDisplayString |
|
551 |
self == Transcript ifTrue:[ |
|
552 |
^ 'Transcript (a ',super classDisplayString,')' |
|
553 |
]. |
|
554 |
^ super classDisplayString |
|
555 |
! ! |
|
556 |
||
0 | 557 |
!TextCollector methodsFor:'private'! |
558 |
||
559 |
checkLineLimit |
|
560 |
"this method checks if the text has become too large (> lineLimit) |
|
561 |
and cuts off some lines at the top if so; it must be called whenever lines |
|
562 |
have been added to the bottom" |
|
563 |
||
2426
281067d406c7
eliminated direct write-access to cursorLine
Claus Gittinger <cg@exept.de>
parents:
2371
diff
changeset
|
564 |
|nDel newCursorLine| |
0 | 565 |
|
6114 | 566 |
list isEmptyOrNil ifTrue:[ |
567 |
"no lines" |
|
568 |
^ self. |
|
569 |
]. |
|
570 |
||
0 | 571 |
lineLimit notNil ifTrue:[ |
2426
281067d406c7
eliminated direct write-access to cursorLine
Claus Gittinger <cg@exept.de>
parents:
2371
diff
changeset
|
572 |
(cursorLine > lineLimit) ifTrue:[ |
281067d406c7
eliminated direct write-access to cursorLine
Claus Gittinger <cg@exept.de>
parents:
2371
diff
changeset
|
573 |
nDel := list size - lineLimit. |
4772 | 574 |
self basicListRemoveFromIndex:1 toIndex:nDel. |
2426
281067d406c7
eliminated direct write-access to cursorLine
Claus Gittinger <cg@exept.de>
parents:
2371
diff
changeset
|
575 |
newCursorLine := cursorLine - nDel. |
281067d406c7
eliminated direct write-access to cursorLine
Claus Gittinger <cg@exept.de>
parents:
2371
diff
changeset
|
576 |
firstLineShown := firstLineShown - nDel. |
281067d406c7
eliminated direct write-access to cursorLine
Claus Gittinger <cg@exept.de>
parents:
2371
diff
changeset
|
577 |
(firstLineShown < 1) ifTrue:[ |
281067d406c7
eliminated direct write-access to cursorLine
Claus Gittinger <cg@exept.de>
parents:
2371
diff
changeset
|
578 |
newCursorLine := newCursorLine - firstLineShown + 1. |
281067d406c7
eliminated direct write-access to cursorLine
Claus Gittinger <cg@exept.de>
parents:
2371
diff
changeset
|
579 |
firstLineShown := 1 |
281067d406c7
eliminated direct write-access to cursorLine
Claus Gittinger <cg@exept.de>
parents:
2371
diff
changeset
|
580 |
]. |
281067d406c7
eliminated direct write-access to cursorLine
Claus Gittinger <cg@exept.de>
parents:
2371
diff
changeset
|
581 |
self setCursorLine:newCursorLine. |
3320
a820e3101bb6
refresh when removing some lines after hitting linelimit
fm
parents:
3295
diff
changeset
|
582 |
self contentsChanged. |
a820e3101bb6
refresh when removing some lines after hitting linelimit
fm
parents:
3295
diff
changeset
|
583 |
self invalidate. |
2426
281067d406c7
eliminated direct write-access to cursorLine
Claus Gittinger <cg@exept.de>
parents:
2371
diff
changeset
|
584 |
] |
3710 | 585 |
]. |
586 |
self autoRaise ifTrue:[ |
|
587 |
self topView |
|
588 |
raise; |
|
589 |
"/ setForegroundWindow; |
|
590 |
yourself. |
|
591 |
]. |
|
3320
a820e3101bb6
refresh when removing some lines after hitting linelimit
fm
parents:
3295
diff
changeset
|
592 |
|
a820e3101bb6
refresh when removing some lines after hitting linelimit
fm
parents:
3295
diff
changeset
|
593 |
"Modified: / 26-07-2006 / 16:02:15 / fm" |
6114 | 594 |
"Modified: / 02-03-2017 / 12:02:03 / stefan" |
34
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
595 |
! |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
596 |
|
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
597 |
installDelayedUpdate |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
598 |
"arrange for collecting input for some time, |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
599 |
and output all buffered strings at once after a while. |
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
600 |
This makes output to the transcript much faster on systems |
553 | 601 |
with poor scrolling performance (i.e. dumb vga cards ...)." |
34
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
602 |
|
131 | 603 |
|p| |
34
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
604 |
|
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
605 |
flushPending ifFalse:[ |
553 | 606 |
inFlush ifFalse:[ |
4643 | 607 |
flushPending := true. |
553 | 608 |
" |
609 |
we could run under a process, which dies in the meantime; |
|
610 |
therefore, we have to arrange for the transcript process to |
|
611 |
be interrupted and do the update. |
|
612 |
" |
|
613 |
windowGroup isNil ifTrue:[ |
|
4503 | 614 |
p := Processor timeoutHandlerProcess |
553 | 615 |
] ifFalse:[ |
616 |
p := windowGroup process |
|
617 |
]. |
|
1221
0c2a4231fc9e
Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents:
1109
diff
changeset
|
618 |
(p isNil or:[p isSystemProcess]) ifTrue:[ |
834
0da7c9923d1b
prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
619 |
self endEntry |
0da7c9923d1b
prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
620 |
] ifFalse:[ |
1711 | 621 |
flushBlock isNil ifTrue:[ |
4650 | 622 |
flushBlock := [self delayedEndEntry]. |
1711 | 623 |
]. |
834
0da7c9923d1b
prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
624 |
Processor addTimedBlock:flushBlock for:p afterSeconds:timeDelay. |
3009
7eb1704fa5a6
Avoid dangling references in context
Stefan Vogel <sv@exept.de>
parents:
3006
diff
changeset
|
625 |
]. |
4650 | 626 |
p := nil. "hack: avoid dangling references to p through the home context of flushBlock" |
553 | 627 |
] |
34
c4b386a8cc57
critical-lock; allows show:/showCr: from multiple processes
claus
parents:
22
diff
changeset
|
628 |
] |
553 | 629 |
|
1711 | 630 |
"Modified: / 17.4.1997 / 13:03:15 / stefan" |
631 |
"Modified: / 9.11.1998 / 14:34:07 / cg" |
|
4365 | 632 |
! |
633 |
||
634 |
senderTraceString |
|
635 |
"generate a sender trace string." |
|
636 |
||
637 |
|con| |
|
638 |
||
639 |
"/ skip over intermediate contexts |
|
640 |
"/ con := con sender. |
|
641 |
"/ con := thisContext sender sender. |
|
642 |
"/ [ con receiver == self ] whileTrue:[ |
|
643 |
"/ con := con sender |
|
644 |
"/ ]. |
|
645 |
con := DebugView interestingContextFrom:thisContext sender sender. |
|
646 |
^ con printString |
|
647 |
||
648 |
"Created: / 02-02-2012 / 11:58:17 / cg" |
|
0 | 649 |
! ! |
650 |
||
778
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
651 |
!TextCollector methodsFor:'queries'! |
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
652 |
|
6731 | 653 |
canDivertOutput |
654 |
^ true. |
|
655 |
! |
|
656 |
||
778
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
657 |
current |
4687 | 658 |
"return the current (your screen's) transcript. |
5301 | 659 |
In multiDisplay applications, this need NOT be the main transcript, |
660 |
as each display may have its own transcript. |
|
778
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
661 |
But typically, this is the same as Transcript." |
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
662 |
|
6795 | 663 |
|theTranscript app myTop| |
2025
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
664 |
|
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
665 |
theTranscript := TranscriptQuerySignal query. |
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
666 |
theTranscript isNil ifTrue:[ |
6795 | 667 |
(myTop := self topView) notNil ifTrue:[ |
668 |
(app := myTop application) notNil ifTrue:[ |
|
669 |
app := app class current ? app |
|
670 |
] |
|
671 |
]. |
|
672 |
app isNil ifTrue:[^ Transcript]. |
|
2763
e2fba3262e07
Avoid recursion when getting the Transcript on extra displays
Stefan Vogel <sv@exept.de>
parents:
2750
diff
changeset
|
673 |
(app notNil and:[thisContext isRecursive not]) ifTrue:[ |
2278 | 674 |
theTranscript := (app transcript ? Stderr). |
675 |
] ifFalse:[ |
|
676 |
theTranscript := Stderr. |
|
677 |
] |
|
2025
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
678 |
]. |
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
679 |
^ theTranscript |
778
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
680 |
|
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
681 |
" |
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
682 |
Transcript current flash |
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
683 |
" |
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
684 |
|
4687 | 685 |
"Created: / 05-07-1996 / 14:14:34 / cg" |
686 |
"Modified (comment): / 29-08-2013 / 11:04:55 / cg" |
|
4441
fb138fb5cf04
#isStream answers true for Transcript
Stefan Vogel <sv@exept.de>
parents:
4428
diff
changeset
|
687 |
! |
fb138fb5cf04
#isStream answers true for Transcript
Stefan Vogel <sv@exept.de>
parents:
4428
diff
changeset
|
688 |
|
fb138fb5cf04
#isStream answers true for Transcript
Stefan Vogel <sv@exept.de>
parents:
4428
diff
changeset
|
689 |
isStream |
fb138fb5cf04
#isStream answers true for Transcript
Stefan Vogel <sv@exept.de>
parents:
4428
diff
changeset
|
690 |
"if I am the Transcript, I am used as a stream. |
fb138fb5cf04
#isStream answers true for Transcript
Stefan Vogel <sv@exept.de>
parents:
4428
diff
changeset
|
691 |
See #displayOn:" |
6529 | 692 |
"If you need a real stream, use entryStream" |
4441
fb138fb5cf04
#isStream answers true for Transcript
Stefan Vogel <sv@exept.de>
parents:
4428
diff
changeset
|
693 |
|
fb138fb5cf04
#isStream answers true for Transcript
Stefan Vogel <sv@exept.de>
parents:
4428
diff
changeset
|
694 |
^ self == Transcript |
fb138fb5cf04
#isStream answers true for Transcript
Stefan Vogel <sv@exept.de>
parents:
4428
diff
changeset
|
695 |
|
fb138fb5cf04
#isStream answers true for Transcript
Stefan Vogel <sv@exept.de>
parents:
4428
diff
changeset
|
696 |
" |
fb138fb5cf04
#isStream answers true for Transcript
Stefan Vogel <sv@exept.de>
parents:
4428
diff
changeset
|
697 |
Transcript isStream |
fb138fb5cf04
#isStream answers true for Transcript
Stefan Vogel <sv@exept.de>
parents:
4428
diff
changeset
|
698 |
" |
6529 | 699 |
|
700 |
"Modified (comment): / 19-02-2019 / 22:38:17 / Claus Gittinger" |
|
4687 | 701 |
! |
702 |
||
703 |
isTextCollector |
|
6530 | 704 |
"true, iff this is a text collector emulating a stream" |
705 |
||
4687 | 706 |
^ true |
707 |
||
708 |
" |
|
709 |
Transcript isTextCollector |
|
710 |
" |
|
711 |
||
712 |
"Created: / 29-08-2013 / 11:32:46 / cg" |
|
6530 | 713 |
"Modified (comment): / 19-02-2019 / 22:48:40 / Claus Gittinger" |
5330 | 714 |
! |
715 |
||
716 |
position |
|
717 |
"for compatibiliy with normal streams; return the column" |
|
718 |
||
719 |
^ cursorCol |
|
5989 | 720 |
! |
721 |
||
722 |
showLineLimitInMenu |
|
723 |
^ true. |
|
778
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
724 |
! ! |
3a8fabcf1872
added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
725 |
|
2450 | 726 |
!TextCollector methodsFor:'scrolling'! |
727 |
||
5136 | 728 |
makeCursorVisible |
5137 | 729 |
(scrollLocked ? false) ifFalse:[ |
5136 | 730 |
access critical:[ |
731 |
super makeCursorVisible |
|
732 |
] |
|
733 |
] |
|
734 |
! |
|
735 |
||
736 |
scrollLock:aBoolean |
|
737 |
aBoolean ifTrue:[ |
|
738 |
scrollWhenUpdating := #endOfText. |
|
739 |
] ifFalse:[ |
|
740 |
scrollWhenUpdating := nil. |
|
741 |
]. |
|
5137 | 742 |
scrollLocked := aBoolean. |
5136 | 743 |
! |
744 |
||
2450 | 745 |
scrollTo:anOrigin redraw:doRedraw |
746 |
access critical:[ |
|
747 |
super scrollTo:anOrigin redraw:doRedraw |
|
748 |
] |
|
749 |
! ! |
|
750 |
||
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
751 |
!TextCollector methodsFor:'stream messages'! |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
752 |
|
4106 | 753 |
addLine:line |
754 |
"append a line to the outstanding lines buffer" |
|
755 |
||
756 |
access critical:[ |
|
757 |
outstandingLine size ~~ 0 ifTrue:[ |
|
758 |
outstandingLine := outstandingLine , line |
|
759 |
] ifFalse:[ |
|
4645 | 760 |
(TimestampMessages == true and:[self == Transcript]) ifTrue:[ |
4643 | 761 |
outstandingLine := Timestamp now printString,' ',line |
762 |
] ifFalse:[ |
|
763 |
outstandingLine := line |
|
764 |
] |
|
4106 | 765 |
]. |
4650 | 766 |
"/ self ~~ Transcript ifTrue:['xa' printCR]. |
4106 | 767 |
outstandingLines isNil ifTrue:[ |
768 |
outstandingLines := OrderedCollection with:outstandingLine |
|
769 |
] ifFalse:[ |
|
770 |
outstandingLines add:outstandingLine. |
|
771 |
]. |
|
772 |
outstandingLine := ''. |
|
773 |
||
774 |
collecting ifTrue:[ |
|
4643 | 775 |
flushPending ifFalse:[ |
776 |
self installDelayedUpdate |
|
777 |
] ifTrue:[ |
|
4106 | 778 |
outstandingLines size > collectSize ifTrue:[ |
779 |
self endEntry |
|
780 |
] |
|
781 |
] |
|
782 |
] ifFalse:[ |
|
783 |
self endEntry. |
|
784 |
self cursorReturn. |
|
785 |
self checkLineLimit. |
|
786 |
self cursorToEnd. |
|
787 |
] |
|
788 |
]. |
|
789 |
||
790 |
"Created: / 28.7.1998 / 00:31:46 / cg" |
|
791 |
"Modified: / 28.7.1998 / 00:34:58 / cg" |
|
792 |
! |
|
793 |
||
6558 | 794 |
binary:beBinaryBool |
795 |
"ExternalStream protocol compatibility" |
|
796 |
||
797 |
^ false "/ no-op, I am not in binary mode |
|
798 |
||
799 |
"Created: / 13-03-2019 / 19:12:48 / Stefan Vogel" |
|
800 |
! |
|
801 |
||
6560 | 802 |
bufferSizeForBulkCopy |
803 |
^ 1024 |
|
804 |
||
805 |
"Created: / 14-03-2019 / 00:21:49 / Claus Gittinger" |
|
806 |
! |
|
807 |
||
6558 | 808 |
buffered:aBoolean |
809 |
"ignored here" |
|
810 |
||
811 |
^ false "/ pretend, that I am not buffered |
|
812 |
||
813 |
"Created: / 13-03-2019 / 18:30:29 / Stefan Vogel" |
|
814 |
"Modified: / 13-03-2019 / 19:34:41 / Stefan Vogel" |
|
815 |
! |
|
816 |
||
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
817 |
cr |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
818 |
"output a carriage return, finishing the current line" |
135 | 819 |
|
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
820 |
access critical:[ |
4643 | 821 |
|line| |
822 |
||
834
0da7c9923d1b
prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
823 |
collecting ifTrue:[ |
4643 | 824 |
line := outstandingLine. |
4645 | 825 |
(TimestampMessages == true and:[self == Transcript]) ifTrue:[ |
4643 | 826 |
outstandingLine size == 0 ifTrue:[ |
827 |
line := Timestamp now printString |
|
828 |
]. |
|
829 |
]. |
|
4650 | 830 |
"/ self ~~ Transcript ifTrue:['xc' printCR]. |
4643 | 831 |
outstandingLines isNil ifTrue:[ |
832 |
outstandingLines := OrderedCollection with:line |
|
833 |
] ifFalse:[ |
|
834 |
outstandingLines add:line. |
|
834
0da7c9923d1b
prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
835 |
]. |
0da7c9923d1b
prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
836 |
outstandingLine := ''. |
4643 | 837 |
flushPending ifFalse:[ |
838 |
self installDelayedUpdate |
|
839 |
] |
|
834
0da7c9923d1b
prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
840 |
] ifFalse:[ |
0da7c9923d1b
prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
841 |
self cursorReturn. |
0da7c9923d1b
prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
842 |
self checkLineLimit. |
0da7c9923d1b
prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
843 |
self cursorToEnd. |
0da7c9923d1b
prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
844 |
]. |
0da7c9923d1b
prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents:
778
diff
changeset
|
845 |
]. |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
846 |
! |
135 | 847 |
|
4460 | 848 |
display:someObject |
849 |
"dolphin compatibility" |
|
850 |
||
5246 | 851 |
"/ someObject printOn:self. |
852 |
self nextPutAll: someObject asString. |
|
4460 | 853 |
! |
854 |
||
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
855 |
doesNotUnderstand:aMessage |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
856 |
"this is funny: all message we do not understand, are passed |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
857 |
on to the stream which will send the characters via nextPut: |
3006 | 858 |
This way, we understand all Stream messages - great isn't it!!" |
859 |
||
6680 | 860 |
"/ catch and re-raise, so to the debugger it will look as if it was |
861 |
"/ raised here (in case the ActorStream also does not implement it. |
|
862 |
"/ Thus the debugger will show the caller as responsible, instead of me. |
|
863 |
[ |
|
864 |
^ aMessage sendTo:entryStream |
|
865 |
] on:MessageNotUnderstood do:[:ex | |
|
866 |
ex selector == aMessage selector ifTrue:[ |
|
867 |
ex originator == entryStream ifTrue:[ |
|
868 |
ex originator:self. |
|
869 |
^ ex raiseSignalIn:ex handlerContext. |
|
870 |
^ super doesNotUnderstand:aMessage |
|
871 |
] |
|
872 |
]. |
|
873 |
ex reject |
|
874 |
]. |
|
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
875 |
! |
0 | 876 |
|
4311 | 877 |
ensureCr |
878 |
"if the output position is not already at the beginning of a line, |
|
879 |
output a carriage return" |
|
880 |
||
881 |
|needCR| |
|
882 |
||
883 |
collecting ifTrue:[ |
|
884 |
needCR := outstandingLine notEmptyOrNil |
|
885 |
] ifFalse:[ |
|
886 |
needCR := cursorCol > 0 |
|
887 |
]. |
|
888 |
||
889 |
needCR ifTrue:[ |
|
890 |
self cr. |
|
891 |
]. |
|
892 |
||
893 |
"Created: / 14-09-2011 / 09:01:03 / cg" |
|
894 |
! |
|
895 |
||
5025 | 896 |
format:formatSpec with:args |
5569 | 897 |
"convenient formatted printing: |
898 |
%1..%9 - positional parameters from args-collection |
|
899 |
%(name) - named parameter from args-dictionary |
|
900 |
%% - escape for % |
|
901 |
%<cr> - cr (also tab, nl)" |
|
902 |
||
5025 | 903 |
^ entryStream format:formatSpec with:args |
5569 | 904 |
|
905 |
" |
|
906 |
1 to: 10 do:[:i | |
|
907 |
Transcript |
|
908 |
format:'[%1] Hello %2 World - this is %3%<cr>' |
|
909 |
with:{i . 'my' . 'nice'} |
|
910 |
]. |
|
911 |
" |
|
5025 | 912 |
! |
913 |
||
0 | 914 |
lineLength |
928 | 915 |
"to make a textCollector (somewhat) compatible with printer |
916 |
streams, support the lineLength query" |
|
917 |
||
4918 | 918 |
^ width // (gc font width) |
928 | 919 |
|
920 |
"Modified: 11.1.1997 / 14:42:41 / cg" |
|
0 | 921 |
! |
922 |
||
923 |
nextPut:something |
|
928 | 924 |
"append somethings printString to my displayed text. |
6686 | 925 |
Answer something. |
928 | 926 |
This allows TextCollectors to be used Stream-wise" |
0 | 927 |
|
1504
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
928 |
|txt| |
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
929 |
|
656 | 930 |
(something isCharacter) ifTrue:[ |
931 |
((something == Character cr) or:[something == Character nl]) ifTrue:[ |
|
6684 | 932 |
self cr. |
6685 | 933 |
^ something. |
656 | 934 |
]. |
0 | 935 |
]. |
1504
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
936 |
|
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
937 |
txt := something asString. |
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
938 |
currentEmphasis notNil ifTrue:[ |
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
939 |
txt := txt emphasizeAllWith:currentEmphasis |
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
940 |
]. |
3101f410e230
rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
941 |
self show:txt. |
6685 | 942 |
^ something |
656 | 943 |
|
944 |
"/ flushPending ifTrue:[ |
|
945 |
"/ self endEntry |
|
946 |
"/ ]. |
|
947 |
"/ (something isMemberOf:Character) ifTrue:[ |
|
948 |
"/ ((something == Character cr) or:[something == Character nl]) ifTrue:[ |
|
949 |
"/ ^ self cr |
|
950 |
"/ ]. |
|
951 |
"/ self insertCharAtCursor:something |
|
952 |
"/ ] ifFalse:[ |
|
953 |
"/ self insertStringAtCursor:(something printString). |
|
954 |
"/ self checkLineLimit |
|
955 |
"/ ]. |
|
956 |
"/ device flush |
|
957 |
||
928 | 958 |
"Modified: 11.1.1997 / 14:43:05 / cg" |
0 | 959 |
! |
960 |
||
961 |
nextPutAll:something |
|
928 | 962 |
"append all of something to my displayed text. |
963 |
This allows TextCollectors to be used Stream-wise" |
|
0 | 964 |
|
3958 | 965 |
self show:(currentEmphasis notNil |
966 |
ifTrue:[something emphasizeAllWith:currentEmphasis] |
|
967 |
ifFalse:[something]) |
|
656 | 968 |
|
928 | 969 |
"Modified: 11.1.1997 / 14:43:26 / cg" |
0 | 970 |
! |
971 |
||
5320 | 972 |
nextPutAll:count from:buffer startingAt:initialPosition |
973 |
"append count characters from buffer starting at initialPosition to my displayed text. |
|
6684 | 974 |
Answer the number of elements that were appended. |
5320 | 975 |
This allows TextCollectors to be used Stream-wise" |
976 |
||
977 |
|stringToShow| |
|
978 |
||
979 |
stringToShow := buffer copyFrom:initialPosition to:initialPosition+count-1. |
|
980 |
||
981 |
self show:(currentEmphasis notNil |
|
982 |
ifTrue:[stringToShow emphasizeAllWith:currentEmphasis] |
|
983 |
ifFalse:[stringToShow]). |
|
984 |
^ count. |
|
985 |
||
986 |
"Modified: 11.1.1997 / 14:43:26 / cg" |
|
987 |
! |
|
988 |
||
5603 | 989 |
printf:formatSpec |
6296 | 990 |
"convenient C-style formatted printing. |
991 |
For smalltalk specific formats, |
|
992 |
see documentation in PrintfScanf >> format_printf" |
|
5603 | 993 |
|
994 |
^ entryStream printf:formatSpec |
|
995 |
||
996 |
" |
|
997 |
1 to: 10 do:[:i | |
|
998 |
Transcript printf:'Hello World\n' |
|
999 |
]. |
|
1000 |
" |
|
1001 |
! |
|
1002 |
||
6111 | 1003 |
printf:formatSpec arguments:args |
1004 |
"convenient C-style formatted printing with an arbitrary number of arguments. |
|
6296 | 1005 |
Same as printf:withAll:, for protocol completeness. |
1006 |
For smalltalk specific formats, |
|
1007 |
see documentation in PrintfScanf >> format_printf" |
|
6111 | 1008 |
|
1009 |
^ entryStream printf:formatSpec withAll:args |
|
1010 |
||
1011 |
" |
|
1012 |
1 to: 10 do:[:i | |
|
1013 |
Transcript |
|
1014 |
printf:'[%d] Hello %s World - this is %s\n' |
|
1015 |
with:{i . 'my' . 'nice'} |
|
1016 |
]. |
|
1017 |
" |
|
1018 |
||
1019 |
"Created: / 23-02-2017 / 16:43:46 / cg" |
|
1020 |
! |
|
1021 |
||
5569 | 1022 |
printf:formatSpec with:arg1 |
6296 | 1023 |
"convenient C-style formatted printing with 1 argument. |
1024 |
For smalltalk specific formats, |
|
1025 |
see documentation in PrintfScanf >> format_printf" |
|
5569 | 1026 |
|
1027 |
^ entryStream printf:formatSpec with:arg1 |
|
1028 |
||
1029 |
" |
|
1030 |
1 to: 10 do:[:i | |
|
5603 | 1031 |
Transcript printf:'[%d] Hello World\n' with:i |
5569 | 1032 |
]. |
1033 |
" |
|
1034 |
! |
|
1035 |
||
1036 |
printf:formatSpec with:arg1 with:arg2 |
|
6296 | 1037 |
"convenient C-style formatted printing with 2 arguments. |
1038 |
For smalltalk specific formats, |
|
1039 |
see documentation in PrintfScanf >> format_printf" |
|
5569 | 1040 |
|
1041 |
^ entryStream printf:formatSpec with:arg1 with:arg2 |
|
1042 |
||
1043 |
" |
|
1044 |
1 to: 10 do:[:i | |
|
1045 |
Transcript |
|
1046 |
printf:'[%d] Hello World\n' with:i |
|
1047 |
]. |
|
1048 |
" |
|
1049 |
! |
|
1050 |
||
1051 |
printf:formatSpec with:arg1 with:arg2 with:arg3 |
|
6296 | 1052 |
"convenient C-style formatted printing with 3 arguments. |
1053 |
For smalltalk specific formats, |
|
1054 |
see documentation in PrintfScanf >> format_printf" |
|
5569 | 1055 |
|
1056 |
^ entryStream printf:formatSpec with:arg1 with:arg2 with:arg3 |
|
1057 |
||
1058 |
" |
|
1059 |
1 to: 10 do:[:i | |
|
1060 |
Transcript |
|
1061 |
printf:'[%d] Hello World\n' with:i |
|
1062 |
]. |
|
1063 |
" |
|
1064 |
! |
|
1065 |
||
1066 |
printf:formatSpec with:arg1 with:arg2 with:arg3 with:arg4 |
|
6296 | 1067 |
"convenient C-style formatted printing. |
1068 |
For smalltalk specific formats, |
|
1069 |
see documentation in PrintfScanf >> format_printf" |
|
5569 | 1070 |
|
1071 |
^ entryStream printf:formatSpec with:arg1 with:arg2 with:arg3 with:arg4 |
|
1072 |
||
1073 |
" |
|
1074 |
1 to: 10 do:[:i | |
|
1075 |
Transcript |
|
1076 |
printf:'[%d] Hello World\n' with:i |
|
1077 |
]. |
|
1078 |
" |
|
1079 |
! |
|
1080 |
||
1081 |
printf:formatSpec with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
|
6296 | 1082 |
"convenient C-style formatted printing. |
1083 |
For smalltalk specific formats, |
|
1084 |
see documentation in PrintfScanf >> format_printf" |
|
5569 | 1085 |
|
1086 |
^ entryStream printf:formatSpec with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
|
1087 |
||
1088 |
" |
|
1089 |
1 to: 10 do:[:i | |
|
1090 |
Transcript |
|
1091 |
printf:'[%d] Hello World\n' with:i |
|
1092 |
]. |
|
1093 |
" |
|
1094 |
! |
|
1095 |
||
1096 |
printf:formatSpec withAll:args |
|
6296 | 1097 |
"convenient C-style formatted printing with an arbitrary number of arguments. |
1098 |
For smalltalk specific formats, |
|
1099 |
see documentation in PrintfScanf >> format_printf" |
|
5569 | 1100 |
|
1101 |
^ entryStream printf:formatSpec withAll:args |
|
1102 |
||
1103 |
" |
|
1104 |
1 to: 10 do:[:i | |
|
1105 |
Transcript |
|
1106 |
printf:'[%d] Hello %s World - this is %s\n' |
|
1107 |
with:{i . 'my' . 'nice'} |
|
1108 |
]. |
|
1109 |
" |
|
1110 |
! |
|
1111 |
||
5130 | 1112 |
println |
1113 |
"for those used to Java/Javascript, a compatibility message. |
|
1114 |
Most useful inside expecco" |
|
1115 |
||
1116 |
self cr |
|
1117 |
! |
|
1118 |
||
1119 |
println:anObject |
|
1120 |
"for those used to Java/Javascript, a compatibility message. |
|
1121 |
Most useful inside expecco" |
|
1122 |
||
1123 |
self showCR:anObject |
|
1124 |
! |
|
1125 |
||
0 | 1126 |
show:anObject |
1127 |
"insert the argument aString at current cursor position" |
|
1128 |
||
4045 | 1129 |
|printString lines| |
0 | 1130 |
|
4045 | 1131 |
printString := anObject printString. |
928 | 1132 |
|
4643 | 1133 |
(self == Transcript) ifTrue:[ |
1134 |
DebugSendersOfMessagePattern notNil ifTrue:[ |
|
1135 |
(DebugSendersOfMessagePattern match:printString string) ifTrue:[ |
|
5733 | 1136 |
"to disable this breakpoint in the future, evaluate: |
1137 |
DebugSendersOfMessagePattern := nil |
|
1138 |
" |
|
4643 | 1139 |
self halt:('Transcript: text matches: "', printString,'"'). |
1140 |
]. |
|
4122 | 1141 |
]. |
4643 | 1142 |
TraceSendersOfMessagePattern notNil ifTrue:[ |
1143 |
(TraceSendersOfMessagePattern match:printString string) ifTrue:[ |
|
1144 |
printString := self senderTraceString,': ',printString |
|
1145 |
]. |
|
4365 | 1146 |
]. |
1147 |
]. |
|
4105
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
1148 |
|
4045 | 1149 |
(printString includes:(Character cr)) ifTrue:[ |
1150 |
lines := printString asStringCollection. |
|
653 | 1151 |
lines keysAndValuesDo:[:nr :line | |
1562
9b7557a81849
made the number of buffered lines an instVar.
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
1152 |
(nr == lines size |
4045 | 1153 |
and:[(printString endsWith:(Character cr)) not]) ifTrue:[ |
653 | 1154 |
"/ the last one. |
1155 |
self show:line |
|
1156 |
] ifFalse:[ |
|
1157 |
self showCR:line |
|
1158 |
]. |
|
1159 |
]. |
|
1160 |
^ self. |
|
308
b216a5efa2c8
handle show: with a string containing cr's
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1161 |
]. |
b216a5efa2c8
handle show: with a string containing cr's
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1162 |
|
1026 | 1163 |
access critical:[ |
4650 | 1164 |
"/ self ~~ Transcript ifTrue:['xs' printCR]. |
3295
37cb2b5d579a
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3248
diff
changeset
|
1165 |
outstandingLine size ~~ 0 ifTrue:[ |
4045 | 1166 |
outstandingLine := outstandingLine , printString |
1026 | 1167 |
] ifFalse:[ |
4045 | 1168 |
outstandingLine := printString |
653 | 1169 |
]. |
1026 | 1170 |
collecting ifTrue:[ |
1171 |
flushPending ifFalse:[ |
|
1172 |
self installDelayedUpdate |
|
1312
eaa44f7649f5
flush after some lines have been collected
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1173 |
] ifTrue:[ |
1562
9b7557a81849
made the number of buffered lines an instVar.
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
1174 |
outstandingLines size > collectSize ifTrue:[ |
1312
eaa44f7649f5
flush after some lines have been collected
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1175 |
self endEntry |
eaa44f7649f5
flush after some lines have been collected
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
1176 |
] |
1026 | 1177 |
] |
1178 |
] ifFalse:[ |
|
1179 |
self endEntry |
|
653 | 1180 |
] |
1026 | 1181 |
]. |
0 | 1182 |
|
4411 | 1183 |
"Modified: / 24-03-2012 / 20:04:10 / cg" |
4428 | 1184 |
"Modified (format): / 02-06-2012 / 01:54:55 / cg" |
6588 | 1185 |
"Modified: / 29-05-2019 / 11:59:55 / Claus Gittinger" |
1617 | 1186 |
! |
1187 |
||
1188 |
showCR:anObject |
|
1189 |
"insert the argument aString at current cursor position, |
|
1190 |
and advance to the next line. This is the same as a #show: |
|
1191 |
followed by a #cr." |
|
1192 |
||
5302 | 1193 |
|printString lines crlf| |
1617 | 1194 |
|
4045 | 1195 |
printString := anObject printString. |
6112 | 1196 |
printString isEmptyOrNil ifTrue:[ |
2689
ddaa98a64bd5
Fix #showCR: when displaying multi-line strings
Stefan Vogel <sv@exept.de>
parents:
2632
diff
changeset
|
1197 |
self cr. |
ddaa98a64bd5
Fix #showCR: when displaying multi-line strings
Stefan Vogel <sv@exept.de>
parents:
2632
diff
changeset
|
1198 |
^ self. |
1617 | 1199 |
]. |
1200 |
||
4643 | 1201 |
self == Transcript ifTrue:[ |
1202 |
DebugSendersOfMessagePattern notNil ifTrue:[ |
|
1203 |
(DebugSendersOfMessagePattern match:printString string) ifTrue:[ |
|
1204 |
"/ to disable this right from inside the debugger, evaluate: |
|
5454 | 1205 |
" |
1206 |
DebugSendersOfMessagePattern := nil |
|
1207 |
" |
|
4643 | 1208 |
self halt:('Transcript: text matches: "', printString, '"'). |
1209 |
]. |
|
4365 | 1210 |
]. |
4643 | 1211 |
TraceSendersOfMessagePattern notNil ifTrue:[ |
1212 |
(TraceSendersOfMessagePattern match:printString string) ifTrue:[ |
|
1213 |
printString := self senderTraceString,': ',printString |
|
1214 |
]. |
|
4122 | 1215 |
]. |
4105
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
1216 |
]. |
c2c3a96f8757
debug support: who sends a message
Claus Gittinger <cg@exept.de>
parents:
4073
diff
changeset
|
1217 |
|
5302 | 1218 |
crlf := String crlf. |
1219 |
(printString includesAny:crlf) ifTrue:[ |
|
4045 | 1220 |
lines := printString asStringCollection. |
2689
ddaa98a64bd5
Fix #showCR: when displaying multi-line strings
Stefan Vogel <sv@exept.de>
parents:
2632
diff
changeset
|
1221 |
lines do:[:line| |
5302 | 1222 |
|lineWithoutEOL| |
1223 |
||
4106 | 1224 |
(line endsWith:Character nl) ifTrue:[ |
5302 | 1225 |
(line endsWith:crlf) ifTrue:[ |
1226 |
lineWithoutEOL := line copyButLast:2. |
|
4106 | 1227 |
] ifFalse:[ |
5302 | 1228 |
lineWithoutEOL := line copyButLast:1. |
4106 | 1229 |
] |
2805 | 1230 |
] ifFalse:[ |
4106 | 1231 |
(line endsWith:Character return) ifTrue:[ |
5302 | 1232 |
lineWithoutEOL := line copyButLast:1. |
4106 | 1233 |
] ifFalse:[ |
5302 | 1234 |
lineWithoutEOL := line |
4106 | 1235 |
] |
5302 | 1236 |
]. |
1237 |
self addLine:lineWithoutEOL. |
|
1617 | 1238 |
]. |
1239 |
^ self. |
|
1240 |
]. |
|
4106 | 1241 |
self addLine:printString |
4365 | 1242 |
|
4410 | 1243 |
"Modified: / 24-03-2012 / 20:00:08 / cg" |
6112 | 1244 |
"Modified: / 27-02-2017 / 15:22:47 / stefan" |
4073 | 1245 |
! |
1246 |
||
4473 | 1247 |
space |
1248 |
self show:' ' |
|
1249 |
! |
|
1250 |
||
4073 | 1251 |
tab |
1252 |
"append a tab-character to the stream. |
|
1253 |
This is only allowed, if the receiver supports writing." |
|
1254 |
||
1255 |
self nextPut:(Character tab) |
|
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1256 |
! ! |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1257 |
|
2746 | 1258 |
!TextCollector methodsFor:'stream messages-emphasis'! |
1822
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1259 |
|
6588 | 1260 |
bgColor:aColorOrNil |
1261 |
"followup characters sent with stream messages (nextPut/nextPutAll) |
|
1262 |
will be rendered with background color in aColorOrNil. |
|
1263 |
Does not affect show/showCR" |
|
1264 |
||
1265 |
aColorOrNil isNil ifTrue:[ |
|
4658 | 1266 |
currentEmphasis := Text removeEmphasis:#backgroundColor from:currentEmphasis |
1267 |
] ifFalse:[ |
|
6588 | 1268 |
currentEmphasis := Text addEmphasis:(#backgroundColor->aColorOrNil) to:currentEmphasis |
4658 | 1269 |
] |
6588 | 1270 |
|
1271 |
"Modified (comment): / 29-05-2019 / 12:01:21 / Claus Gittinger" |
|
2539 | 1272 |
! |
1273 |
||
1822
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1274 |
bold |
6588 | 1275 |
"switch to bold |
1276 |
followup characters sent with stream messages (nextPut/nextPutAll) |
|
1277 |
will be rendered in a bold font. |
|
1278 |
Does not affect show/showCR" |
|
3205 | 1279 |
|
4658 | 1280 |
currentEmphasis := Text addEmphasis:#bold to:currentEmphasis |
6588 | 1281 |
|
1282 |
" |
|
1283 |
Transcript |
|
1284 |
nextPutAll:'hello'; |
|
1285 |
bold; |
|
1286 |
nextPutAll:' world'; |
|
1287 |
notBold; |
|
1288 |
nextPutLine:' again' |
|
1289 |
" |
|
1290 |
||
1291 |
"Modified (comment): / 29-05-2019 / 12:05:08 / Claus Gittinger" |
|
1822
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1292 |
! |
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1293 |
|
6588 | 1294 |
color:aColorOrNil |
1295 |
"switch color |
|
1296 |
followup characters sent with stream messages (nextPut/nextPutAll) |
|
1297 |
will be rendered in aColorOrNil. |
|
1298 |
Does not affect show/showCR" |
|
1299 |
||
6162 | 1300 |
currentEmphasis := Text removeEmphasis:#color from:currentEmphasis. |
6588 | 1301 |
aColorOrNil notNil ifTrue:[ |
1302 |
currentEmphasis := Text addEmphasis:(#color->aColorOrNil) to:currentEmphasis |
|
4658 | 1303 |
]. |
1822
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1304 |
|
6588 | 1305 |
" |
1306 |
Transcript |
|
1307 |
nextPutAll:'hello'; |
|
1308 |
color:Color red; |
|
1309 |
nextPutAll:' world'; |
|
1310 |
color:nil; |
|
1311 |
nextPutLine:' again' |
|
1312 |
" |
|
1313 |
" |
|
1314 |
Transcript |
|
1315 |
showCR:('hello' allBold , ' world') |
|
1316 |
" |
|
1317 |
||
6162 | 1318 |
"Modified: / 30-05-2017 / 09:37:26 / cg" |
6588 | 1319 |
"Modified (comment): / 29-05-2019 / 12:05:33 / Claus Gittinger" |
1320 |
! |
|
1321 |
||
1322 |
emphasis:anEmphasisCollectionOrNil |
|
1323 |
"change emphasis |
|
1324 |
followup characters sent with stream messages (nextPut/nextPutAll) |
|
1325 |
will be rendered with anEmphasisCollectionOrNil. |
|
1326 |
Does not affect show/showCR" |
|
1327 |
||
1328 |
currentEmphasis := anEmphasisCollectionOrNil |
|
1329 |
||
1330 |
" |
|
1331 |
Transcript |
|
1332 |
nextPutAll:'hello '; |
|
1333 |
emphasis:#( bold underline ); |
|
1334 |
nextPutAll:'world'; |
|
1335 |
emphasis:nil; |
|
1336 |
nextPutLine:' again' |
|
1337 |
" |
|
1338 |
" |
|
1339 |
Transcript |
|
1340 |
nextPutAll:'hello'; |
|
1341 |
bold; |
|
1342 |
nextPutAll:' world'; |
|
1343 |
notBold; |
|
1344 |
nextPutLine:' again' |
|
1345 |
" |
|
1346 |
||
1347 |
"Created: / 29-05-2019 / 11:45:35 / Claus Gittinger" |
|
1822
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1348 |
! |
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1349 |
|
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1350 |
italic |
6588 | 1351 |
"switch to italic |
1352 |
followup characters sent with stream messages (nextPut/nextPutAll) |
|
1353 |
will be rendered in an italic font. |
|
1354 |
Does not affect show/showCR" |
|
1355 |
||
6172 | 1356 |
currentEmphasis := Text addEmphasis:(Text italicEmphasis) to:currentEmphasis |
1357 |
||
1358 |
"Modified: / 20-06-2017 / 08:35:20 / cg" |
|
6588 | 1359 |
"Modified (comment): / 29-05-2019 / 12:03:02 / Claus Gittinger" |
1822
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1360 |
! |
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1361 |
|
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1362 |
normal |
6588 | 1363 |
"switch back to normal |
1364 |
followup characters sent with stream messages (nextPut/nextPutAll) |
|
1365 |
will be rendered in the default font without color" |
|
1366 |
||
1822
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1367 |
currentEmphasis := nil |
6588 | 1368 |
|
1369 |
"Modified (comment): / 29-05-2019 / 12:03:40 / Claus Gittinger" |
|
1822
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1370 |
! |
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1371 |
|
4659 | 1372 |
notBold |
6588 | 1373 |
"switch to non-bold |
1374 |
followup characters sent with stream messages (nextPut/nextPutAll) |
|
1375 |
will be rendered in a non-bold font. |
|
1376 |
Does not affect show/showCR" |
|
4659 | 1377 |
|
1378 |
currentEmphasis := Text removeEmphasis:#bold from:currentEmphasis |
|
6588 | 1379 |
|
1380 |
"Modified (comment): / 29-05-2019 / 12:04:00 / Claus Gittinger" |
|
4659 | 1381 |
! |
1382 |
||
1383 |
notItalic |
|
6588 | 1384 |
"switch to non-italic |
1385 |
followup characters sent with stream messages (nextPut/nextPutAll) |
|
1386 |
will be rendered in a non-italic font. |
|
1387 |
Does not affect show/showCR" |
|
4659 | 1388 |
|
6172 | 1389 |
currentEmphasis := Text removeEmphasis:(Text italicEmphasis) from:currentEmphasis |
1390 |
||
1391 |
"Modified: / 20-06-2017 / 08:35:26 / cg" |
|
6588 | 1392 |
"Modified (comment): / 29-05-2019 / 12:04:09 / Claus Gittinger" |
4659 | 1393 |
! |
1394 |
||
1395 |
notReverse |
|
6588 | 1396 |
"switch back default colors" |
1397 |
||
4659 | 1398 |
currentEmphasis := Text removeEmphasis:#color from:currentEmphasis. |
1399 |
currentEmphasis := Text removeEmphasis:#backgroundColor from:currentEmphasis. |
|
6588 | 1400 |
|
1401 |
"Modified (comment): / 29-05-2019 / 11:42:52 / Claus Gittinger" |
|
4659 | 1402 |
! |
1403 |
||
1404 |
notUnderline |
|
6588 | 1405 |
"switch to non-underline |
1406 |
followup characters sent with stream messages (nextPut/nextPutAll) |
|
1407 |
will be rendered without underline. |
|
1408 |
Does not affect show/showCR" |
|
1409 |
||
4659 | 1410 |
currentEmphasis := Text removeEmphasis:#underline from:currentEmphasis |
1411 |
||
6588 | 1412 |
"Created: / 26-03-1999 / 14:27:07 / cg" |
1413 |
"Modified (comment): / 29-05-2019 / 12:04:32 / Claus Gittinger" |
|
4659 | 1414 |
! |
1415 |
||
1822
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1416 |
reverse |
6588 | 1417 |
"switch to reverse |
1418 |
followup characters sent with stream messages (nextPut/nextPutAll) |
|
1419 |
will be rendered with reversed colors. |
|
1420 |
Does not affect show/showCR" |
|
1421 |
||
4658 | 1422 |
currentEmphasis := Text addEmphasis:(#color->bgColor) to:currentEmphasis. |
1423 |
currentEmphasis := Text addEmphasis:(#backgroundColor->fgColor) to:currentEmphasis. |
|
6588 | 1424 |
|
1425 |
"Modified (comment): / 29-05-2019 / 12:04:52 / Claus Gittinger" |
|
1822
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1426 |
! |
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1427 |
|
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1428 |
underline |
6588 | 1429 |
"switch to underline |
1430 |
followup characters sent with stream messages (nextPut/nextPutAll) |
|
1431 |
will be rendered with underline. |
|
1432 |
Does not affect show/showCR" |
|
1433 |
||
4658 | 1434 |
currentEmphasis := Text addEmphasis:#underline to:currentEmphasis |
1822
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1435 |
|
6588 | 1436 |
"Created: / 26-03-1999 / 14:27:07 / cg" |
1437 |
"Modified (comment): / 29-05-2019 / 12:04:39 / Claus Gittinger" |
|
1822
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1438 |
! ! |
9abf58839e67
added #color: and #underline
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
1439 |
|
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1440 |
!TextCollector methodsFor:'transcript specials'! |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1441 |
|
6673 | 1442 |
assertEndEntry |
1443 |
"assert there is no pending collected output" |
|
1444 |
||
1445 |
self assert:(outstandingLines isEmptyOrNil). |
|
1446 |
self assert:(outstandingLine isEmptyOrNil) |
|
1447 |
! |
|
1448 |
||
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1449 |
beTranscript |
928 | 1450 |
"make the receiver be the systemTranscript; this one |
5575 | 1451 |
is accessible via the global Transcript and gets relevant |
928 | 1452 |
system messages from various places." |
1453 |
||
3852
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
1454 |
self beTranscript:#Transcript |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
1455 |
|
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
1456 |
"Modified: / 2.11.1997 / 22:34:47 / cg" |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
1457 |
! |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
1458 |
|
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
1459 |
beTranscript:name |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
1460 |
"make the receiver be the systemTranscript; this one |
5575 | 1461 |
is accessible via the global Transcript and gets relevant |
3852
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
1462 |
system messages from various places." |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
1463 |
|
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1464 |
|fg bg cFg cBg| |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1465 |
|
5908 | 1466 |
self assert:((Smalltalk includesKey:name) not |
1467 |
or:[ (Smalltalk at:name) isBehavior not ]). |
|
3852
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
1468 |
Smalltalk at:name put:self. |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1469 |
|
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1470 |
" |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1471 |
fancy feature: whenever Transcript is closed, reset to StdError |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1472 |
" |
1421
afef284eadc4
only reset Transcript to stdErr, if I really am the transcript.
ca
parents:
1389
diff
changeset
|
1473 |
self destroyAction:[ |
3852
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
1474 |
self == (Smalltalk at:name) ifTrue:[ |
8322d7c41f1c
refactored newTranscript to allow for another transcript to be opened
Claus Gittinger <cg@exept.de>
parents:
3774
diff
changeset
|
1475 |
Smalltalk at:name put:Stderr |
1421
afef284eadc4
only reset Transcript to stdErr, if I really am the transcript.
ca
parents:
1389
diff
changeset
|
1476 |
] |
afef284eadc4
only reset Transcript to stdErr, if I really am the transcript.
ca
parents:
1389
diff
changeset
|
1477 |
]. |
0 | 1478 |
|
928 | 1479 |
"/ user may prefer a special color for this one; |
1480 |
"/ look into the style definitions ... |
|
1481 |
||
1389 | 1482 |
fg := styleSheet colorAt:'transcript.foregroundColor' default:self foregroundColor. |
1483 |
bg := styleSheet colorAt:'transcript.backgroundColor' default:self backgroundColor. |
|
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1484 |
self foregroundColor:fg backgroundColor:bg. |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1485 |
self viewBackground:bg. |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1486 |
|
1389 | 1487 |
cFg := styleSheet colorAt:'transcript.cursorForegroundColor' default:bg. |
1488 |
cBg := styleSheet colorAt:'transcript.cursorBackgroundColor' default:fg. |
|
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1489 |
self cursorForegroundColor:cFg backgroundColor:cBg. |
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1490 |
|
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1491 |
"self lineLimit:1000. " "or whatever you think makes sense" |
928 | 1492 |
|
1389 | 1493 |
"Modified: / 2.11.1997 / 22:34:47 / cg" |
2928
24991431c7e0
added #clear (to clear its contents)
Claus Gittinger <cg@exept.de>
parents:
2831
diff
changeset
|
1494 |
! |
24991431c7e0
added #clear (to clear its contents)
Claus Gittinger <cg@exept.de>
parents:
2831
diff
changeset
|
1495 |
|
4643 | 1496 |
beginEntry |
1497 |
"noop for now, ST80 compatibility" |
|
1498 |
||
1499 |
^ self |
|
1500 |
||
1501 |
"Created: / 4.3.1998 / 11:08:14 / stefan" |
|
1502 |
! |
|
1503 |
||
2928
24991431c7e0
added #clear (to clear its contents)
Claus Gittinger <cg@exept.de>
parents:
2831
diff
changeset
|
1504 |
clear |
3119 | 1505 |
self endEntry. |
2928
24991431c7e0
added #clear (to clear its contents)
Claus Gittinger <cg@exept.de>
parents:
2831
diff
changeset
|
1506 |
self contents:nil. |
24991431c7e0
added #clear (to clear its contents)
Claus Gittinger <cg@exept.de>
parents:
2831
diff
changeset
|
1507 |
|
24991431c7e0
added #clear (to clear its contents)
Claus Gittinger <cg@exept.de>
parents:
2831
diff
changeset
|
1508 |
" |
24991431c7e0
added #clear (to clear its contents)
Claus Gittinger <cg@exept.de>
parents:
2831
diff
changeset
|
1509 |
Transcript clear |
24991431c7e0
added #clear (to clear its contents)
Claus Gittinger <cg@exept.de>
parents:
2831
diff
changeset
|
1510 |
" |
3774 | 1511 |
! |
1512 |
||
4650 | 1513 |
delayedEndEntry |
1514 |
"flush collected output; displaying all that has been buffered so far" |
|
1515 |
||
1516 |
"/ self ~~ Transcript ifTrue:[ 'de0' printCR ]. |
|
1517 |
inFlush ifTrue:[ |
|
1518 |
"/ self ~~ Transcript ifTrue:[ 'deX' printCR ]. |
|
1519 |
^ self |
|
1520 |
]. |
|
1521 |
||
1522 |
"/ self ~~ Transcript ifTrue:[ 'de1' printCR ]. |
|
1523 |
access owner == Processor activeProcess ifTrue:[ |
|
1524 |
"/ self ~~ Transcript ifTrue:[ 'de2' printCR ]. |
|
1525 |
self installDelayedUpdate. |
|
1526 |
^ self |
|
1527 |
]. |
|
1528 |
||
1529 |
self endEntry |
|
1530 |
! |
|
1531 |
||
4643 | 1532 |
endEntry |
1533 |
"flush collected output; displaying all that has been buffered so far" |
|
1534 |
||
5644 | 1535 |
|nLines lines| |
4643 | 1536 |
|
4965 | 1537 |
((outstandingLines isEmptyOrNil) and:[outstandingLine isEmptyOrNil]) ifTrue:[ |
4650 | 1538 |
"/ self ~~ Transcript ifTrue:[ 'e- ' print. thisContext sender selector printCR ]. |
1539 |
^ self |
|
1540 |
]. |
|
4965 | 1541 |
shown ifFalse:[ |
1542 |
"/ when iconified or not yet shown, keep |
|
1543 |
"/ collecting. But not too much ... |
|
1544 |
outstandingLines size < 300 ifTrue:[ |
|
1545 |
"/ self ~~ Transcript ifTrue:[ 'eC' printCR ]. |
|
1546 |
access critical:[ |
|
1547 |
flushPending ifFalse:[ |
|
1548 |
self installDelayedUpdate. |
|
1549 |
]. |
|
1550 |
]. |
|
1551 |
^ self |
|
1552 |
] |
|
1553 |
]. |
|
4650 | 1554 |
|
6673 | 1555 |
(device isNil |
1556 |
or:[device isOpen not |
|
1557 |
or:[self drawableId isNil |
|
1558 |
]]) ifTrue:[ |
|
4961 | 1559 |
"on snapshot load, Transcript may not yet be re-created. |
1560 |
Write to Stderr then." |
|
1561 |
Stderr notNil ifTrue:[ |
|
4963 | 1562 |
outstandingLines do:[:eachLine| |
1563 |
eachLine printOn:Stderr. |
|
1564 |
]. |
|
4961 | 1565 |
outstandingLines := nil. |
1566 |
outstandingLine notNil ifTrue:[ |
|
1567 |
outstandingLine printOn:Stderr. |
|
1568 |
outstandingLine := nil. |
|
1569 |
]. |
|
1570 |
Stderr cr. |
|
1571 |
]. |
|
1572 |
^ self. |
|
1573 |
]. |
|
1574 |
||
4643 | 1575 |
access critical:[ |
1576 |
collecting ifTrue:[ |
|
1577 |
flushBlock notNil ifTrue:[ |
|
1578 |
Processor removeTimedBlock:flushBlock. |
|
1579 |
]. |
|
1580 |
]. |
|
1581 |
||
4650 | 1582 |
"/ self ~~ Transcript ifTrue:[ 'e1' printCR ]. |
4643 | 1583 |
inFlush ifFalse:[ |
4650 | 1584 |
"/ self ~~ Transcript ifTrue:[ 'e2' printCR ]. |
4643 | 1585 |
inFlush := true. |
1586 |
[ |
|
1587 |
flushPending := false. |
|
5147 | 1588 |
self withAutoIndent:false do:[ |
4650 | 1589 |
"/ self ~~ Transcript ifTrue:[ 'e3 "' print. outstandingLine print. '" ' print. outstandingLine asByteArray hexPrintString print. ' ' printCR. |
1590 |
"/ (outstandingLines ? #()) do:[:l | '"' print. l print. '" ' print. l asByteArray hexPrintString printCR ]]. |
|
1591 |
(nLines := outstandingLines size) ~~ 0 ifTrue:[ |
|
1592 |
"/ self ~~ Transcript ifTrue:[ 'e4' printCR.]. |
|
4643 | 1593 |
"insert the bunch of lines - if any" |
1594 |
lines := outstandingLines. |
|
1595 |
outstandingLines := nil. |
|
1596 |
||
4650 | 1597 |
"/ self ~~ Transcript ifTrue:[ 'e5 ' print. nLines printCR.]. |
4643 | 1598 |
(nLines ~~ 0) ifTrue:[ |
1599 |
self isInInsertMode ifTrue:[ |
|
4650 | 1600 |
"/ self ~~ Transcript ifTrue:[ (nLines > 1 and:[(lines second ? '') startsWith:'111']) ifTrue:['e6a' printCR.self halt.]]. |
4643 | 1601 |
self insertLines:lines withCR:true. |
4650 | 1602 |
"/ self ~~ Transcript ifTrue:[ (nLines > 1 and:[(lines second ? '') startsWith:'111']) ifTrue:['e6a' printCR.self halt.]]. |
4643 | 1603 |
] ifFalse:[ |
1604 |
self replaceLines:lines withCR:true |
|
1605 |
]. |
|
1606 |
alwaysAppendAtEnd ifTrue:[ |
|
1607 |
self cursorToEnd. |
|
1608 |
]. |
|
1609 |
(cursorLine >= (firstLineShown + nFullLinesShown)) ifTrue:[ |
|
5137 | 1610 |
scrollLocked ifFalse:[ |
1611 |
self withCursorOffDo:[ |
|
6341 | 1612 |
self scrollDownLines:nLines |
5137 | 1613 |
] |
1614 |
]. |
|
4643 | 1615 |
]. |
1616 |
]. |
|
1617 |
]. |
|
1618 |
||
4650 | 1619 |
"/ self ~~ Transcript ifTrue:[ (nLines > 1 and:[(lines second ? '') startsWith:'111']) ifTrue:['e7a' printCR.self halt.]]. |
4643 | 1620 |
"and the last partial line - if any" |
1621 |
outstandingLine size ~~ 0 ifTrue:[ |
|
1622 |
self isInInsertMode ifTrue:[ |
|
1623 |
self insertStringAtCursor:outstandingLine. |
|
1624 |
] ifFalse:[ |
|
1625 |
self replaceStringAtCursor:outstandingLine. |
|
1626 |
]. |
|
1627 |
outstandingLine := ''. |
|
1628 |
]. |
|
1629 |
self checkLineLimit. |
|
1630 |
"/ device flush. |
|
5147 | 1631 |
]. |
4643 | 1632 |
] ensure:[ |
1633 |
inFlush := false. |
|
1634 |
] |
|
1635 |
]. |
|
1636 |
]. |
|
1637 |
||
6341 | 1638 |
"Modified: / 09-11-1998 / 21:17:56 / cg" |
1639 |
"Modified: / 13-06-2018 / 22:00:27 / Claus Gittinger" |
|
4643 | 1640 |
! |
1641 |
||
3774 | 1642 |
flash |
1643 |
"make sure everything is visible, before flashing" |
|
1644 |
||
1645 |
self endEntry. |
|
1646 |
super flash. |
|
5408 | 1647 |
! |
1648 |
||
6219 | 1649 |
flash:messageOrNil withColor:flashColor |
5408 | 1650 |
"make sure everything is visible, before flashing" |
1651 |
||
1652 |
self endEntry. |
|
6219 | 1653 |
super flash:messageOrNil withColor:flashColor. |
1654 |
||
1655 |
"Modified (format): / 21-10-2017 / 23:13:42 / cg" |
|
0 | 1656 |
! ! |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1657 |
|
928 | 1658 |
!TextCollector class methodsFor:'documentation'! |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1659 |
|
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1660 |
version |
5408 | 1661 |
^ '$Header$' |
3958 | 1662 |
! |
1663 |
||
1664 |
version_CVS |
|
5408 | 1665 |
^ '$Header$' |
363
d780a45df2d4
MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents:
308
diff
changeset
|
1666 |
! ! |
2632 | 1667 |
|
4503 | 1668 |
|
2025
0c9729befabc
allow current transcript to be reassigned temporarily
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1669 |
TextCollector initialize! |