TerminalView.st
changeset 2191 221cae81c950
parent 2169 132759c9c32c
child 2192 5f3bf896d334
equal deleted inserted replaced
2190:9c7777ad9594 2191:221cae81c950
  1549 "/].
  1549 "/].
  1550 "/self showCursor.
  1550 "/self showCursor.
  1551 "/^ self.
  1551 "/^ self.
  1552 
  1552 
  1553     access critical:[
  1553     access critical:[
  1554         |i i2 s crnlFollows|
  1554         |index controlCharIndex stringWithOutControl crnlFollows|
  1555 
  1555 
  1556         i := 1.
  1556         index := 1.
  1557         [i <= count] whileTrue:[
  1557         [index <= count] whileTrue:[
  1558             (state == 0) ifTrue:[
  1558             (state == 0) ifTrue:[
  1559                 "/ in initial state.
  1559                 "/ in initial state.
  1560                 "/ quick scan forward for next control character ...
  1560                 "/ quick scan forward for next control character ...
  1561                 i2 := buffer indexOfControlCharacterStartingAt:i.
  1561                 controlCharIndex := buffer indexOfControlCharacterStartingAt:index.
  1562                 i2 > count ifTrue:[i2 := 0].
  1562                 controlCharIndex > count ifTrue:[controlCharIndex := 0].
  1563 
  1563 
  1564                 i2 == 0 ifTrue:[
  1564                 controlCharIndex == 0 ifTrue:[
  1565                     "/ no control characters - simply append all
  1565                     "/ no control characters - simply append all
  1566                     "/ to the outstanding lines ...
  1566                     "/ to the outstanding lines ...
  1567                     s := buffer copyFrom:i to:count.
  1567                     stringWithOutControl := buffer copyFrom:index to:count.
  1568                     i := count + 1. "/ leave loop.
  1568                     index := count + 1. "/ leave loop.
  1569                     crnlFollows := false.
  1569                     crnlFollows := false.
  1570                 ] ifFalse:[
  1570                 ] ifFalse:[
  1571                     i2 > i ifTrue:[
  1571                     controlCharIndex > index ifTrue:[
  1572                         s := buffer copyFrom:i to:i2-1.
  1572                         stringWithOutControl := buffer copyFrom:index to:controlCharIndex-1.
  1573                         i := i2. "/ proceed withcontrol character
  1573                         index := controlCharIndex. "/ proceed withcontrol character
  1574                         crnlFollows := false.
  1574                         crnlFollows := false.
  1575                         i < (count - 1) ifTrue:[
  1575                         index < (count - 1) ifTrue:[
  1576                             (buffer at:i) == Character return ifTrue:[
  1576                             (buffer at:index) == Character return ifTrue:[
  1577                                 (buffer at:i+1) == Character nl ifTrue:[
  1577                                 (buffer at:index+1) == Character nl ifTrue:[
  1578                                     crnlFollows := true.
  1578                                     crnlFollows := true.
  1579                                     i := i + 2.
  1579                                     index := index + 2.
  1580                                 ]
  1580                                 ]
  1581                             ]
  1581                             ]
  1582                         ].
  1582                         ].
  1583                     ]
  1583                     ]
  1584                 ].
  1584                 ].
  1585             ].
  1585             ].
  1586 
  1586 
  1587             s notNil ifTrue:[
  1587             stringWithOutControl notNil ifTrue:[
  1588                 currentEmphasis notNil ifTrue:[
  1588                 currentEmphasis notNil ifTrue:[
  1589                     s := s emphasizeAllWith:currentEmphasis
  1589                     stringWithOutControl := stringWithOutControl emphasizeAllWith:currentEmphasis
  1590                 ].
  1590                 ].
  1591 
  1591 
  1592                 outstandingLine size > 0 ifTrue:[
  1592                 outstandingLine size > 0 ifTrue:[
  1593                     outstandingLine := outstandingLine , s.
  1593                     outstandingLine := outstandingLine , stringWithOutControl.
  1594                 ] ifFalse:[
  1594                 ] ifFalse:[
  1595                     outstandingLine := s.
  1595                     outstandingLine := stringWithOutControl.
  1596                 ].
  1596                 ].
  1597                 crnlFollows ifTrue:[
  1597                 crnlFollows ifTrue:[
  1598                     outstandingLines isNil ifTrue:[
  1598                     outstandingLines isNil ifTrue:[
  1599                         outstandingLines := OrderedCollection with:outstandingLine
  1599                         outstandingLines := OrderedCollection with:outstandingLine
  1600                     ] ifFalse:[
  1600                     ] ifFalse:[
  1601                         outstandingLines add:outstandingLine.
  1601                         outstandingLines add:outstandingLine.
  1602                     ].
  1602                     ].
  1603                     outstandingLine := ''.
  1603                     outstandingLine := ''.
  1604                 ].
  1604                 ].
  1605                 s := nil.
  1605                 stringWithOutControl := nil.
  1606 
  1606 
  1607                 collecting ifTrue:[
  1607                 collecting ifTrue:[
  1608                     flushPending ifFalse:[
  1608                     flushPending ifFalse:[
  1609                         self installDelayedUpdate
  1609                         self installDelayedUpdate
  1610                     ] ifTrue:[
  1610                     ] ifTrue:[
  1618             ] ifFalse:[
  1618             ] ifFalse:[
  1619                 "/ no chunk to append (in an escape sequence)
  1619                 "/ no chunk to append (in an escape sequence)
  1620                 "/ must handle individual characters
  1620                 "/ must handle individual characters
  1621                 "/ to update the state machine.
  1621                 "/ to update the state machine.
  1622 
  1622 
  1623                 self nextPut:(buffer at:i).
  1623                 self nextPut:(buffer at:index).
  1624                 i := i + 1.
  1624                 index := index + 1.
  1625                 [state ~~ 0 and:[i <= count]] whileTrue:[
  1625                 [state ~~ 0 and:[index <= count]] whileTrue:[
  1626                     self nextPut:(buffer at:i).
  1626                     self nextPut:(buffer at:index).
  1627                     i := i + 1.
  1627                     index := index + 1.
  1628                 ]
  1628                 ]
  1629             ]
  1629             ]
  1630         ].
  1630         ].
  1631     ].
  1631     ].
  1632 
  1632 
  1776 ! !
  1776 ! !
  1777 
  1777 
  1778 !TerminalView class methodsFor:'documentation'!
  1778 !TerminalView class methodsFor:'documentation'!
  1779 
  1779 
  1780 version
  1780 version
  1781     ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.98 2002-09-05 12:41:42 cg Exp $'
  1781     ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.99 2002-09-17 09:07:29 penk Exp $'
  1782 ! !
  1782 ! !