TextCollector.st
author Claus Gittinger <cg@exept.de>
Mon, 27 Jul 1998 16:17:03 +0200
changeset 1610 b05a3e405b33
parent 1598 c9f30d02ad4f
child 1611 779762acd916
permissions -rw-r--r--
allow change of collectSize and updateTimeDelay.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
EditTextView subclass:#TextCollector
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
    14
	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
    15
		outstandingLine flushBlock flushPending inFlush collecting
1562
9b7557a81849 made the number of buffered lines an instVar.
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
    16
		timeDelay access currentEmphasis alwaysAppendAtEnd collectSize'
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
    17
	classVariableNames:''
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
    18
	poolDictionaries:''
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
    19
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    20
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    21
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
    22
!TextCollector class methodsFor:'documentation'!
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    23
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    24
copyright
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    25
"
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    26
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
    27
	      All Rights Reserved
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    28
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    29
 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
    30
 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
    31
 inclusion of the above copyright notice.   This software may not
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    32
 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
    33
 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
    34
 hereby transferred.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    35
"
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    36
!
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    37
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    38
documentation
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    39
"
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    40
    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
    41
    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
    42
    received text.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    43
    Its main use in the system is the Transcript, but it can also be used for
110
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
    44
    things like trace-windows, errorLogs etc.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    45
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    46
    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
    47
    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
    48
    data - finally updating the whole chunk in one piece. 
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    49
    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
    50
    (on fast displays this is less of a problem).
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    51
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    52
    The total number of lines kept is controlled by lineLimit, if more lines 
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    53
    than this limit are added at the bottom, the textcollector will forget lines 
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    54
    at the top. 
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    55
    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
    56
    of memory then ...
77
565b052f5277 *** empty log message ***
claus
parents: 63
diff changeset
    57
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 553
diff changeset
    58
    [StyleSheet paramters (transcript only):]
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 553
diff changeset
    59
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 553
diff changeset
    60
        transcriptForegroundColor       defaults to textForegroundColor
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 553
diff changeset
    61
        transcriptBackgroundColor'      defaults to textBackgroundColor.
77
565b052f5277 *** empty log message ***
claus
parents: 63
diff changeset
    62
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 553
diff changeset
    63
        transcriptCursorForegroundColor
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 553
diff changeset
    64
        transcriptCursorBackgroundColor
77
565b052f5277 *** empty log message ***
claus
parents: 63
diff changeset
    65
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 553
diff changeset
    66
    [author:]
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 553
diff changeset
    67
        Claus Gittinger
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 553
diff changeset
    68
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 553
diff changeset
    69
    [see also:]
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 553
diff changeset
    70
        CodeView EditTextView
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 553
diff changeset
    71
        ActorStream
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    72
"
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    73
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    74
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
    75
!TextCollector class methodsFor:'instance creation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    76
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    77
newTranscript
778
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
    78
    "create and open a new transcript.
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
    79
     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
    80
     were two different views. It is no longer recommended."
110
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
    81
130
claus
parents: 119
diff changeset
    82
    |topView transcript f v lines cols|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    83
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    84
    topView := StandardSystemView label:'Transcript' minExtent:(100 @ 100).
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    85
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    86
    v := HVScrollableView for:self miniScrollerH:true miniScrollerV:false in:topView.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    87
    v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    88
    transcript := v scrolledView.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    89
    "transcript partialLines:false."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    90
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    91
    f := transcript font.
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    92
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    93
    "
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    94
     should add the height of the frame & scrollbars to be exact ...
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    95
    "
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    96
    cols := self defaultTranscriptSize x.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    97
    lines := self defaultTranscriptSize y.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    98
    topView extent:(((f widthOf:'x') * cols) @ (f height * lines)).
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    99
110
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   100
    transcript beTranscript.
59
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   101
80
5a878a1eebf2 *** empty log message ***
claus
parents: 77
diff changeset
   102
    "
5a878a1eebf2 *** empty log message ***
claus
parents: 77
diff changeset
   103
     run it at a slightly higher prio, to allow for
5a878a1eebf2 *** empty log message ***
claus
parents: 77
diff changeset
   104
     delayed buffered updates to be performed
5a878a1eebf2 *** empty log message ***
claus
parents: 77
diff changeset
   105
    "
