TextCollector.st
changeset 1504 3101f410e230
parent 1500 dee7275372f1
child 1562 9b7557a81849
equal deleted inserted replaced
1503:ae953a367422 1504:3101f410e230
    11 "
    11 "
    12 
    12 
    13 EditTextView subclass:#TextCollector
    13 EditTextView subclass:#TextCollector
    14 	instanceVariableNames:'entryStream lineLimit destroyAction outstandingLines
    14 	instanceVariableNames:'entryStream lineLimit destroyAction outstandingLines
    15 		outstandingLine flushBlock flushPending inFlush collecting
    15 		outstandingLine flushBlock flushPending inFlush collecting
    16 		timeDelay access'
    16 		timeDelay access currentEmphasis'
    17 	classVariableNames:''
    17 	classVariableNames:''
    18 	poolDictionaries:''
    18 	poolDictionaries:''
    19 	category:'Views-Text'
    19 	category:'Views-Text'
    20 !
    20 !
    21 
    21 
   137 
   137 
   138 !TextCollector methodsFor:'ST-80 compatibility'!
   138 !TextCollector methodsFor:'ST-80 compatibility'!
   139 
   139 
   140 deselect
   140 deselect
   141     self unselect
   141     self unselect
       
   142 !
       
   143 
       
   144 flush
       
   145     self endEntry.
       
   146     super flush
   142 ! !
   147 ! !
   143 
   148 
   144 !TextCollector methodsFor:'accessing'!
   149 !TextCollector methodsFor:'accessing'!
   145 
   150 
   146 beginEntry
   151 beginEntry
   404     "Modified: 5.7.1996 / 14:14:52 / cg"
   409     "Modified: 5.7.1996 / 14:14:52 / cg"
   405 ! !
   410 ! !
   406 
   411 
   407 !TextCollector methodsFor:'stream messages'!
   412 !TextCollector methodsFor:'stream messages'!
   408 
   413 
       
   414 bold
       
   415     currentEmphasis := #bold
       
   416 !
       
   417 
   409 cr
   418 cr
   410     "output a carriage return, finishing the current line"
   419     "output a carriage return, finishing the current line"
   411 
   420 
   412     access critical:[
   421     access critical:[
   413         collecting ifTrue:[
   422         collecting ifTrue:[
   441      This way, we understand all Stream messages - great isn't it !!
   450      This way, we understand all Stream messages - great isn't it !!
   442     "
   451     "
   443      ^ entryStream perform:(aMessage selector) withArguments:(aMessage arguments)
   452      ^ entryStream perform:(aMessage selector) withArguments:(aMessage arguments)
   444 !
   453 !
   445 
   454 
       
   455 italic
       
   456     currentEmphasis := #italic
       
   457 !
       
   458 
   446 lineLength
   459 lineLength
   447     "to make a textCollector (somewhat) compatible with printer
   460     "to make a textCollector (somewhat) compatible with printer
   448      streams, support the lineLength query"
   461      streams, support the lineLength query"
   449 
   462 
   450     ^ width // (font width)
   463     ^ width // (font width)
   453 !
   466 !
   454 
   467 
   455 nextPut:something
   468 nextPut:something
   456     "append somethings printString to my displayed text.
   469     "append somethings printString to my displayed text.
   457      This allows TextCollectors to be used Stream-wise"
   470      This allows TextCollectors to be used Stream-wise"
       
   471 
       
   472     |txt|
   458 
   473 
   459     (something isCharacter) ifTrue:[
   474     (something isCharacter) ifTrue:[
   460         ((something == Character cr) or:[something == Character nl]) ifTrue:[
   475         ((something == Character cr) or:[something == Character nl]) ifTrue:[
   461             ^ self cr
   476             ^ self cr
   462         ].
   477         ].
   463     ].
   478     ].
   464     self show:(something asString).
   479 
       
   480     txt := something asString.
       
   481     currentEmphasis notNil ifTrue:[
       
   482         txt := txt emphasizeAllWith:currentEmphasis
       
   483     ].
       
   484     self show:txt.
   465 
   485 
   466 "/    flushPending ifTrue:[
   486 "/    flushPending ifTrue:[
   467 "/        self endEntry
   487 "/        self endEntry
   468 "/    ].
   488 "/    ].
   469 "/    (something isMemberOf:Character) ifTrue:[
   489 "/    (something isMemberOf:Character) ifTrue:[
   482 
   502 
   483 nextPutAll:something
   503 nextPutAll:something
   484     "append all of something to my displayed text.
   504     "append all of something to my displayed text.
   485      This allows TextCollectors to be used Stream-wise"
   505      This allows TextCollectors to be used Stream-wise"
   486 
   506 
       
   507     currentEmphasis notNil ifTrue:[
       
   508         ^ self show:(something emphasizeAllWith:currentEmphasis)
       
   509     ].
   487     ^ self show:something
   510     ^ self show:something
   488 
   511 
   489     "Modified: 11.1.1997 / 14:43:26 / cg"
   512     "Modified: 11.1.1997 / 14:43:26 / cg"
       
   513 !
       
   514 
       
   515 normal
       
   516     currentEmphasis := nil
   490 !
   517 !
   491 
   518 
   492 show:anObject
   519 show:anObject
   493     "insert the argument aString at current cursor position"
   520     "insert the argument aString at current cursor position"
   494 
   521 
   572 ! !
   599 ! !
   573 
   600 
   574 !TextCollector class methodsFor:'documentation'!
   601 !TextCollector class methodsFor:'documentation'!
   575 
   602 
   576 version
   603 version
   577     ^ '$Header: /cvs/stx/stx/libwidg/TextCollector.st,v 1.45 1998-04-22 15:11:30 ca Exp $'
   604     ^ '$Header: /cvs/stx/stx/libwidg/TextCollector.st,v 1.46 1998-04-24 18:46:15 cg Exp $'
   578 ! !
   605 ! !