TextColl.st
author Claus Gittinger <cg@exept.de>
Sat, 18 May 1996 18:35:43 +0200
changeset 656 2fb1c683d3f3
parent 653 fdab88d1205f
child 778 3a8fabcf1872
permissions -rw-r--r--
checkin from browser
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
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
    16
		timeDelay access'
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
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
    22
!TextCollector class methodsFor:'documentation'!
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
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    75
!TextCollector class methodsFor:'instance creation'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    76
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    77
newTranscript
110
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
    78
    "create and open a new transcript."
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
    79
130
claus
parents: 119
diff changeset
    80
    |topView transcript f v lines cols|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    81
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
    82
    topView := StandardSystemView label:'Transcript' minExtent:(100 @ 100).
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    83
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    84
    v := HVScrollableView for:self miniScrollerH:true miniScrollerV:false in:topView.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    85
    v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    86
    transcript := v scrolledView.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    87
    "transcript partialLines:false."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    88
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    89
    f := transcript font.
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    90
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    91
    "
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    92
     should add the height of the frame & scrollbars to be exact ...
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    93
    "
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    94
    cols := self defaultTranscriptSize x.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    95
    lines := self defaultTranscriptSize y.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    96
    topView extent:(((f widthOf:'x') * cols) @ (f height * lines)).
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    97
110
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
    98
    transcript beTranscript.
59
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
    99
80
5a878a1eebf2 *** empty log message ***
claus
parents: 77
diff changeset
   100
    "
5a878a1eebf2 *** empty log message ***
claus
parents: 77
diff changeset
   101
     run it at a slightly higher prio, to allow for
5a878a1eebf2 *** empty log message ***
claus
parents: 77
diff changeset
   102
     delayed buffered updates to be performed
5a878a1eebf2 *** empty log message ***
claus
parents: 77
diff changeset
   103
    "
5a878a1eebf2 *** empty log message ***
claus
parents: 77
diff changeset
   104
    topView openWithPriority:(Processor userSchedulingPriority + 1).
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   105
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   106
    ^ transcript
110
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   107
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   108
    "
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   109
     TextCollector newTranscript
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   110
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   111
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   112
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   113
!TextCollector class methodsFor:'defaults'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   114
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   115
defaultLineLimit
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   116
    "the number of lines remembered by default"
59
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   117
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   118
    ^ 600
59
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   119
!
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   120
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   121
defaultTimeDelay
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   122
    "the time in seconds to wait & collect by default"
36
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   123
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   124
    ^ 0.3 
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   125
!
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   126
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   127
defaultTranscriptSize
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   128
    "the number of cols/lines by which the Transcript should come up"
110
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   129
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   130
    ^ 70@11
110
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   131
! !
eb59f6e31e84 *** empty log message ***
claus
parents: 97
diff changeset
   132
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   133
!TextCollector methodsFor:'accessing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   134
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   135
collect:aBoolean
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   136
    "turn on/off collecting - if on, do not output immediately
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   137
     but collect text and output en-bloque after some time delta"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   138
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   139
    collecting := aBoolean
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   140
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   141
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   142
destroyAction:aBlock
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   143
    "define the action to be performed when I get destroyed.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   144
     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
   145
     when closed. (see TextCollectorclass>>newTranscript)"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   146
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   147
    destroyAction := aBlock
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   148
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   149
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   150
endEntry
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   151
    "flush collected output"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   152
36
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   153
    |nLines lines|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   154
133
claus
parents: 131
diff changeset
   155
    shown ifFalse:[
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   156
        flushPending ifFalse:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   157
            self installDelayedUpdate.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   158
        ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   159
        ^ self
133
claus
parents: 131
diff changeset
   160
    ].
119
claus
parents: 110
diff changeset
   161
    inFlush ifTrue:[^ self].
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   162
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   163
    Processor removeTimedBlock:flushBlock.
59
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   164
    flushPending ifFalse:[^ self].
15
0dbce35d3c69 *** empty log message ***
claus
parents: 7
diff changeset
   165
52
e69fade0aa8e mutual exclusion when updating contents
claus
parents: 36
diff changeset
   166
    access critical:[
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   167
        inFlush := true.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   168
        flushPending := false.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   169
        outstandingLines size ~~ 0 ifTrue:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   170
            "insert the bunch of lines - if any"
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   171
            lines := outstandingLines.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   172
            outstandingLines := OrderedCollection new.
36
641fe12489b2 prevent deadlock on access-semaphore in image-restart
claus
parents: 34
diff changeset
   173
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   174
            nLines := lines size.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   175
            (nLines ~~ 0) ifTrue:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   176
                self insertLines:lines withCR:true.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   177
                self cursorToEnd.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   178
                self withCursorOffDo:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   179
                    (cursorLine >= (firstLineShown + nFullLinesShown)) ifTrue:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   180
                        self scrollDown:nLines
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   181
                    ]
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   182
                ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   183
            ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   184
        ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   185
        "and the last partial line - if any"
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   186
        outstandingLine notNil ifTrue:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   187
            self insertStringAtCursor:outstandingLine.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   188
            outstandingLine := ''.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   189
        ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   190
        self checkLineLimit.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   191
        inFlush := false.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   192
        device flush.