5a878a1eebf2 *** empty log message ***
claus
parents: 77
diff changeset
   106
    topView openWithPriority:(Processor userSchedulingPriority + 1).
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   107
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   108
    ^ transcript
110
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   109
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   110
    "
1026
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   111
     TextCollector newTranscript.
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   112
     Transcript lineLimit:3000.
110
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   113
    "
778
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   114
1026
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   115
    "Modified: 17.2.1997 / 18:20:27 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   116
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   117
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   118
!TextCollector class methodsFor:'defaults'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   119
1610
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   120
defaultCollectSize
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   121
    "the number of lines buffered for delayed update"
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   122
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   123
    ^ 50
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   124
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   125
    "Modified: / 27.7.1998 / 16:14:51 / cg"
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   126
!
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   127
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   128
defaultLineLimit
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   129
    "the number of lines remembered by default"
59
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   130
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   131
    ^ 600
59
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   132
!
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   133
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   134
defaultTimeDelay
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   135
    "the time in seconds to wait & collect by default"
36
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   136
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   137
    ^ 0.3 
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   138
!
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   139
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   140
defaultTranscriptSize
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   141
    "the number of cols/lines by which the Transcript should come up"
110
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   142
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   143
    ^ 70@11
110
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   144
! !
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   145
1500
dee7275372f1 checkin from browser
ca
parents: 1491
diff changeset
   146
!TextCollector methodsFor:'ST-80 compatibility'!
dee7275372f1 checkin from browser
ca
parents: 1491
diff changeset
   147
dee7275372f1 checkin from browser
ca
parents: 1491
diff changeset
   148
deselect
dee7275372f1 checkin from browser
ca
parents: 1491
diff changeset
   149
    self unselect
1504
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   150
!
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   151
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   152
flush
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   153
    self endEntry.
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   154
    super flush
1500
dee7275372f1 checkin from browser
ca
parents: 1491
diff changeset
   155
! !
dee7275372f1 checkin from browser
ca
parents: 1491
diff changeset
   156
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   157
!TextCollector methodsFor:'accessing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   158
1467
5c09bb2dadef Add (dummy fore now) #beginEntry for ST80 compat.
Stefan Vogel <sv@exept.de>
parents: 1421
diff changeset
   159
beginEntry
5c09bb2dadef Add (dummy fore now) #beginEntry for ST80 compat.
Stefan Vogel <sv@exept.de>
parents: 1421
diff changeset
   160
    "noop for now, ST80 compatibility"
5c09bb2dadef Add (dummy fore now) #beginEntry for ST80 compat.
Stefan Vogel <sv@exept.de>
parents: 1421
diff changeset
   161
5c09bb2dadef Add (dummy fore now) #beginEntry for ST80 compat.
Stefan Vogel <sv@exept.de>
parents: 1421
diff changeset
   162
    ^ self
5c09bb2dadef Add (dummy fore now) #beginEntry for ST80 compat.
Stefan Vogel <sv@exept.de>
parents: 1421
diff changeset
   163
5c09bb2dadef Add (dummy fore now) #beginEntry for ST80 compat.
Stefan Vogel <sv@exept.de>
parents: 1421
diff changeset
   164
    "Created: / 4.3.1998 / 11:08:14 / stefan"
5c09bb2dadef Add (dummy fore now) #beginEntry for ST80 compat.
Stefan Vogel <sv@exept.de>
parents: 1421
diff changeset
   165
!
5c09bb2dadef Add (dummy fore now) #beginEntry for ST80 compat.
Stefan Vogel <sv@exept.de>
parents: 1421
diff changeset
   166
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   167
collect:aBoolean
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   168
    "turn on/off collecting - if on, do not output immediately
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   169
     but collect text and output en-bloque after some time delta"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   170
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   171
    collecting := aBoolean
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   172
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   173
1610
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   174
collectSize:numberOfLines
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   175
    "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
   176
     the receiver will force update of the view, 
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   177
     whenever that many lines have been collected
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   178
     (or the updateTimeDelay interval has passed).
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   179
     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
   180
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   181
    collectSize := numberOfLines
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   182
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   183
    "Modified: / 27.7.1998 / 16:16:00 / cg"
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   184
!
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   185
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   186
destroyAction:aBlock
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   187
    "define the action to be performed when I get destroyed.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   188
     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
   189
     when closed. (see TextCollectorclass>>newTranscript)"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   190
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   191
    destroyAction := aBlock
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   192
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   193
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   194
endEntry
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   195
    "flush collected output; displaying all that has been buffered so far"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   196
