628 ! |
628 ! |
629 |
629 |
630 add:aString beforeIndex:index |
630 add:aString beforeIndex:index |
631 "add a line and redisplay" |
631 "add a line and redisplay" |
632 |
632 |
|
633 |lastShown| |
|
634 |
633 list isNil ifTrue:[list := OrderedCollection new]. |
635 list isNil ifTrue:[list := OrderedCollection new]. |
634 list add:aString beforeIndex:index. |
636 list add:aString beforeIndex:index. |
635 |
637 |
636 widthOfWidestLine notNil ifTrue:[ |
638 widthOfWidestLine notNil ifTrue:[ |
637 self recomputeWidthOfWidestLineFor:aString |
639 self recomputeWidthOfWidestLineFor:aString |
640 includesNonStrings ifFalse:[ |
642 includesNonStrings ifFalse:[ |
641 includesNonStrings := (aString notNil and:[aString isString not]). |
643 includesNonStrings := (aString notNil and:[aString isString not]). |
642 "/ includesNonStrings ifTrue:[self getFontParameters]. |
644 "/ includesNonStrings ifTrue:[self getFontParameters]. |
643 ]. |
645 ]. |
644 shown ifTrue:[ |
646 shown ifTrue:[ |
645 index to:self lastLineShown do:[:eachLine | |
647 lastShown := self lastLineShown. |
646 self invalidateLine:eachLine |
648 index <= 2 ifTrue:[ |
|
649 self invalidate |
|
650 ] ifFalse:[ |
|
651 index to:lastShown do:[:eachLine | |
|
652 self invalidateLine:eachLine |
|
653 ]. |
647 ]. |
654 ]. |
648 "/ self redrawFromLine:index. |
|
649 ]. |
655 ]. |
650 self contentsChanged. "recompute scrollbars" |
656 self contentsChanged. "recompute scrollbars" |
651 |
657 |
652 (scrollWhenUpdating == #end or:[scrollWhenUpdating == #endOfText]) ifTrue:[ |
658 (scrollWhenUpdating == #end or:[scrollWhenUpdating == #endOfText]) ifTrue:[ |
653 "/ self selection isNil ifTrue:[ |
659 "/ self selection isNil ifTrue:[ |
655 "/ ] |
661 "/ ] |
656 ]. |
662 ]. |
657 ! |
663 ! |
658 |
664 |
659 addAll:aCollectionOfLines beforeIndex:index |
665 addAll:aCollectionOfLines beforeIndex:index |
660 "add a line and redisplay" |
666 "add a bunch of lines and redisplay" |
|
667 |
|
668 |lastShown| |
661 |
669 |
662 list isNil ifTrue:[list := OrderedCollection new]. |
670 list isNil ifTrue:[list := OrderedCollection new]. |
663 aCollectionOfLines do:[:eachLine | |
671 aCollectionOfLines do:[:eachLine | |
664 list addAll:aCollectionOfLines beforeIndex:index. |
672 list addAll:aCollectionOfLines beforeIndex:index. |
665 ]. |
673 ]. |
|
674 includesNonStrings ifFalse:[ |
|
675 aCollectionOfLines do:[:eachLine | |
|
676 includesNonStrings := includesNonStrings or:[(eachLine notNil and:[eachLine isString not])]. |
|
677 ] |
|
678 ]. |
666 |
679 |
667 widthOfWidestLine := nil. "/ i.e. unknown |
680 widthOfWidestLine := nil. "/ i.e. unknown |
668 self textChanged. |
681 self textChanged. |
669 |
682 |
670 ((index-1) <= self lastLineShown) ifTrue:[ |
683 shown ifTrue:[ |
671 index-1 to:self lastLineShown do:[:eachLine | |
684 lastShown := self lastLineShown. |
672 self invalidateLine:eachLine |
685 ((index-1) <= lastShown) ifTrue:[ |
|
686 index <= 2 ifTrue:[ |
|
687 self invalidate |
|
688 ] ifFalse:[ |
|
689 index-1 to:lastShown do:[:eachLine | |
|
690 self invalidateLine:eachLine |
|
691 ]. |
|
692 "/ self redrawFromLine:index-1. |
|
693 ]. |
673 ]. |
694 ]. |
674 "/ self redrawFromLine:index-1. |
695 ]. |
675 ]. |
|
676 |
|
677 self contentsChanged. "recompute scrollbars" |
696 self contentsChanged. "recompute scrollbars" |
678 |
697 |
679 (scrollWhenUpdating == #end or:[scrollWhenUpdating == #endOfText]) ifTrue:[ |
698 (scrollWhenUpdating == #end or:[scrollWhenUpdating == #endOfText]) ifTrue:[ |
680 "/ self selection isNil ifTrue:[ |
699 "/ self selection isNil ifTrue:[ |
681 self scrollToBottom. |
700 self scrollToBottom. |
682 "/ ] |
701 "/ ] |
683 ]. |
702 ]. |
684 |
|
685 ! |
703 ! |
686 |
704 |
687 at:lineNr |
705 at:lineNr |
688 "retrieve a line; return nil if beyond end-of-text. |
706 "retrieve a line; return nil if beyond end-of-text. |
689 this allows textViews to be used like collections in some places." |
707 this allows textViews to be used like collections in some places." |