TextColl.st
author claus
Wed, 24 Aug 1994 01:38:59 +0200
changeset 51 e895ac4cc7c8
parent 36 641fe12489b2
child 52 e69fade0aa8e
permissions -rw-r--r--
support non-string entries
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
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     3
              All Rights Reserved
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
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    14
       instanceVariableNames:'entryStream lineLimit destroyAction
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    15
                              outstandingLines outstandingLine
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    16
                              flushBlock flushPending collecting timeDelay access'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    17
       classVariableNames:''
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    18
       poolDictionaries:''
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    19
       category:'Views-Text'
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    20
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    21
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    22
TextCollector comment:'
5
claus
parents: 3
diff changeset
    23
COPYRIGHT (c) 1989 by Claus Gittinger
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    24
              All Rights Reserved
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    25
36
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
    26
$Header: /cvs/stx/stx/libwidg/Attic/TextColl.st,v 1.8 1994-08-07 13:18:43 claus Exp $
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    27
'!
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    28
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    29
!TextCollector class methodsFor:'documentation'!
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    30
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    31
copyright
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    32
"
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    33
 COPYRIGHT (c) 1989 by Claus Gittinger
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    34
              All Rights Reserved
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
 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
    37
 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
    38
 inclusion of the above copyright notice.   This software may not
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    39
 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
    40
 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
    41
 hereby transferred.
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
!
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    44
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    45
version
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    46
"
36
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
    47