36
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   197
    |nLines lines|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   198
133
claus
parents: 131
diff changeset
   199
    shown ifFalse:[
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   200
        flushPending ifFalse:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   201
            self installDelayedUpdate.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   202
        ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   203
        ^ self
133
claus
parents: 131
diff changeset
   204
    ].
119
claus
parents: 110
diff changeset
   205
    inFlush ifTrue:[^ self].
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   206
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   207
    Processor removeTimedBlock:flushBlock.
59
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   208
    flushPending ifFalse:[^ self].
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   209
52
e69fade0aa8e mutual exclusion when updating contents
claus
parents: 36
diff changeset
   210
    access critical:[
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   211
        inFlush := true.
1491
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   212
        [
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   213
            flushPending := false.
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   214
            outstandingLines size ~~ 0 ifTrue:[
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   215
                "insert the bunch of lines - if any"
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   216
                lines := outstandingLines.
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   217
                outstandingLines := nil.
36
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   218
1491
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   219
                nLines := lines size.
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   220
                (nLines ~~ 0) ifTrue:[
1565
9109e9848c6f care for insertMode when handling collected text.
Claus Gittinger <cg@exept.de>
parents: 1562
diff changeset
   221
                    insertMode ifTrue:[
9109e9848c6f care for insertMode when handling collected text.
Claus Gittinger <cg@exept.de>
parents: 1562
diff changeset
   222
                        self insertLines:lines withCR:true.
9109e9848c6f care for insertMode when handling collected text.
Claus Gittinger <cg@exept.de>
parents: 1562
diff changeset
   223
                    ] ifFalse:[
9109e9848c6f care for insertMode when handling collected text.
Claus Gittinger <cg@exept.de>
parents: 1562
diff changeset
   224
                        self replaceLines:lines withCR:true
9109e9848c6f care for insertMode when handling collected text.
Claus Gittinger <cg@exept.de>
parents: 1562
diff changeset
   225
                    ].
1562
9b7557a81849 made the number of buffered lines an instVar.
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   226
                    alwaysAppendAtEnd ifTrue:[
9b7557a81849 made the number of buffered lines an instVar.
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   227
                        self cursorToEnd.
9b7557a81849 made the number of buffered lines an instVar.
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   228
                    ].
1491
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   229
                    self withCursorOffDo:[
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   230
                        (cursorLine >= (firstLineShown + nFullLinesShown)) ifTrue:[
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   231
                            self scrollDown:nLines
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   232
                        ]
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   233
                    ].
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   234
                ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   235
            ].
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   236
1491
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   237
            "and the last partial line - if any"
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   238
            outstandingLine size > 0 ifTrue:[
1565
9109e9848c6f care for insertMode when handling collected text.
Claus Gittinger <cg@exept.de>
parents: 1562
diff changeset
   239
                insertMode ifTrue:[
9109e9848c6f care for insertMode when handling collected text.
Claus Gittinger <cg@exept.de>
parents: 1562
diff changeset
   240
                    self insertStringAtCursor:outstandingLine.
9109e9848c6f care for insertMode when handling collected text.
Claus Gittinger <cg@exept.de>
parents: 1562
diff changeset
   241
                ] ifFalse:[
9109e9848c6f care for insertMode when handling collected text.
Claus Gittinger <cg@exept.de>
parents: 1562
diff changeset
   242
                    self replaceStringAtCursor:outstandingLine.
9109e9848c6f care for insertMode when handling collected text.
Claus Gittinger <cg@exept.de>
parents: 1562
diff changeset
   243
                ].
1491
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   244
                outstandingLine := ''.
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   245
            ].
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   246
            self checkLineLimit.
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   247
            device flush.
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   248
        ] valueNowOrOnUnwindDo:[
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   249
            inFlush := false.
0445841f7852 care for unwind (clear inFlush flag)
Claus Gittinger <cg@exept.de>
parents: 1489
diff changeset
   250
        ]
119
claus
parents: 110
diff changeset
   251
    ].
claus
parents: 110
diff changeset
   252
    flushPending ifTrue:[
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   253
        flushPending := false.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   254
        self installDelayedUpdate
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   255
    ]
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   256
1598
c9f30d02ad4f added #reverse - emphasis change
Claus Gittinger <cg@exept.de>
parents: 1565
diff changeset
   257
    "Modified: / 20.6.1998 / 20:24:09 / cg"
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   258
!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   259
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   260
lineLimit:aNumber
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   261
    "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
   262
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   263
    lineLimit := aNumber
1610
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   264
!
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   265
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   266
updateTimeDelay:seconds
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   267
    "if collect is enabled, the receiver will update its view, 
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   268
     after that time delay (i.e. it collects more output during that period),
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   269
     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
   270
     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
   271
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   272
    timeDelay := seconds
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   273
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   274
    "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
   275
! !
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   276
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   277
!TextCollector methodsFor:'change & update'!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   278
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   279
getListFromModel
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   280
    "a textCollector always scrolls to the bottom"
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   281
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   282
     super getListFromModel.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   283
     self scrollToBottom
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   284
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   285
    "Created: 12.2.1996 / 14:27:56 / stefan"
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   286
    "Modified: 11.1.1997 / 14:41:50 / cg"
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   287
! !
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   288
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   289
!TextCollector methodsFor:'events'!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   290
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   291
exposeX:x y:y width:w height:h
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   292
    "flush buffered text when exposed"
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   293
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   294
    super exposeX:x y:y width:w height:h.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   295
    self endEntry
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   296
! !
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   297
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   298
!TextCollector methodsFor:'initialize / release'!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   299
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   300
destroy
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   301
    "destroy this view"
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   302
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   303
    destroyAction notNil ifTrue:[
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   304
        destroyAction value
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   305
    ].
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   306
    Processor removeTimedBlock:flushBlock.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   307
    flushBlock := nil.
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   308
    outstandingLines := nil.
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   309
    outstandingLine := ''.
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   310
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   311
    super destroy
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   312
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   313
    "Modified: 11.1.1997 / 14:40:30 / cg"
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   314
!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   315
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   316
editMenu
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   317
    "return my popUpMenu; thats the superClasses menu,
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   318
     minus any accept item."
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   319
1262
d69149b5be1f resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
   320
    <resource: #programMenu>
1109
83d8c0143ef9 commentary
Claus Gittinger <cg@exept.de>
parents: 1026
diff changeset
   321
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   322
    |m idx|
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   323
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   324
    m := super editMenu.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   325
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   326
    "
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   327
     textcollectors do not support #accept
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   328
     remove it from the menu (and the preceeding separating line)
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   329
    "
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   330
    idx := m indexOf:#accept.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   331
    idx ~~ 0 ifTrue:[
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   332
        m remove:idx.
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   333
        (m labels at:(idx - 1)) = '-' ifTrue:[
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   334
            m remove:idx - 1
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   335
        ].
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   336
    ].
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   337
    ^ m
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   338
1262
d69149b5be1f resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
   339
    "Modified: 3.7.1997 / 13:54:11 / cg"
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   340
!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   341
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   342
initialize
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   343
    super initialize.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   344
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   345
    outstandingLines := nil.
1562
9b7557a81849 made the number of buffered lines an instVar.
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   346
    alwaysAppendAtEnd := true.
1610
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   347
    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
   348
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   349
    flushBlock := [self endEntry].
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   350
    flushPending := inFlush := false.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   351
    collecting := true.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   352
    timeDelay := self class defaultTimeDelay.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   353
    access := RecursionLock new. "/ Semaphore forMutualExclusion.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   354
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   355
    lineLimit := self class defaultLineLimit.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   356
    entryStream := ActorStream new.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   357
    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
   358
    entryStream nextPutAllBlock:[:something | self nextPutAll:something]
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   359
1610
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   360
    "Modified: / 27.7.1998 / 16:15:06 / cg"
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   361
!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   362
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   363
mapped
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   364
    "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
   365
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   366
    super mapped.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   367
    self endEntry
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   368
!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   369
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   370
reinitialize
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   371
    "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
   372
     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
   373
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   374
    flushPending := false.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   375
    access := RecursionLock new. "/ Semaphore forMutualExclusion.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   376
    super reinitialize.
1467
5c09bb2dadef Add (dummy fore now) #beginEntry for ST80 compat.
Stefan Vogel <sv@exept.de>
parents: 1421
diff changeset
   377
5c09bb2dadef Add (dummy fore now) #beginEntry for ST80 compat.
Stefan Vogel <sv@exept.de>
parents: 1421
diff changeset
   378
    "Modified: / 5.3.1998 / 10:09:14 / stefan"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   379
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   380
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   381
!TextCollector methodsFor:'private'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   382
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   383
checkLineLimit
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   384
    "this method checks if the text has become too large (> lineLimit)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   385
     and cuts off some lines at the top if so; it must be called whenever lines
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   386
     have been added to the bottom"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   387
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   388
    |nDel|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   389
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   390
    lineLimit notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   391
	(cursorLine > lineLimit) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   392
	    nDel := list size - lineLimit.
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   393
	    list removeFromIndex:1 toIndex:nDel.
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   394
	    cursorLine := cursorLine - nDel.
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   395
	    firstLineShown := firstLineShown - nDel.
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   396
	    (firstLineShown < 1) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   397
		cursorLine := cursorLine - firstLineShown + 1.
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   398
		firstLineShown := 1
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   399
	    ].
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   400
	    self contentsChanged
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   401
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   402
    ]
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   403
!
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   404
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   405
installDelayedUpdate
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   406
    "arrange for collecting input for some time,
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   407
     and output all buffered strings at once after a while.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   408
     This makes output to the transcript much faster on systems