119
claus
parents: 110
diff changeset
   193
    ].
claus
parents: 110
diff changeset
   194
    flushPending ifTrue:[
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   195
        flushPending := false.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   196
        self installDelayedUpdate
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   197
    ]
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   198
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   199
    "Modified: 18.5.1996 / 15:33:26 / cg"
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   200
!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   201
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   202
lineLimit:aNumber
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   203
    "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
   204
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   205
    lineLimit := aNumber
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   206
! !
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   207
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   208
!TextCollector methodsFor:'change & update'!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   209
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   210
getListFromModel
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   211
     super getListFromModel.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   212
     self scrollToBottom
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   213
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   214
    "Created: 12.2.1996 / 14:27:56 / stefan"
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   215
! !
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   216
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   217
!TextCollector methodsFor:'events'!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   218
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   219
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
   220
    "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
   221
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   222
    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
   223
    self endEntry
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   224
! !
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   225
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   226
!TextCollector methodsFor:'initialize / release'!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   227
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   228
destroy
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   229
    destroyAction notNil ifTrue:[
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   230
	destroyAction value
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   231
    ].
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   232
    Processor removeTimedBlock:flushBlock.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   233
    flushBlock := nil.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   234
    outstandingLines := OrderedCollection new.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   235
    outstandingLine := ''.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   236
    super destroy
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   237
!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   238
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   239
editMenu
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   240
    |m idx|
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   241
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   242
    m := super editMenu.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   243
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   244
    "
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   245
     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
   246
     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
   247
    "
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   248
    idx := m indexOf:#accept.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   249
    idx ~~ 0 ifTrue:[
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   250
	m remove:idx.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   251
	(m labels at:(idx - 1)) = '-' ifTrue:[
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   252
	    m remove:idx - 1
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   253
	].
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   254
    ].
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   255
    ^ m
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   256
!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   257
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   258
initialize
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   259
    super initialize.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   260
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   261
    outstandingLines := OrderedCollection new.
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
    flushBlock := [self endEntry].
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   264
    flushPending := inFlush := false.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   265
    collecting := true.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   266
    timeDelay := self class defaultTimeDelay.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   267
    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
   268
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   269
    lineLimit := self class defaultLineLimit.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   270
    entryStream := ActorStream new.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   271
    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
   272
    entryStream nextPutAllBlock:[:something | self nextPutAll:something]
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   273
!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   274
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   275
mapped
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   276
    "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
   277
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   278
    super mapped.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   279
    self endEntry
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   280
!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   281
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   282
reinitialize
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   283
    "recreate access-semaphore; image could have been save (theoretically)
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   284
     with the semaphore locked - int this case, we had a deadlock"
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   285
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   286
    flushPending := false.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   287
    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
   288
    super reinitialize.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   289
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   290
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   291
!TextCollector methodsFor:'private'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   292
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   293
checkLineLimit
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   294
    "this method checks if the text has become too large (> lineLimit)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   295
     and cuts off some lines at the top if so; it must be called whenever lines
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   296
     have been added to the bottom"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   297
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   298
    |nDel|
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   299
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   300
    lineLimit notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   301
	(cursorLine > lineLimit) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   302
	    nDel := list size - lineLimit.
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   303
	    list removeFromIndex:1 toIndex:nDel.
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   304
	    cursorLine := cursorLine - nDel.
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   305
	    firstLineShown := firstLineShown - nDel.
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   306
	    (firstLineShown < 1) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   307
		cursorLine := cursorLine - firstLineShown + 1.
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   308
		firstLineShown := 1
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   309
	    ].
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   310
	    self contentsChanged
450ce95a72a4 *** empty log message ***
claus
parents: 52
diff changeset
   311
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   312
    ]
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   313
!
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   314
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   315
installDelayedUpdate
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   316
    "arrange for collecting input for some time,
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   317
     and output all buffered strings at once after a while.
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   318
     This makes output to the transcript much faster on systems
553
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   319
     with poor scrolling performance (i.e. dumb vga cards ...)."
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   320
131
claus
parents: 130
diff changeset
   321
    |p|
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   322
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   323
    flushPending ifFalse:[
553
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   324
        flushPending := true.
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   325
        inFlush ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   326
            "
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   327
             we could run under a process, which dies in the meantime;
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   328
             therefore, we have to arrange for the transcript process to
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   329
             be interrupted and do the update.
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   330
            "
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   331
            windowGroup isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   332
                p := Processor activeProcess
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   333
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   334
                p := windowGroup process
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   335
            ].
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   336
            Processor addTimedBlock:flushBlock for:p afterSeconds:timeDelay.
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   337
        ]
34
c4b386a8cc57 critical-lock; allows show:/showCr: from multiple processes
claus
parents: 22
diff changeset
   338
    ]
553
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   339
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   340
    "Modified: 18.4.1996 / 20:02:01 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   341
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   342
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   343
!TextCollector methodsFor:'stream messages'!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   344
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   345
cr
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   346
    "output a carriage return, finishing the current line"