$Header: /cvs/stx/stx/libwidg/Attic/TextColl.st,v 1.8 1994-08-07 13:18:43 claus Exp $
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    48
"
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    49
!
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    50
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    51
documentation
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    52
"
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    53
    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
    54
    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
    55
    received text.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    56
    Its main use in the system is the Transcript, but it can also be used for
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    57
    things like trace-windows etc.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    58
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    59
    If collecting is turned on, a Textcollector will not immediately display 
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    60
    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
    61
    data - finally updating the whole chunk in one piece. 
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    62
    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
    63
    (on fast displays this is less of a problem).
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    64
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    65
    The total number of lines kept is controlled by lineLimit, if more lines are 
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    66
    entered at the bottom, the textcollector will forget lines at the top. 
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    67
    Linelimit can also be set to nil (i.e. no limit), but you may need a lot 
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    68
    of memory then ...
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    69
"
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    70
! !
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    71
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    72
!TextCollector class methodsFor:'defaults'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    73
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    74
defaultLineLimit
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    75
    "the number of lines remembered by default"
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    76
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    77
    ^ 600
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    78
! 
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    79
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    80
defaultTimeDelay
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    81
    "the time in seconds to wait & collect by default"
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    82
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    83
    ^ 0.3 
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    84
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    85
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    86
!TextCollector class methodsFor:'instance creation'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    87
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    88
newTranscript
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    89
    |topView transcript f v|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    90
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    91
    topView := StandardSystemView label:'Transcript' minExtent:(100 @ 100).
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
    92
    topView icon:(Form fromFile:'SmalltalkX.xbm').
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    93
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    94
    v := ScrollableView for:self in:topView.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    95
    v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    96
    transcript := v scrolledView.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    97
    "transcript partialLines:false."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    98
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    99
    f := transcript font.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   100
    topView extent:(((f widthOf:'x') * 70) @ (f height * 10)).
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   101
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   102
    Smalltalk at:#Transcript put:transcript.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   103
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   104
    "fancy feature: whenever Transcript is closed, reset to StdError"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   105
    transcript destroyAction:[Smalltalk at:#Transcript put:Stderr].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   106
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
   107
    topView open.
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   108
    "transcript lineLimit:1000. " "or whatever you think makes sense"
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   109
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   110
    ^ transcript
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   111
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   112
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   113
!TextCollector methodsFor:'initialize / release'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   114
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   115
initialize
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   116
    super initialize.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   117
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   118
    outstandingLines := OrderedCollection new.
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   119
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   120
    flushBlock := [self endEntry].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   121
    flushPending := false.
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   122
    collecting := true.
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   123
    timeDelay := self class defaultTimeDelay.
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   124
    access := Semaphore forMutualExclusion.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   125
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   126
    lineLimit := self class defaultLineLimit.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   127
    entryStream := ActorStream new.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   128
    entryStream nextPutBlock:[:something | self nextPut:something].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   129
    entryStream nextPutAllBlock:[:something | self nextPutAll:something]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   130
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   131
36
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   132
reinitialize
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   133
    "recreate access-semaphore; image could have been save (theoretically)
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   134
     with the semaphore locked - int this case, we had a deadlock"
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   135
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   136
    flushPending := false.
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   137
    access := Semaphore forMutualExclusion.
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   138
    super reinitialize.
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   139
!
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   140
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   141
mapped
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   142
    "view became visible - show collected lines (if any)"
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   143
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   144
    super mapped.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   145
    self endEntry
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   146
!
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   147
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   148
destroy
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   149
    destroyAction notNil ifTrue:[
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   150
        destroyAction value
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   151
    ].
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   152
    Processor removeTimedBlock:flushBlock.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   153
    flushBlock := nil.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   154
    outstandingLines := OrderedCollection new.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   155
    outstandingLine := ''.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   156
    super destroy
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   157
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   158
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   159
!TextCollector methodsFor:'accessing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   160
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   161
collect:aBoolean
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   162
    "turn on/off collecting - if on, do not output immediately
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   163
     but collect text and output en-bloque after some time delta"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   164
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   165
    collecting := aBoolean
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   166
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   167
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   168
lineLimit:aNumber
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   169
    "define the number of text-lines I am supposed to hold"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   170
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   171
    lineLimit := aNumber
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   172
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   173
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   174
destroyAction:aBlock
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   175
    "define the action to be performed when I get destroyed.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   176
     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
   177
     when closed. (see TextCollectorclass>>newTranscript)"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   178
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   179
    destroyAction := aBlock
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   180
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   181
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   182
endEntry
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   183
    "flush collected output"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   184
36
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   185
    |nLines lines|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   186
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   187
    shown ifFalse:[^ self].
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   188
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   189
    Processor removeTimedBlock:flushBlock.
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   190
    flushPending := false.
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   191
36
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   192
    outstandingLines size ~~ 0 ifTrue:[
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   193
        access critical:[
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   194
            "insert the bunch of lines - if any"
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   195
            lines := outstandingLines.
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   196
            outstandingLines := OrderedCollection new.
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   197
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   198
            nLines := lines size.
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   199
            (nLines ~~ 0) ifTrue:[
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   200
                self insertLines:lines withCr:true.
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   201
                self withCursorOffDo:[
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   202
                    (cursorLine >= (firstLineShown + nFullLinesShown)) ifTrue:[
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   203
                        self scrollDown:nLines
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   204
                    ]
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   205
                ].
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   206
            ].
36
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   207
            "and the last partial line - if any"
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   208
            outstandingLine notNil ifTrue:[
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   209
                self insertStringAtCursor:outstandingLine.
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   210
                outstandingLine := ''.
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   211
            ].
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   212
            self checkLineLimit
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   213
        ]
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   214
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   215
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   216
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   217
!TextCollector methodsFor:'private'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   218
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   219
checkLineLimit
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   220
    "this method checks if the text has become too large (> lineLimit)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   221
     and cuts off some lines at the top if so; it must be called whenever lines
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   222
     have been added to the bottom"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   223
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   224
    |nDel|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   225
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   226
    lineLimit notNil ifTrue:[
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   227
        (cursorLine > lineLimit) ifTrue:[
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   228
            nDel := list size - lineLimit.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   229
            list removeFromIndex:1 toIndex:nDel.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   230
            cursorLine := cursorLine - nDel.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   231
            firstLineShown := firstLineShown - nDel.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   232
            (firstLineShown < 1) ifTrue:[
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   233
                cursorLine := cursorLine - firstLineShown + 1.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   234
                firstLineShown := 1
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   235
            ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   236
            self contentsChanged
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   237
        ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   238
    ]
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   239
!
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   240
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   241
installDelayedUpdate
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   242
    "arrange for collecting input for some time,
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   243
     and output all buffered strings at once after a while.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   244
     This makes output to the transcript much faster on systems
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   245
     with poor scrolling performance (i.e. dump vga cards ...)."
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   246
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   247
    |wg p|
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   248
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   249
    flushPending ifFalse:[
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   250
        flushPending := true.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   251
        "
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   252
         this could run under a process, which dies in the meantime;
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   253
         therefore, we have to interrupt the transcript process.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   254
        "
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   255
        wg := self windowGroup.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   256
        wg isNil ifTrue:[
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   257
            p := Processor activeProcess
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   258
        ] ifFalse:[
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   259
            p := wg process
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   260
        ].
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   261
        Processor addTimedBlock:flushBlock for:p afterSeconds:timeDelay.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   262
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   263
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   264
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   265
!TextCollector methodsFor:'stream messages'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   266
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   267
lineLength
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   268
    ^ width // (font width)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   269
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   270
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   271
nextPut:something
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   272
    "this allows TextCollectors to be used Stream-wise"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   273
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   274
    flushPending ifTrue:[
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   275
        self endEntry
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   276
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   277
    (something isMemberOf:Character) ifTrue:[
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   278
        ((something == Character cr) or:[something == Character nl]) ifTrue:[
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   279
            ^ self cr
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   280
        ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   281
        self insertCharAtCursor:something
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   282
    ] ifFalse:[
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   283
        self insertStringAtCursor:(something printString).
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   284
        self checkLineLimit
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   285
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   286
    device synchronizeOutput
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   287
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   288
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   289
nextPutAll:something
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   290
    "this allows TextCollectors to be used Stream-wise"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   291
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   292
    ^ self nextPut:something
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   293
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   294
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   295
cr
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   296
    "output a carriage return, finishing the current line"
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   297
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   298
    |wasBlocked|
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   299
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   300
    collecting ifTrue:[
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   301
        access critical:[
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   302
            outstandingLine notNil ifTrue:[
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   303
                outstandingLines add:outstandingLine.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   304
            ].
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   305
            outstandingLine := ''.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   306
        ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   307
        flushPending ifFalse:[
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   308
            self installDelayedUpdate
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   309
        ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   310
    ] ifFalse:[
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   311
        access critical:[
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   312
            self cursorReturn.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   313
            self checkLineLimit.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   314
        ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   315
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   316
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   317
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   318
show:anObject
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   319
    "insert the argument aString at current cursor position"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   320
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   321
    |aString wasBlocked|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   322
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   323
    aString := anObject printString.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   324
    collecting ifTrue:[
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   325
        access critical:[
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   326
            outstandingLine notNil ifTrue:[
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   327
                outstandingLine := outstandingLine , aString
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   328
            ] ifFalse:[
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   329
                outstandingLine := aString
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   330
            ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   331
        ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   332
        flushPending ifFalse:[
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   333
            self installDelayedUpdate
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   334
        ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   335
    ] ifFalse:[
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   336
        access critical:[
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   337
            self nextPut:aString.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   338
        ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   339
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   340
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   341
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   342
showCr:aString
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   343
    "insert the argument aString followed by a newline
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   344
     at current cursor position"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   345
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   346
    self show:aString.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   347
    self cr
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   348
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   349
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   350
doesNotUnderstand:aMessage
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   351
    "this is funny: all message we do not understand, are passed
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   352
     on to the stream which will send the characters via nextPut:
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   353
     This way, we understand all Stream messages - great isn't it !!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   354
    "
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   355
     ^ entryStream perform:(aMessage selector) withArguments:(aMessage arguments)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   356
! !