553
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   409
     with poor scrolling performance (i.e. dumb vga cards ...)."
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   410
131
claus
parents: 130
diff changeset
   411
    |p|
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   412
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   413
    flushPending ifFalse:[
553
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   414
        flushPending := true.
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   415
        inFlush ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   416
            "
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   417
             we could run under a process, which dies in the meantime;
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   418
             therefore, we have to arrange for the transcript process to
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   419
             be interrupted and do the update.
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   420
            "
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   421
            windowGroup isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   422
                p := Processor activeProcess
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   423
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   424
                p := windowGroup process
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   425
            ].
1221
0c2a4231fc9e Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 1109
diff changeset
   426
            (p isNil or:[p isSystemProcess]) ifTrue:[
834
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   427
                self endEntry
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   428
            ] ifFalse:[
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   429
                Processor addTimedBlock:flushBlock for:p afterSeconds:timeDelay.
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   430
            ]
553
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   431
        ]
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   432
    ]
553
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   433
834
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   434
    "Modified: 17.9.1996 / 00:11:53 / cg"
1221
0c2a4231fc9e Move #isSystemProcess from ProcessorScheduler to Process.
Stefan Vogel <sv@exept.de>
parents: 1109
diff changeset
   435
    "Modified: 17.4.1997 / 13:03:15 / stefan"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   436
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   437
778
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   438
!TextCollector methodsFor:'queries'!
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   439
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   440
current
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   441
    "return the current (your screens) transcript.
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   442
     In multiDisplay applications, this need NOT be the main transcript.
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   443
     But typically, this is the same as Transcript."
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   444
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   445
    ^ self topView application class current transcript
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   446
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   447
    "
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   448
     Transcript current flash
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   449
    "
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   450
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   451
    "Created: 5.7.1996 / 14:14:34 / cg"
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   452
    "Modified: 5.7.1996 / 14:14:52 / cg"
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   453
! !
3a8fabcf1872 added #current (for: Transcript current)
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   454
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   455
!TextCollector methodsFor:'stream messages'!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   456
1504
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   457
bold
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   458
    currentEmphasis := #bold
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   459
!
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   460
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   461
cr
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   462
    "output a carriage return, finishing the current line"
