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