135
claus
parents: 133
diff changeset
   347
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   348
    access critical:[
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   349
	collecting ifTrue:[
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   350
	    outstandingLine notNil ifTrue:[
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   351
		outstandingLines add:outstandingLine.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   352
	    ].
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   353
	    outstandingLine := ''.
135
claus
parents: 133
diff changeset
   354
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   355
	    flushPending ifFalse:[
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   356
		self installDelayedUpdate
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   357
	    ]
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   358
	] ifFalse:[
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   359
	    self cursorReturn.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   360
	    self checkLineLimit.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   361
	    self cursorToEnd.
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
    ]
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   364
!
135
claus
parents: 133
diff changeset
   365
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   366
doesNotUnderstand:aMessage
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   367
    "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
   368
     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
   369
     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
   370
    "
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   371
     ^ 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
   372
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   373
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   374
lineLength
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   375
    ^ width // (font width)
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   376
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   377
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   378
nextPut:something
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   379
    "this allows TextCollectors to be used Stream-wise"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   380
656
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   381
    (something isCharacter) ifTrue:[
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   382
        ((something == Character cr) or:[something == Character nl]) ifTrue:[
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   383
            ^ self cr
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   384
        ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   385
    ].
656
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   386
    self show:(something asString).
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   387
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   388
"/    flushPending ifTrue:[
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   389
"/        self endEntry
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   390
"/    ].
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   391
"/    (something isMemberOf:Character) ifTrue:[
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   392
"/        ((something == Character cr) or:[something == Character nl]) ifTrue:[
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   393
"/            ^ self cr
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   394
"/        ].
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   395
"/        self insertCharAtCursor:something
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   396
"/    ] ifFalse:[
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   397
"/        self insertStringAtCursor:(something printString).
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   398
"/        self checkLineLimit
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   399
"/    ].
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   400
"/    device flush
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   401
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   402
    "Modified: 18.5.1996 / 18:30:39 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   403
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   404
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   405
nextPutAll:something
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   406
    "this allows TextCollectors to be used Stream-wise"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   407
656
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   408
    ^ self show:something
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   409
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   410
    "Modified: 18.5.1996 / 18:31:11 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   411
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   412
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   413
show:anObject
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   414
    "insert the argument aString at current cursor position"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   415
308
b216a5efa2c8 handle show: with a string containing cr's
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   416
    |aString lines|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   417
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   418
    aString := anObject printString.
308
b216a5efa2c8 handle show: with a string containing cr's
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   419
    (aString includes:(Character cr)) ifTrue:[
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   420
        lines := aString asStringCollection.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   421
        lines keysAndValuesDo:[:nr :line |
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   422
            nr == lines size ifTrue:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   423
                "/ the last one.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   424
                self show:line
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   425
            ] ifFalse:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   426
                self showCR:line
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   427
            ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   428
        ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   429
        ^ self.
308
b216a5efa2c8 handle show: with a string containing cr's
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   430
    ].
b216a5efa2c8 handle show: with a string containing cr's
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   431
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   432
    collecting ifTrue:[
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   433
        access critical:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   434
            outstandingLine notNil ifTrue:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   435
                outstandingLine := outstandingLine , aString
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   436
            ] ifFalse:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   437
                outstandingLine := aString
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   438
            ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   439
        ].
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   440
        flushPending ifFalse:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   441
            self installDelayedUpdate
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   442
        ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   443
    ] ifFalse:[
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   444
        access critical:[
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   445
            self nextPut:aString.
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   446
        ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   447
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   448
653
fdab88d1205f showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   449
    "Modified: 18.5.1996 / 15:45:00 / cg"
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   450
! !
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   451
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   452
!TextCollector methodsFor:'transcript specials'!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   453
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   454
beTranscript
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   455
    |fg bg cFg cBg|
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   456
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   457
    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
   458
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   459
    "
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   460
     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
   461
    "
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   462
    self destroyAction:[Smalltalk at:#Transcript put:Stderr].
0
e6a541c1c0eb Initial revision
claus
parents:
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
    fg := styleSheet colorAt:'transcriptForegroundColor' default:self foregroundColor.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   465
    bg := styleSheet colorAt:'transcriptBackgroundColor' default:self backgroundColor.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   466
    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
   467
    self viewBackground:bg.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   468
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   469
    cFg := styleSheet colorAt:'transcriptCursorForegroundColor' default:bg.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   470
    cBg := styleSheet colorAt:'transcriptCursorBackgroundColor' default:fg.
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   471
    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
   472
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   473
    "self lineLimit:1000. " "or whatever you think makes sense"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   474
! !
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   475
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   476
!TextCollector class methodsFor:'documentation'!
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   477
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   478
version
656
2fb1c683d3f3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 653
diff changeset
   479
    ^ '$Header: /cvs/stx/stx/libwidg/Attic/TextColl.st,v 1.30 1996-05-18 16:35:43 cg Exp $'
363
d780a45df2d4 MVC operation: scroll to bottom when model changes the text.
Stefan Vogel <sv@exept.de>
parents: 308
diff changeset
   480
! !