135
claus
parents: 133
diff changeset
   463
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   464
    access critical:[
834
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   465
        collecting ifTrue:[
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   466
            outstandingLine notNil ifTrue:[  "/ mhmh - is never nil
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   467
                outstandingLines isNil ifTrue:[
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   468
                    outstandingLines := OrderedCollection with:outstandingLine
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   469
                ] ifFalse:[
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   470
                    outstandingLines add:outstandingLine.
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   471
                ]
834
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   472
            ].
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   473
            outstandingLine := ''.
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   474
        ] ifFalse:[
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   475
            self cursorReturn.
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   476
            self checkLineLimit.
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   477
            self cursorToEnd.
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   478
        ].
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   479
    ].
135
claus
parents: 133
diff changeset
   480
834
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   481
    collecting ifTrue:[
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   482
        flushPending ifFalse:[
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   483
            self installDelayedUpdate
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   484
        ]
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   485
    ]
834
0da7c9923d1b prevent scheduler from being suspended
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   486
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   487
    "Modified: 11.1.1997 / 14:39:00 / cg"
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   488
!
135
claus
parents: 133
diff changeset
   489
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   490
doesNotUnderstand:aMessage
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   491
    "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
   492
     on to the stream which will send the characters via nextPut:
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   493
     This way, we understand all Stream messages - great isn't it !!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   494
    "
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   495
     ^ entryStream perform:(aMessage selector) withArguments:(aMessage arguments)
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   496
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   497
1504
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   498
italic
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   499
    currentEmphasis := #italic
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   500
!
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   501
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   502
lineLength
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   503
    "to make a textCollector (somewhat) compatible with printer
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   504
     streams, support the lineLength query"
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   505
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   506
    ^ width // (font width)
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   507
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   508
    "Modified: 11.1.1997 / 14:42:41 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   509
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   510
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   511
nextPut:something
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   512
    "append somethings printString to my displayed text.
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   513
     This allows TextCollectors to be used Stream-wise"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   514
1504
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   515
    |txt|
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   516
656
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   517
    (something isCharacter) ifTrue:[
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   518
        ((something == Character cr) or:[something == Character nl]) ifTrue:[
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   519
            ^ self cr
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   520
        ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   521
    ].
1504
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   522
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   523
    txt := something asString.
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   524
    currentEmphasis notNil ifTrue:[
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   525
        txt := txt emphasizeAllWith:currentEmphasis
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   526
    ].
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   527
    self show:txt.
656
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   528
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   529
"/    flushPending ifTrue:[
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   530
"/        self endEntry
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   531
"/    ].
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   532
"/    (something isMemberOf:Character) ifTrue:[
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   533
"/        ((something == Character cr) or:[something == Character nl]) ifTrue:[
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   534
"/            ^ self cr
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   535
"/        ].
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   536
"/        self insertCharAtCursor:something
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   537
"/    ] ifFalse:[
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   538
"/        self insertStringAtCursor:(something printString).
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   539
"/        self checkLineLimit
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   540
"/    ].
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   541
"/    device flush
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   542
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   543
    "Modified: 11.1.1997 / 14:43:05 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   544
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   545
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   546
nextPutAll:something
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   547
    "append all of something to my displayed text.
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   548
     This allows TextCollectors to be used Stream-wise"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   549
1504
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   550
    currentEmphasis notNil ifTrue:[
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   551
        ^ self show:(something emphasizeAllWith:currentEmphasis)
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   552
    ].
656
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   553
    ^ self show:something
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   554
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   555
    "Modified: 11.1.1997 / 14:43:26 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   556
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   557
1504
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   558
normal
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   559
    currentEmphasis := nil
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   560
!
3101f410e230 rudimentary support for (some) emphasis messages
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   561
1598
c9f30d02ad4f added #reverse - emphasis change
Claus Gittinger <cg@exept.de>
parents: 1565
diff changeset
   562
reverse
c9f30d02ad4f added #reverse - emphasis change
Claus Gittinger <cg@exept.de>
parents: 1565
diff changeset
   563
    currentEmphasis := Array with:#color->bgColor
c9f30d02ad4f added #reverse - emphasis change
Claus Gittinger <cg@exept.de>
parents: 1565
diff changeset
   564
                             with:#backgroundColor->fgColor.
c9f30d02ad4f added #reverse - emphasis change
Claus Gittinger <cg@exept.de>
parents: 1565
diff changeset
   565
c9f30d02ad4f added #reverse - emphasis change
Claus Gittinger <cg@exept.de>
parents: 1565
diff changeset
   566
    "Created: / 20.6.1998 / 20:10:45 / cg"
c9f30d02ad4f added #reverse - emphasis change
Claus Gittinger <cg@exept.de>
parents: 1565
diff changeset
   567
!
c9f30d02ad4f added #reverse - emphasis change
Claus Gittinger <cg@exept.de>
parents: 1565
diff changeset
   568
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   569
show:anObject
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   570
    "insert the argument aString at current cursor position"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   571
308
b216a5efa2c8 handle show: with a string containing cr's
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   572
    |aString lines|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   573
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   574
    aString := anObject printString.
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   575
308
b216a5efa2c8 handle show: with a string containing cr's
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   576
    (aString includes:(Character cr)) ifTrue:[
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   577
        lines := aString asStringCollection.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   578
        lines keysAndValuesDo:[:nr :line |
1562
9b7557a81849 made the number of buffered lines an instVar.
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   579
            (nr == lines size 
9b7557a81849 made the number of buffered lines an instVar.
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   580
            and:[(aString endsWith:(Character cr)) not]) ifTrue:[
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   581
                "/ the last one.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   582
                self show:line
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   583
            ] ifFalse:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   584
                self showCR:line
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   585
            ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   586
        ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   587
        ^ self.
308
b216a5efa2c8 handle show: with a string containing cr's
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   588
    ].
b216a5efa2c8 handle show: with a string containing cr's
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   589
1026
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   590
    access critical:[
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   591
        outstandingLine size > 0 ifTrue:[
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   592
            outstandingLine := outstandingLine , aString
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   593
        ] ifFalse:[
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   594
            outstandingLine := aString
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   595
        ].
1026
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   596
        collecting ifTrue:[
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   597
            flushPending ifFalse:[
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   598
                self installDelayedUpdate
1312
eaa44f7649f5 flush after some lines have been collected
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
   599
            ] ifTrue:[
1562
9b7557a81849 made the number of buffered lines an instVar.
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   600
                outstandingLines size > collectSize ifTrue:[
1312
eaa44f7649f5 flush after some lines have been collected
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
   601
                    self endEntry
eaa44f7649f5 flush after some lines have been collected
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
   602
                ]
1026
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   603
            ]
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   604
        ] ifFalse:[
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   605
            self endEntry
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   606
        ]
1026
6068cf626646 non-collecting nextPut
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   607
    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   608
1562
9b7557a81849 made the number of buffered lines an instVar.
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   609
    "Modified: / 10.6.1998 / 19:34:25 / cg"
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   610
! !
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   611
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   612
!TextCollector methodsFor:'transcript specials'!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   613
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   614
beTranscript
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   615
    "make the receiver be the systemTranscript; this one
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   616
     is accessable via the global Transcript and gets relevant
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   617
     system messages from various places."
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   618
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   619
    |fg bg cFg cBg|
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   620
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   621
    Smalltalk at:#Transcript put:self.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   622
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   623
    "
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   624
     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
   625
    "
1421
afef284eadc4 only reset Transcript to stdErr, if I really am the transcript.
ca
parents: 1389
diff changeset
   626
    self destroyAction:[
afef284eadc4 only reset Transcript to stdErr, if I really am the transcript.
ca
parents: 1389
diff changeset
   627
        self == (Smalltalk at:#Transcript) ifTrue:[
afef284eadc4 only reset Transcript to stdErr, if I really am the transcript.
ca
parents: 1389
diff changeset
   628
            Smalltalk at:#Transcript put:Stderr
afef284eadc4 only reset Transcript to stdErr, if I really am the transcript.
ca
parents: 1389
diff changeset
   629
        ]
afef284eadc4 only reset Transcript to stdErr, if I really am the transcript.
ca
parents: 1389
diff changeset
   630
    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   631
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   632
    "/ user may prefer a special color for this one;
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   633
    "/ look into the style definitions ...
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   634
1389
82a672130741 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1312
diff changeset
   635
    fg := styleSheet colorAt:'transcript.foregroundColor' default:self foregroundColor.
82a672130741 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1312
diff changeset
   636
    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
   637
    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
   638
    self viewBackground:bg.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   639
1389
82a672130741 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1312
diff changeset
   640
    cFg := styleSheet colorAt:'transcript.cursorForegroundColor' default:bg.
82a672130741 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1312
diff changeset
   641
    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
   642
    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
   643
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   644
    "self lineLimit:1000. " "or whatever you think makes sense"
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   645
1389
82a672130741 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1312
diff changeset
   646
    "Modified: / 2.11.1997 / 22:34:47 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   647
! !
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   648
928
d120ad0c0422 commentary
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   649
!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
   650
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   651
version
1610
b05a3e405b33 allow change of collectSize and updateTimeDelay.
Claus Gittinger <cg@exept.de>
parents: 1598
diff changeset
   652
    ^ '$Header: /cvs/stx/stx/libwidg/TextCollector.st,v 1.50 1998-07-27 14:17:03 cg Exp $'
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   653
! !