99 |
100 |
100 firstLineShown <Number> the index of the 1st visible line (1 ..) |
101 firstLineShown <Number> the index of the 1st visible line (1 ..) |
101 leftOffset <Number> left offset for horizontal scroll |
102 leftOffset <Number> left offset for horizontal scroll |
102 |
103 |
103 nFullLinesShown <Number> the number of unclipped lines in visible area |
104 nFullLinesShown <Number> the number of unclipped lines in visible area |
104 (internal; updated on size changes) |
105 (internal; updated on size changes) |
105 nLinesShown <Number> the number of lines in visible area, incl. partial |
106 nLinesShown <Number> the number of lines in visible area, incl. partial |
106 (internal; updated on size changes) |
107 (internal; updated on size changes) |
107 |
108 |
108 fgColor <Color> color to draw characters |
109 fgColor <Color> color to draw characters |
109 bgColor <Color> the background |
110 bgColor <Color> the background |
110 |
111 |
111 partialLines <Boolean> allow last line to be partial displayed |
112 partialLines <Boolean> allow last line to be partial displayed |
123 lastSearchPattern <String> last pattern for searching |
124 lastSearchPattern <String> last pattern for searching |
124 (kept to provide a default for next search) |
125 (kept to provide a default for next search) |
125 lastSearchIgnoredCase <Boolean> last search ignored case |
126 lastSearchIgnoredCase <Boolean> last search ignored case |
126 (kept to provide a default for next search) |
127 (kept to provide a default for next search) |
127 wordCheck <Block> rule used for check for word boundaries in word select |
128 wordCheck <Block> rule used for check for word boundaries in word select |
128 The default rule is to return true for alphaNumeric characters. |
129 The default rule is to return true for alphaNumeric characters. |
129 (can be changed to allow for underscore and other |
130 (can be changed to allow for underscore and other |
130 characters to be treated as alphaCharacters) |
131 characters to be treated as alphaCharacters) |
131 |
132 |
132 autoScrollBlock <Block> block installed as timeoutBlock when doing an |
133 autoScrollBlock <Block> block installed as timeoutBlock when doing an |
133 autoScroll (internal) |
134 autoScroll (internal) |
134 autoScrollDeltaT computed scroll time delta in seconds (internal) |
135 autoScrollDeltaT computed scroll time delta in seconds (internal) |
135 |
136 |
136 includesNonStrings cached flag if any non-strings are in list |
137 includesNonStrings cached flag if any non-strings are in list |
137 widthOfWidestLine cached width of widest line |
138 widthOfWidestLine cached width of widest line |
138 listMsg if view has a model and listMsg is non-nil, |
139 listMsg if view has a model and listMsg is non-nil, |
139 this is sent to the model to aquired a new contents |
140 this is sent to the model to aquired a new contents |
140 whenever a change of the aspect (aspectMsg) occurs. |
141 whenever a change of the aspect (aspectMsg) occurs. |
141 |
142 |
142 viewOrigin the current origin |
143 viewOrigin the current origin |
143 |
144 |
144 backgroundAlreadyClearedColor internal; speedup by avoiding |
145 backgroundAlreadyClearedColor internal; speedup by avoiding |
145 multiple fills when drawing |
146 multiple fills when drawing |
146 internal lines |
147 internal lines |
147 |
148 |
148 [StyleSheet parameters:] |
149 [StyleSheet parameters:] |
149 |
150 |
319 ! ! |
320 ! ! |
320 |
321 |
321 !ListView class methodsFor:'defaults'! |
322 !ListView class methodsFor:'defaults'! |
322 |
323 |
323 defaultTabPositions |
324 defaultTabPositions |
|
325 "return an array containing the default tab positions" |
|
326 |
324 ^ self tab8Positions |
327 ^ self tab8Positions |
325 ! |
328 ! |
326 |
329 |
327 tab4Positions |
330 tab4Positions |
|
331 "return an array containing tab positions for 4-col tabs" |
|
332 |
328 ^ #(1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 |
333 ^ #(1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 |
329 85 89 93 97 101 105 109 113 114 121 125 129 133 137 141 145) |
334 85 89 93 97 101 105 109 113 114 121 125 129 133 137 141 145) |
330 ! |
335 ! |
331 |
336 |
332 tab8Positions |
337 tab8Positions |
|
338 "return an array containing tab positions for 8-col tabs" |
|
339 |
333 ^ #(1 9 17 25 33 41 49 57 65 73 81 89 97 105 113 121 129 137 145) |
340 ^ #(1 9 17 25 33 41 49 57 65 73 81 89 97 105 113 121 129 137 145) |
334 ! |
341 ! |
335 |
342 |
336 updateStyleCache |
343 updateStyleCache |
337 "extract values from the styleSheet and cache them in class variables" |
344 "extract values from the styleSheet and cache them in class variables" |
338 |
345 |
339 <resource: #style (#'text.foregroundColor' #'text.backgroundColor' |
346 <resource: #style (#'text.foregroundColor' #'text.backgroundColor' |
340 #'text.tabPositions' |
347 #'text.tabPositions' |
341 #'text.font')> |
348 #'text.font')> |
342 |
349 |
343 DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black. |
350 DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black. |
344 DefaultBackgroundColor := StyleSheet colorAt:'text.backgroundColor' default:White. |
351 DefaultBackgroundColor := StyleSheet colorAt:'text.backgroundColor' default:White. |
345 DefaultFont := StyleSheet fontAt:'text.font'. |
352 DefaultFont := StyleSheet fontAt:'text.font'. |
346 DefaultTabPositions := StyleSheet at:'text.tabPositions'. |
353 DefaultTabPositions := StyleSheet at:'text.tabPositions'. |
347 DefaultTabPositions isNil ifTrue:[DefaultTabPositions := self defaultTabPositions]. |
354 DefaultTabPositions isNil ifTrue:[DefaultTabPositions := self defaultTabPositions]. |
|
355 DefaultLeftMargin := 0.5. |
|
356 DefaultTopMargin := 0.5. |
348 |
357 |
349 "Modified: 20.10.1997 / 15:05:30 / cg" |
358 "Modified: 20.10.1997 / 15:05:30 / cg" |
350 ! ! |
359 ! ! |
351 |
360 |
352 !ListView methodsFor:'accessing'! |
361 !ListView methodsFor:'accessing'! |
359 |
368 |
360 backgroundColor:aColor |
369 backgroundColor:aColor |
361 "set the background color of the contents" |
370 "set the background color of the contents" |
362 |
371 |
363 bgColor ~~ aColor ifTrue:[ |
372 bgColor ~~ aColor ifTrue:[ |
364 bgColor := aColor. |
373 bgColor := aColor. |
365 self viewBackground:bgColor. |
374 self viewBackground:bgColor. |
366 shown ifTrue:[ |
375 shown ifTrue:[ |
367 self invalidate "/ clear; redraw |
376 self invalidate "/ clear; redraw |
368 ] |
377 ] |
369 ] |
378 ] |
370 |
379 |
371 "Modified: 3.5.1997 / 10:27:40 / cg" |
380 "Modified: 3.5.1997 / 10:27:40 / cg" |
372 ! |
381 ! |
373 |
382 |
374 font:aFont |
383 font:aFont |
375 "set the font for all shown text. |
384 "set the font for all shown text. |
376 Redraws everything. |
385 Redraws everything. |
377 CAVEAT: with the addition of Text objects, |
386 CAVEAT: with the addition of Text objects, |
378 this method is going to be obsoleted by a textStyle |
387 this method is going to be obsoleted by a textStyle |
379 method, which allows specific control over |
388 method, which allows specific control over |
380 normalFont/boldFont/italicFont parameters." |
389 normalFont/boldFont/italicFont parameters." |
381 |
390 |
382 aFont isNil ifTrue:[ |
391 aFont isNil ifTrue:[ |
383 ^ self error:'nil font' |
392 ^ self error:'nil font' |
384 ]. |
393 ]. |
385 font ~~ aFont ifTrue:[ |
394 font ~~ aFont ifTrue:[ |
386 super font:(aFont on:device). |
395 super font:(aFont on:device). |
387 preferredExtent := nil. |
396 preferredExtent := nil. |
388 widthOfWidestLine := nil. "/ i.e. unknown |
397 widthOfWidestLine := nil. "/ i.e. unknown |
389 self getFontParameters. |
398 self getFontParameters. |
390 realized ifTrue:[ |
399 realized ifTrue:[ |
391 (font graphicsDevice == device) ifTrue:[ |
400 (font graphicsDevice == device) ifTrue:[ |
392 self getFontParameters. |
401 self getFontParameters. |
393 self computeNumberOfLinesShown. |
402 self computeNumberOfLinesShown. |
394 shown ifTrue:[ |
403 shown ifTrue:[ |
395 self redrawFromVisibleLine:1 to:nLinesShown |
404 self redrawFromVisibleLine:1 to:nLinesShown |
396 ] |
405 ] |
397 ]. |
406 ]. |
398 self contentsChanged |
407 self contentsChanged |
399 ] |
408 ] |
400 ] |
409 ] |
401 |
410 |
402 "Modified: 5.7.1996 / 17:55:34 / cg" |
411 "Modified: 5.7.1996 / 17:55:34 / cg" |
403 ! |
412 ! |
404 |
413 |
405 fontHeight:pixels |
414 fontHeight:pixels |
406 "set the lines height - thats the number of pixels, |
415 "set the lines height - thats the number of pixels, |
407 by which lines are vertically separated." |
416 by which lines are vertically separated." |
408 |
417 |
409 fontHeight ~~ pixels ifTrue:[ |
418 fontHeight ~~ pixels ifTrue:[ |
410 fontHeight := pixels. |
419 fontHeight := pixels. |
411 ] |
420 ] |
412 |
421 |
413 "Created: 17.4.1997 / 01:41:33 / cg" |
422 "Created: 17.4.1997 / 01:41:33 / cg" |
414 ! |
423 ! |
415 |
424 |
595 |
604 |
596 fontHeightBefore := fontHeight. |
605 fontHeightBefore := fontHeight. |
597 self withoutRedrawAt:index put:aString. |
606 self withoutRedrawAt:index put:aString. |
598 |
607 |
599 shown ifTrue:[ |
608 shown ifTrue:[ |
600 "/ synchronous drawing: |
609 "/ synchronous drawing: |
601 |
610 |
602 "/ this could have changed the font height; |
611 "/ this could have changed the font height; |
603 "/ must clear all below last line, if it became smaller |
612 "/ must clear all below last line, if it became smaller |
604 fontHeightBefore > fontHeight ifTrue:[ |
613 fontHeightBefore > fontHeight ifTrue:[ |
605 (self listLineIsVisible:(self size)) ifTrue:[ |
614 (self listLineIsVisible:(self size)) ifTrue:[ |
606 self clearRectangle:(margin @ (self yOfVisibleLine:nLinesShown+1)) |
615 self clearRectangle:(margin @ (self yOfVisibleLine:nLinesShown+1)) |
607 corner:(width-margin) @ (height-margin). |
616 corner:(width-margin) @ (height-margin). |
608 ]. |
617 ]. |
609 self redrawFromLine:index |
618 self redrawFromLine:index |
610 ] ifFalse:[ |
619 ] ifFalse:[ |
611 self redrawLine:index |
620 self redrawLine:index |
612 ]. |
621 ]. |
613 |
622 |
614 "/ asynchronous: |
623 "/ asynchronous: |
615 "/ visibleLine := self listLineToVisibleLine:index. |
624 "/ visibleLine := self listLineToVisibleLine:index. |
616 "/ visibleLine notNil ifTrue:[ |
625 "/ visibleLine notNil ifTrue:[ |
617 "/ y := self yOfVisibleLine:visibleLine. |
626 "/ y := self yOfVisibleLine:visibleLine. |
618 "/ self invalidate:((margin @ y) extent:(width@fontHeight)) |
627 "/ self invalidate:((margin @ y) extent:(width@fontHeight)) |
619 "/ ]. |
628 "/ ]. |
739 (the nonStrings information is remembered to optimize later redraws & height computations)." |
748 (the nonStrings information is remembered to optimize later redraws & height computations)." |
740 |
749 |
741 |oldFirst oldLeft nonStringsBefore fontHeightBefore| |
750 |oldFirst oldLeft nonStringsBefore fontHeightBefore| |
742 |
751 |
743 (aCollection isNil and:[list isNil]) ifTrue:[ |
752 (aCollection isNil and:[list isNil]) ifTrue:[ |
744 "no change" |
753 "no change" |
745 self scrollToTop. |
754 self scrollToTop. |
746 self scrollToLeft. |
755 self scrollToLeft. |
747 ^ self |
756 ^ self |
748 ]. |
757 ]. |
749 list := aCollection. |
758 list := aCollection. |
750 |
759 |
751 nonStringsBefore := includesNonStrings. |
760 nonStringsBefore := includesNonStrings. |
752 fontHeightBefore := fontHeight. |
761 fontHeightBefore := fontHeight. |
753 includesNonStrings := false. |
762 includesNonStrings := false. |
754 |
763 |
755 list notNil ifTrue:[ |
764 list notNil ifTrue:[ |
756 expand ifTrue:[ |
765 expand ifTrue:[ |
757 self expandTabs |
766 self expandTabs |
758 ] ifFalse:[ |
767 ] ifFalse:[ |
759 scan ifTrue:[ |
768 scan ifTrue:[ |
760 includesNonStrings := (list findFirst:[:e | e isString not]) ~~ 0. |
769 includesNonStrings := (list findFirst:[:e | e isString not]) ~~ 0. |
761 ] ifFalse:[ |
770 ] ifFalse:[ |
762 includesNonStrings := nonStrings |
771 includesNonStrings := nonStrings |
763 ] |
772 ] |
764 ]. |
773 ]. |
765 ]. |
774 ]. |
766 (includesNonStrings ~~ nonStringsBefore) ifTrue:[ |
775 (includesNonStrings ~~ nonStringsBefore) ifTrue:[ |
767 self getFontParameters. |
776 self getFontParameters. |
768 ]. |
777 ]. |
769 |
778 |
770 widthOfWidestLine := nil. "/ i.e. unknown |
779 widthOfWidestLine := nil. "/ i.e. unknown |
771 oldFirst := firstLineShown. |
780 oldFirst := firstLineShown. |
772 oldLeft := leftOffset. |
781 oldLeft := leftOffset. |
773 firstLineShown := 1. |
782 firstLineShown := 1. |
774 leftOffset := 0. |
783 leftOffset := 0. |
775 |
784 |
776 realized ifTrue:[ |
785 realized ifTrue:[ |
777 (includesNonStrings ~~ nonStringsBefore) ifTrue:[ |
786 (includesNonStrings ~~ nonStringsBefore) ifTrue:[ |
778 self computeNumberOfLinesShown. |
787 self computeNumberOfLinesShown. |
779 ]. |
788 ]. |
780 self contentsChanged. |
789 self contentsChanged. |
781 " |
790 " |
782 dont use scroll here to avoid double redraw |
791 dont use scroll here to avoid double redraw |
783 " |
792 " |
784 viewOrigin := 0 @ 0. |
793 viewOrigin := 0 @ 0. |
785 |
794 |
786 oldFirst ~~ firstLineShown ifTrue:[ |
795 oldFirst ~~ firstLineShown ifTrue:[ |
787 self originChanged:0 @ ((oldFirst - 1) * fontHeight negated). |
796 self originChanged:0 @ ((oldFirst - 1) * fontHeight negated). |
788 ]. |
797 ]. |
789 shown ifTrue:[ |
798 shown ifTrue:[ |
790 self redrawFromVisibleLine:1 to:nLinesShown. |
799 self redrawFromVisibleLine:1 to:nLinesShown. |
791 |
800 |
792 fontHeightBefore > fontHeight ifTrue:[ |
801 fontHeightBefore > fontHeight ifTrue:[ |
793 (self listLineIsVisible:(self size)) ifTrue:[ |
802 (self listLineIsVisible:(self size)) ifTrue:[ |
794 "/ self clearRectangle:((margin @ (self yOfVisibleLine:nLinesShown+1)) |
803 "/ self clearRectangle:((margin @ (self yOfVisibleLine:nLinesShown+1)) |
795 "/ corner:(width-margin) @ (height-margin)). |
804 "/ corner:(width-margin) @ (height-margin)). |
796 ]. |
805 ]. |
797 ] |
806 ] |
798 ] |
807 ] |
799 ] |
808 ] |
800 |
809 |
801 "Modified: / 30.8.1995 / 19:07:13 / claus" |
810 "Modified: / 30.8.1995 / 19:07:13 / claus" |
802 "Created: / 5.6.1997 / 12:40:06 / cg" |
811 "Created: / 5.6.1997 / 12:40:06 / cg" |
803 "Modified: / 26.7.1998 / 13:47:35 / cg" |
812 "Modified: / 26.7.1998 / 13:47:35 / cg" |
815 is there a need to redraw ? |
824 is there a need to redraw ? |
816 " |
825 " |
817 shown ifFalse:[^ self]. |
826 shown ifFalse:[^ self]. |
818 visLine := self listLineToVisibleLine:lineNr. |
827 visLine := self listLineToVisibleLine:lineNr. |
819 visLine notNil ifTrue:[ |
828 visLine notNil ifTrue:[ |
820 w := self widthForScrollBetween:lineNr and:(firstLineShown + nLinesShown). |
829 w := self widthForScrollBetween:lineNr and:(firstLineShown + nLinesShown). |
821 "/ x := textStartLeft. |
830 "/ x := textStartLeft. |
822 "/ CLAUS fixes leftOver selection pixels |
831 "/ CLAUS fixes leftOver selection pixels |
823 w := w + leftMargin. |
832 w := w + leftMargin. |
824 x := margin. |
833 x := margin. |
825 |
834 |
826 srcY := topMargin + (visLine * fontHeight). |
835 srcY := topMargin + (visLine * fontHeight). |
827 "/ h := ((nLinesShown - visLine) * fontHeight). |
836 "/ h := ((nLinesShown - visLine) * fontHeight). |
828 h := (height - margin - srcY). |
837 h := (height - margin - srcY). |
829 h > 0 ifTrue:[ |
838 h > 0 ifTrue:[ |
830 self catchExpose. |
839 self catchExpose. |
831 self |
840 self |
832 copyFrom:self |
841 copyFrom:self |
833 x:x y:srcY |
842 x:x y:srcY |
834 toX:x y:(srcY - fontHeight) |
843 toX:x y:(srcY - fontHeight) |
835 width:w height:h |
844 width:w height:h |
836 async:true. |
845 async:true. |
837 ]. |
846 ]. |
838 self redrawVisibleLine:nFullLinesShown. |
847 self redrawVisibleLine:nFullLinesShown. |
839 " |
848 " |
840 redraw last partial line - if any |
849 redraw last partial line - if any |
841 " |
850 " |
842 (nFullLinesShown ~~ nLinesShown) ifTrue:[ |
851 (nFullLinesShown ~~ nLinesShown) ifTrue:[ |
843 self redrawVisibleLine:nLinesShown |
852 self redrawVisibleLine:nLinesShown |
844 ]. |
853 ]. |
845 h > 0 ifTrue:[ |
854 h > 0 ifTrue:[ |
846 self waitForExpose |
855 self waitForExpose |
847 ]. |
856 ]. |
848 ] |
857 ] |
849 |
858 |
850 "Modified: / 27.2.1998 / 12:36:59 / cg" |
859 "Modified: / 27.2.1998 / 12:36:59 / cg" |
851 ! |
860 ! |
852 |
861 |
930 |
939 |
931 nonStringsBefore := includesNonStrings. |
940 nonStringsBefore := includesNonStrings. |
932 includesNonStrings := false. |
941 includesNonStrings := false. |
933 |
942 |
934 list notNil ifTrue:[ |
943 list notNil ifTrue:[ |
935 expandTabs ifTrue:[ |
944 expandTabs ifTrue:[ |
936 self expandTabs |
945 self expandTabs |
937 ] ifFalse:[ |
946 ] ifFalse:[ |
938 includesNonStrings := (list findFirst:[:e | e isString not]) ~~ 0. |
947 includesNonStrings := (list findFirst:[:e | e isString not]) ~~ 0. |
939 ]. |
948 ]. |
940 ]. |
949 ]. |
941 (includesNonStrings ~~ nonStringsBefore) ifTrue:[ |
950 (includesNonStrings ~~ nonStringsBefore) ifTrue:[ |
942 self getFontParameters. |
951 self getFontParameters. |
943 self computeNumberOfLinesShown. |
952 self computeNumberOfLinesShown. |
944 ]. |
953 ]. |
945 |
954 |
946 "/ new - reposition horizontally if too big |
955 "/ new - reposition horizontally if too big |
947 widthOfWidestLine := nil. "/ i.e. unknown |
956 widthOfWidestLine := nil. "/ i.e. unknown |
948 innerWidth >= self widthOfContents ifTrue:[ |
957 innerWidth >= self widthOfContents ifTrue:[ |
949 viewOrigin x:0. |
958 viewOrigin x:0. |
950 leftOffset := 0. |
959 leftOffset := 0. |
951 ]. |
960 ]. |
952 self contentsChanged. |
961 self contentsChanged. |
953 |
962 |
954 "/ new - reposition vertically if too big |
963 "/ new - reposition vertically if too big |
955 (firstLineShown + nFullLinesShown) > self size ifTrue:[ |
964 (firstLineShown + nFullLinesShown) > self size ifTrue:[ |
956 oldFirst := firstLineShown. |
965 oldFirst := firstLineShown. |
957 firstLineShown := self size - nFullLinesShown + 1. |
966 firstLineShown := self size - nFullLinesShown + 1. |
958 firstLineShown < 1 ifTrue:[firstLineShown := 1]. |
967 firstLineShown < 1 ifTrue:[firstLineShown := 1]. |
959 |
968 |
960 viewOrigin y:(firstLineShown - 1 * fontHeight). |
969 viewOrigin y:(firstLineShown - 1 * fontHeight). |
961 self originChanged:0 @ ((oldFirst - 1) negated * fontHeight). |
970 self originChanged:0 @ ((oldFirst - 1) negated * fontHeight). |
962 linesShownBefore := nil. |
971 linesShownBefore := nil. |
963 shown ifTrue:[ |
972 shown ifTrue:[ |
964 self clear. |
973 self clear. |
965 ] |
974 ] |
966 ]. |
975 ]. |
967 "/ end new |
976 "/ end new |
968 |
977 |
969 (shown and:[doRedraw]) ifTrue:[ |
978 (shown and:[doRedraw]) ifTrue:[ |
970 self redrawFromVisibleLine:1 to:nLinesShown |
979 self redrawFromVisibleLine:1 to:nLinesShown |
971 |
980 |
972 "/ linesShownBefore isNil ifTrue:[ |
981 "/ linesShownBefore isNil ifTrue:[ |
973 "/ self redrawFromVisibleLine:1 to:nLinesShown |
982 "/ self redrawFromVisibleLine:1 to:nLinesShown |
974 "/ ] ifFalse:[ |
983 "/ ] ifFalse:[ |
975 "/ 1 to:nLinesShown do:[:l | |
984 "/ 1 to:nLinesShown do:[:l | |
1036 |
1045 |
1037 self checkForExistingLine:index. |
1046 self checkForExistingLine:index. |
1038 list at:index put:aString. |
1047 list at:index put:aString. |
1039 didIncludeNonStrings := includesNonStrings. |
1048 didIncludeNonStrings := includesNonStrings. |
1040 includesNonStrings ifFalse:[ |
1049 includesNonStrings ifFalse:[ |
1041 includesNonStrings := (aString notNil and:[aString isString not]). |
1050 includesNonStrings := (aString notNil and:[aString isString not]). |
1042 ] ifTrue:[ |
1051 ] ifTrue:[ |
1043 (aString isNil or:[aString isString]) ifTrue:[ |
1052 (aString isNil or:[aString isString]) ifTrue:[ |
1044 includesNonStrings := (list findFirst:[:l | l notNil and:[l isString not]]) ~~ 0. |
1053 includesNonStrings := (list findFirst:[:l | l notNil and:[l isString not]]) ~~ 0. |
1045 ] |
1054 ] |
1046 ]. |
1055 ]. |
1047 |
1056 |
1048 includesNonStrings ~~ didIncludeNonStrings ifTrue:[ |
1057 includesNonStrings ~~ didIncludeNonStrings ifTrue:[ |
1049 self getFontParameters. |
1058 self getFontParameters. |
1050 self computeNumberOfLinesShown |
1059 self computeNumberOfLinesShown |
1051 ]. |
1060 ]. |
1052 |
1061 |
1053 widthOfWidestLine notNil ifTrue:[ |
1062 widthOfWidestLine notNil ifTrue:[ |
1054 aString isString ifTrue:[ |
1063 aString isString ifTrue:[ |
1055 w := font widthOf:aString |
1064 w := font widthOf:aString |
1056 ] ifFalse:[ |
1065 ] ifFalse:[ |
1057 w := aString widthOn:self |
1066 w := aString widthOn:self |
1058 ]. |
1067 ]. |
1059 w > widthOfWidestLine ifTrue:[ |
1068 w > widthOfWidestLine ifTrue:[ |
1060 widthOfWidestLine := w |
1069 widthOfWidestLine := w |
1061 ] ifFalse:[ |
1070 ] ifFalse:[ |
1062 widthOfWidestLine := nil "/ means: unknown |
1071 widthOfWidestLine := nil "/ means: unknown |
1063 ]. |
1072 ]. |
1064 ] |
1073 ] |
1065 |
1074 |
1066 "Modified: / 26.7.1998 / 13:00:14 / cg" |
1075 "Modified: / 26.7.1998 / 13:00:14 / cg" |
1067 ! ! |
1076 ! ! |
1068 |
1077 |
1273 |
1282 |
1274 self paint:bg. |
1283 self paint:bg. |
1275 |
1284 |
1276 (lineString notNil and:[lineString isString not]) |
1285 (lineString notNil and:[lineString isString not]) |
1277 ifTrue:[ |
1286 ifTrue:[ |
1278 self drawVisibleLine:visLineNr with:fg and:bg |
1287 self drawVisibleLine:visLineNr with:fg and:bg |
1279 ] ifFalse:[ |
1288 ] ifFalse:[ |
1280 yf := y - (lineSpacing // 2). |
1289 yf := y - (lineSpacing // 2). |
1281 col > lineString size ifTrue:[ |
1290 col > lineString size ifTrue:[ |
1282 self fillRectangleX:x y:yf width:(font width) height:fontHeight. |
1291 self fillRectangleX:x y:yf width:(font width) height:fontHeight. |
1283 self paint:fg |
1292 self paint:fg |
1284 ] ifFalse:[ |
1293 ] ifFalse:[ |
1285 characterString := lineString copyFrom:col to:col. |
1294 characterString := lineString copyFrom:col to:col. |
1286 "/ (em := characterString emphasis) notNil ifTrue:[ |
1295 "/ (em := characterString emphasis) notNil ifTrue:[ |
1287 "/ em := em at:1. |
1296 "/ em := em at:1. |
1288 "/ (Text emphasis:em includes:#italic) ifTrue:[ |
1297 "/ (Text emphasis:em includes:#italic) ifTrue:[ |
1289 "/ self paint:fg on:bg. |
1298 "/ self paint:fg on:bg. |
1290 "/ self displayOpaqueString:characterString x:x y:(y + fontAscent). |
1299 "/ self displayOpaqueString:characterString x:x y:(y + fontAscent). |
1291 "/ ^ self |
1300 "/ ^ self |
1292 "/ ] |
1301 "/ ] |
1293 "/ ]. |
1302 "/ ]. |
1294 |
1303 |
1295 self fillRectangleX:x y:yf |
1304 self fillRectangleX:x y:yf |
1296 width:(font widthOf:characterString) |
1305 width:(font widthOf:characterString) |
1297 height:fontHeight. |
1306 height:fontHeight. |
1298 self paint:fg. |
1307 self paint:fg. |
1299 self displayString:characterString x:x y:(y + fontAscent) |
1308 self displayString:characterString x:x y:(y + fontAscent) |
1300 ] |
1309 ] |
1301 ] |
1310 ] |
1302 |
1311 |
1303 "Modified: / 22.4.1998 / 09:13:32 / cg" |
1312 "Modified: / 22.4.1998 / 09:13:32 / cg" |
1304 ! |
1313 ! |
1305 |
1314 |
1307 "draw part of a visible line in fg/bg" |
1316 "draw part of a visible line in fg/bg" |
1308 |
1317 |
1309 |y yf x lineString len characterString w sCol| |
1318 |y yf x lineString len characterString w sCol| |
1310 |
1319 |
1311 (endCol >= startCol) ifTrue:[ |
1320 (endCol >= startCol) ifTrue:[ |
1312 sCol := startCol max:1. |
1321 sCol := startCol max:1. |
1313 |
1322 |
1314 lineString := self visibleAt:visLineNr. |
1323 lineString := self visibleAt:visLineNr. |
1315 |
1324 |
1316 (lineString notNil and:[lineString isString not]) |
1325 (lineString notNil and:[lineString isString not]) |
1317 ifTrue:[ |
1326 ifTrue:[ |
1318 self drawVisibleLine:visLineNr with:fg and:bg. |
1327 self drawVisibleLine:visLineNr with:fg and:bg. |
1319 ] ifFalse:[ |
1328 ] ifFalse:[ |
1320 x := (self xOfCol:sCol inVisibleLine:visLineNr) - leftOffset. |
1329 x := (self xOfCol:sCol inVisibleLine:visLineNr) - leftOffset. |
1321 y := (self yOfVisibleLine:visLineNr). |
1330 y := (self yOfVisibleLine:visLineNr). |
1322 yf := y - (lineSpacing // 2). |
1331 yf := y - (lineSpacing // 2). |
1323 len := lineString size. |
1332 len := lineString size. |
1324 (sCol > len) ifTrue:[ |
1333 (sCol > len) ifTrue:[ |
1325 len := endCol - sCol + 1. |
1334 len := endCol - sCol + 1. |
1326 self paint:bg. |
1335 self paint:bg. |
1327 self fillRectangleX:x y:yf |
1336 self fillRectangleX:x y:yf |
1328 width:(fontWidth * len) |
1337 width:(fontWidth * len) |
1329 height:fontHeight |
1338 height:fontHeight |
1330 ] ifFalse:[ |
1339 ] ifFalse:[ |
1331 (endCol > len) ifTrue:[ |
1340 (endCol > len) ifTrue:[ |
1332 characterString := lineString species new:endCol. |
1341 characterString := lineString species new:endCol. |
1333 characterString replaceFrom:1 to:len with:lineString startingAt:1. |
1342 characterString replaceFrom:1 to:len with:lineString startingAt:1. |
1334 lineString := characterString |
1343 lineString := characterString |
1335 ]. |
1344 ]. |
1336 self paint:bg. |
1345 self paint:bg. |
1337 (lineString isMemberOf:String) ifTrue:[ |
1346 (lineString isMemberOf:String) ifTrue:[ |
1338 fontIsFixedWidth ifTrue:[ |
1347 fontIsFixedWidth ifTrue:[ |
1339 w := (endCol - sCol + 1) * fontWidth |
1348 w := (endCol - sCol + 1) * fontWidth |
1340 ] ifFalse:[ |
1349 ] ifFalse:[ |
1341 w := font widthOf:lineString from:sCol to:endCol |
1350 w := font widthOf:lineString from:sCol to:endCol |
1342 ] |
1351 ] |
1343 ] ifFalse:[ |
1352 ] ifFalse:[ |
1344 w := (lineString copyFrom:sCol to:endCol) widthOn:self |
1353 w := (lineString copyFrom:sCol to:endCol) widthOn:self |
1345 ]. |
1354 ]. |
1346 self fillRectangleX:x y:yf |
1355 self fillRectangleX:x y:yf |
1347 width:w |
1356 width:w |
1348 height:fontHeight. |
1357 height:fontHeight. |
1349 self paint:fg on:bg. |
1358 self paint:fg on:bg. |
1350 self displayOpaqueString:lineString from:sCol to:endCol x:x y:(y + fontAscent) |
1359 self displayOpaqueString:lineString from:sCol to:endCol x:x y:(y + fontAscent) |
1351 ] |
1360 ] |
1352 ] |
1361 ] |
1353 ] |
1362 ] |
1354 |
1363 |
1355 "Modified: / 3.9.1998 / 21:54:01 / cg" |
1364 "Modified: / 3.9.1998 / 21:54:01 / cg" |
1356 ! |
1365 ! |
1357 |
1366 |
1423 |
1432 |
1424 |yTop visLineNr| |
1433 |yTop visLineNr| |
1425 |
1434 |
1426 visLineNr := self listLineToVisibleLine:line. |
1435 visLineNr := self listLineToVisibleLine:line. |
1427 visLineNr notNil ifTrue:[ |
1436 visLineNr notNil ifTrue:[ |
1428 yTop := self yOfVisibleLine:visLineNr. |
1437 yTop := self yOfVisibleLine:visLineNr. |
1429 yTop isNil ifTrue:[^ self]. "/ not visible |
1438 yTop isNil ifTrue:[^ self]. "/ not visible |
1430 (yTop + fontHeight) < 0 ifTrue:[^ self]. "/ not visible |
1439 (yTop + fontHeight) < 0 ifTrue:[^ self]. "/ not visible |
1431 self invalidate:(Rectangle |
1440 self invalidate:(Rectangle |
1432 left:margin top:yTop |
1441 left:margin top:yTop |
1433 width:(width - (2 * margin)) height:fontHeight). |
1442 width:(width - (2 * margin)) height:fontHeight). |
1434 ] |
1443 ] |
1435 |
1444 |
1436 "Created: / 5.3.1998 / 01:24:19 / cg" |
1445 "Created: / 5.3.1998 / 01:24:19 / cg" |
1437 "Modified: / 5.3.1998 / 13:41:31 / cg" |
1446 "Modified: / 5.3.1998 / 13:41:31 / cg" |
1438 ! ! |
1447 ! ! |
1443 "contents changed - move origin up if possible" |
1452 "contents changed - move origin up if possible" |
1444 |
1453 |
1445 |listSize newOrigin| |
1454 |listSize newOrigin| |
1446 |
1455 |
1447 shown ifTrue:[ |
1456 shown ifTrue:[ |
1448 list notNil ifTrue:[ |
1457 list notNil ifTrue:[ |
1449 listSize := self numberOfLines. |
1458 listSize := self numberOfLines. |
1450 |
1459 |
1451 listSize == 0 ifTrue:[ |
1460 listSize == 0 ifTrue:[ |
1452 widthOfWidestLine := 0. |
1461 widthOfWidestLine := 0. |
1453 ]. |
1462 ]. |
1454 |
1463 |
1455 " |
1464 " |
1456 if we are beyond the end, scroll up a bit |
1465 if we are beyond the end, scroll up a bit |
1457 " |
1466 " |
1458 ((firstLineShown + nFullLinesShown) > listSize) ifTrue:[ |
1467 ((firstLineShown + nFullLinesShown) > listSize) ifTrue:[ |
1459 newOrigin := listSize - nFullLinesShown + 1. |
1468 newOrigin := listSize - nFullLinesShown + 1. |
1460 newOrigin < 1 ifTrue:[ |
1469 newOrigin < 1 ifTrue:[ |
1461 newOrigin := 1 |
1470 newOrigin := 1 |
1462 ]. |
1471 ]. |
1463 self scrollToLine: newOrigin. |
1472 self scrollToLine: newOrigin. |
1464 ]. |
1473 ]. |
1465 ]. |
1474 ]. |
1466 ]. |
1475 ]. |
1467 |
1476 |
1468 ^ super contentsChanged |
1477 ^ super contentsChanged |
1469 |
1478 |
1470 "Modified: 18.11.1996 / 19:50:07 / stefan" |
1479 "Modified: 18.11.1996 / 19:50:07 / stefan" |
1526 self paint:bgColor. |
1535 self paint:bgColor. |
1527 self fillRectangleX:x y:y width:w height:h. |
1536 self fillRectangleX:x y:y width:w height:h. |
1528 backgroundAlreadyClearedColor := bgColor. |
1537 backgroundAlreadyClearedColor := bgColor. |
1529 |
1538 |
1530 (includesNonStrings or:[w > (width // 4 * 3)]) ifTrue:[ |
1539 (includesNonStrings or:[w > (width // 4 * 3)]) ifTrue:[ |
1531 "includes non strings or area is big enough redraw whole lines" |
1540 "includes non strings or area is big enough redraw whole lines" |
1532 self redrawFromVisibleLine:startLine to:stopLine |
1541 self redrawFromVisibleLine:startLine to:stopLine |
1533 ] ifFalse:[ |
1542 ] ifFalse:[ |
1534 line := self visibleAt:startLine. |
1543 line := self visibleAt:startLine. |
1535 |
1544 |
1536 (fontIsFixedWidth and:[line isMemberOf:String]) ifFalse:[ |
1545 (fontIsFixedWidth and:[line isMemberOf:String]) ifFalse:[ |
1537 "start/end col has to be computed for each line" |
1546 "start/end col has to be computed for each line" |
1538 |
1547 |
1539 startLine to:stopLine do:[:i | |
1548 startLine to:stopLine do:[:i | |
1540 startCol := self colOfX:x inVisibleLine:i. |
1549 startCol := self colOfX:x inVisibleLine:i. |
1541 endCol := self colOfX:(x + w) inVisibleLine:i. |
1550 endCol := self colOfX:(x + w) inVisibleLine:i. |
1542 startCol > 0 ifTrue:[ |
1551 startCol > 0 ifTrue:[ |
1543 endCol > 0 ifTrue:[ |
1552 endCol > 0 ifTrue:[ |
1544 self redrawVisibleLine:i from:startCol to:endCol |
1553 self redrawVisibleLine:i from:startCol to:endCol |
1545 ] |
1554 ] |
1546 ] |
1555 ] |
1547 ] |
1556 ] |
1548 ] ifTrue:[ |
1557 ] ifTrue:[ |
1549 "start/end col is the same for all lines" |
1558 "start/end col is the same for all lines" |
1550 startCol := self colOfX:x inVisibleLine:startLine. |
1559 startCol := self colOfX:x inVisibleLine:startLine. |
1551 endCol := self colOfX:(x + w) inVisibleLine:startLine. |
1560 endCol := self colOfX:(x + w) inVisibleLine:startLine. |
1552 startCol > 0 ifTrue:[ |
1561 startCol > 0 ifTrue:[ |
1553 endCol > 0 ifTrue:[ |
1562 endCol > 0 ifTrue:[ |
1554 startLine to:stopLine do:[:i | |
1563 startLine to:stopLine do:[:i | |
1555 line := self visibleAt:i. |
1564 line := self visibleAt:i. |
1556 (line isMemberOf:String) ifTrue:[ |
1565 (line isMemberOf:String) ifTrue:[ |
1557 self redrawVisibleLine:i from:startCol to:endCol |
1566 self redrawVisibleLine:i from:startCol to:endCol |
1558 ] ifFalse:[ |
1567 ] ifFalse:[ |
1559 self redrawVisibleLine:i |
1568 self redrawVisibleLine:i |
1560 ] |
1569 ] |
1561 ] |
1570 ] |
1562 ] |
1571 ] |
1563 ] |
1572 ] |
1564 ] |
1573 ] |
1565 ]. |
1574 ]. |
1566 backgroundAlreadyClearedColor := nil. |
1575 backgroundAlreadyClearedColor := nil. |
1567 self clippingRectangle:saveClip. |
1576 self clippingRectangle:saveClip. |
1568 |
|
1569 |
|
1570 |
|
1571 |
|
1572 |
|
1573 ! |
1577 ! |
1574 |
1578 |
1575 sizeChanged:how |
1579 sizeChanged:how |
1576 "size changed - move origin up if possible" |
1580 "size changed - move origin up if possible" |
1577 |
1581 |
1702 "Modified: 28.2.1997 / 19:44:19 / cg" |
1715 "Modified: 28.2.1997 / 19:44:19 / cg" |
1703 ! |
1716 ! |
1704 |
1717 |
1705 recreate |
1718 recreate |
1706 "recreate after a snapin" |
1719 "recreate after a snapin" |
|
1720 |n| |
1707 |
1721 |
1708 super recreate. |
1722 super recreate. |
1709 |
1723 |
1710 " |
1724 " |
1711 recompute margins and font parameters |
1725 recompute margins and font parameters |
1712 - display may have different resolution/font sizes. |
1726 - display may have different resolution/font sizes. |
1713 " |
1727 " |
1714 topMargin := (self verticalPixelPerMillimeter:0.5) rounded. |
1728 "/ topMargin := (self verticalPixelPerMillimeter:0.5) rounded. |
1715 self leftMargin:(self horizontalPixelPerMillimeter:0.5) rounded. |
1729 "/ self leftMargin:(self horizontalPixelPerMillimeter:0.5) rounded. |
|
1730 |
|
1731 n := DefaultTopMargin. |
|
1732 n isInteger ifFalse:[ |
|
1733 n := (self verticalPixelPerMillimeter:n) rounded. |
|
1734 ]. |
|
1735 self topMargin:n. |
|
1736 |
|
1737 n := DefaultLeftMargin. |
|
1738 n isInteger ifFalse:[ |
|
1739 n := (self verticalPixelPerMillimeter:n) rounded. |
|
1740 ]. |
|
1741 self leftMargin:n. |
|
1742 |
1716 self getFontParameters |
1743 self getFontParameters |
|
1744 |
|
1745 "Modified: / 26.9.1998 / 17:09:32 / cg" |
1717 ! ! |
1746 ! ! |
1718 |
1747 |
1719 !ListView methodsFor:'private'! |
1748 !ListView methodsFor:'private'! |
1720 |
1749 |
1721 absoluteLineToVisibleLine:absLineNr |
1750 absoluteLineToVisibleLine:absLineNr |
1774 " |
1803 " |
1775 for fix fonts, this is easy ... |
1804 for fix fonts, this is easy ... |
1776 " |
1805 " |
1777 (fontIsFixedWidth |
1806 (fontIsFixedWidth |
1778 and:[lineString isNil |
1807 and:[lineString isNil |
1779 or:[lineString isMemberOf:String]]) ifTrue:[ |
1808 or:[lineString isMemberOf:String]]) ifTrue:[ |
1780 ^ (xRel // fontWidth) + 1 |
1809 ^ (xRel // fontWidth) + 1 |
1781 ]. |
1810 ]. |
1782 |
1811 |
1783 " |
1812 " |
1784 for variable fonts, more work is required ... |
1813 for variable fonts, more work is required ... |
1785 " |
1814 " |
1786 lineString notNil ifTrue:[ |
1815 lineString notNil ifTrue:[ |
1787 lineString := lineString asString. |
1816 lineString := lineString asString. |
1788 (hasEmphasis := lineString hasChangeOfEmphasis) ifTrue:[ |
1817 (hasEmphasis := lineString hasChangeOfEmphasis) ifTrue:[ |
1789 linePixelWidth := lineString widthOn:self |
1818 linePixelWidth := lineString widthOn:self |
1790 ] ifFalse:[ |
1819 ] ifFalse:[ |
1791 lineString := lineString string. |
1820 lineString := lineString string. |
1792 linePixelWidth := font widthOf:lineString. |
1821 linePixelWidth := font widthOf:lineString. |
1793 ] |
1822 ] |
1794 ] ifFalse:[ |
1823 ] ifFalse:[ |
1795 linePixelWidth := 0 |
1824 linePixelWidth := 0 |
1796 ]. |
1825 ]. |
1797 |
1826 |
1798 (linePixelWidth <= xRel) ifTrue:[ |
1827 (linePixelWidth <= xRel) ifTrue:[ |
1799 fontWidth == 0 ifTrue:[ |
1828 fontWidth == 0 ifTrue:[ |
1800 " |
1829 " |
1801 although this 'cannot happen', |
1830 although this 'cannot happen', |
1802 it seems that X reports this width for some strange fonts ... |
1831 it seems that X reports this width for some strange fonts ... |
1803 " |
1832 " |
1804 ^ lineString size |
1833 ^ lineString size |
1805 ]. |
1834 ]. |
1806 ^ lineString size + ((xRel - linePixelWidth) // fontWidth) + 1 |
1835 ^ lineString size + ((xRel - linePixelWidth) // fontWidth) + 1 |
1807 ]. |
1836 ]. |
1808 |
1837 |
1809 "/ cannot simply count individual characters, |
1838 "/ cannot simply count individual characters, |
1810 "/ since kerning or other non-linear effects may be involved ... |
1839 "/ since kerning or other non-linear effects may be involved ... |
1811 |
1840 |
1812 runCol := lineString size // 2. |
1841 runCol := lineString size // 2. |
1813 (runCol == 0) ifTrue:[runCol := 1]. |
1842 (runCol == 0) ifTrue:[runCol := 1]. |
1814 |
1843 |
1815 hasEmphasis ifTrue:[ |
1844 hasEmphasis ifTrue:[ |
1816 posLeft := (lineString copyFrom:1 to:(runCol - 1)) widthOn:self. |
1845 posLeft := (lineString copyFrom:1 to:(runCol - 1)) widthOn:self. |
1817 posRight := (lineString copyFrom:1 to:runCol) widthOn:self. |
1846 posRight := (lineString copyFrom:1 to:runCol) widthOn:self. |
1818 ] ifFalse:[ |
1847 ] ifFalse:[ |
1819 posLeft := font widthOf:lineString from:1 to:(runCol - 1). |
1848 posLeft := font widthOf:lineString from:1 to:(runCol - 1). |
1820 posRight := font widthOf:lineString from:1 to:runCol. |
1849 posRight := font widthOf:lineString from:1 to:runCol. |
1821 ]. |
1850 ]. |
1822 |
1851 |
1823 done := (posLeft <= xRel) and:[posRight > xRel]. |
1852 done := (posLeft <= xRel) and:[posRight > xRel]. |
1824 |
1853 |
1825 [done] whileFalse:[ |
1854 [done] whileFalse:[ |
1826 oPosRight := posRight. |
1855 oPosRight := posRight. |
1827 oPosLeft := posLeft. |
1856 oPosLeft := posLeft. |
1828 |
1857 |
1829 (posRight <= xRel) ifTrue:[ |
1858 (posRight <= xRel) ifTrue:[ |
1830 runCol := runCol + 1. |
1859 runCol := runCol + 1. |
1831 posLeft := posRight. |
1860 posLeft := posRight. |
1832 hasEmphasis ifTrue:[ |
1861 hasEmphasis ifTrue:[ |
1833 posRight := (lineString copyFrom:1 to:runCol) widthOn:self. |
1862 posRight := (lineString copyFrom:1 to:runCol) widthOn:self. |
1834 ] ifFalse:[ |
1863 ] ifFalse:[ |
1835 posRight := font widthOf:lineString from:1 to:runCol |
1864 posRight := font widthOf:lineString from:1 to:runCol |
1836 ] |
1865 ] |
1837 ] ifFalse:[ |
1866 ] ifFalse:[ |
1838 (posLeft > xRel) ifTrue:[ |
1867 (posLeft > xRel) ifTrue:[ |
1839 runCol := runCol - 1. |
1868 runCol := runCol - 1. |
1840 (runCol == 0) ifTrue:[^ 0]. |
1869 (runCol == 0) ifTrue:[^ 0]. |
1841 posRight := posLeft. |
1870 posRight := posLeft. |
1842 hasEmphasis ifTrue:[ |
1871 hasEmphasis ifTrue:[ |
1843 posLeft := (lineString copyFrom:1 to:(runCol - 1)) widthOn:self. |
1872 posLeft := (lineString copyFrom:1 to:(runCol - 1)) widthOn:self. |
1844 ] ifFalse:[ |
1873 ] ifFalse:[ |
1845 posLeft := font widthOf:lineString from:1 to:(runCol - 1) |
1874 posLeft := font widthOf:lineString from:1 to:(runCol - 1) |
1846 ] |
1875 ] |
1847 ] |
1876 ] |
1848 ]. |
1877 ]. |
1849 done := (posLeft <= xRel) and:[posRight > xRel]. |
1878 done := (posLeft <= xRel) and:[posRight > xRel]. |
1850 |
1879 |
1851 ((oPosRight == posRight) and:[oPosLeft == posLeft]) ifTrue:[ |
1880 ((oPosRight == posRight) and:[oPosLeft == posLeft]) ifTrue:[ |
1852 "/ paranoia: just in case there are unprintable characters |
1881 "/ paranoia: just in case there are unprintable characters |
1853 "/ (avoid endless loop if the binary search does not make progress) |
1882 "/ (avoid endless loop if the binary search does not make progress) |
1854 done := true. |
1883 done := true. |
1855 ] |
1884 ] |
1856 ]. |
1885 ]. |
1857 |
1886 |
1858 ^ runCol |
1887 ^ runCol |
1859 |
1888 |
1860 "Modified: / 3.9.1998 / 21:55:41 / cg" |
1889 "Modified: / 3.9.1998 / 21:55:41 / cg" |
1940 |
1969 |
1941 font := font on:device. |
1970 font := font on:device. |
1942 hMax := font height. |
1971 hMax := font height. |
1943 |
1972 |
1944 includesNonStrings == true ifTrue:[ |
1973 includesNonStrings == true ifTrue:[ |
1945 "/ |
1974 "/ |
1946 "/ find maximum height of lines |
1975 "/ find maximum height of lines |
1947 "/ |
1976 "/ |
1948 hMax := list inject:hMax into:[:maxSoFar :thisLine | |
1977 hMax := list inject:hMax into:[:maxSoFar :thisLine | |
1949 thisLine isNil ifTrue:[ |
1978 thisLine isNil ifTrue:[ |
1950 maxSoFar |
1979 maxSoFar |
1951 ] ifFalse:[ |
1980 ] ifFalse:[ |
1952 (thisLine isMemberOf:String) ifTrue:[ |
1981 (thisLine isMemberOf:String) ifTrue:[ |
1953 maxSoFar |
1982 maxSoFar |
1954 ] ifFalse:[ |
1983 ] ifFalse:[ |
1955 maxSoFar max:(thisLine heightOn:self) |
1984 maxSoFar max:(thisLine heightOn:self) |
1956 ] |
1985 ] |
1957 ] |
1986 ] |
1958 ]. |
1987 ]. |
1959 |
1988 |
1960 ]. |
1989 ]. |
1961 fontHeight := hMax + lineSpacing. |
1990 fontHeight := hMax + lineSpacing. |
1962 fontAscent := font ascent. "/ maxAscent. |
1991 fontAscent := font ascent. "/ maxAscent. |
1963 fontWidth := font width. |
1992 fontWidth := font width. |
2001 If there is no listMessage, try aspect for backward compatibility." |
2030 If there is no listMessage, try aspect for backward compatibility." |
2002 |
2031 |
2003 |text msg| |
2032 |text msg| |
2004 |
2033 |
2005 model notNil ifTrue:[ |
2034 model notNil ifTrue:[ |
2006 msg := listMsg. |
2035 msg := listMsg. |
2007 msg isNil ifTrue:[ |
2036 msg isNil ifTrue:[ |
2008 msg := aspectMsg |
2037 msg := aspectMsg |
2009 ]. |
2038 ]. |
2010 |
2039 |
2011 msg notNil ifTrue:[ |
2040 msg notNil ifTrue:[ |
2012 text := model perform:msg. |
2041 text := model perform:msg. |
2013 text notNil ifTrue:[ |
2042 text notNil ifTrue:[ |
2014 text := text asStringCollection. |
2043 text := text asStringCollection. |
2015 ]. |
2044 ]. |
2016 "/ SV: this does not work, if model uses (i.e. updates) the same stringCollection |
2045 "/ SV: this does not work, if model uses (i.e. updates) the same stringCollection |
2017 "/ as the view!! |
2046 "/ as the view!! |
2018 "/ text ~= list ifTrue:[ |
2047 "/ text ~= list ifTrue:[ |
2019 aBoolean ifTrue:[ |
2048 aBoolean ifTrue:[ |
2020 self list:text |
2049 self list:text |
2021 ] ifFalse:[ |
2050 ] ifFalse:[ |
2022 self setList:text |
2051 self setList:text |
2023 ] |
2052 ] |
2024 "/ ]. |
2053 "/ ]. |
2025 ]. |
2054 ]. |
2026 ]. |
2055 ]. |
2027 |
2056 |
2028 "Modified: 19.2.1997 / 12:08:50 / stefan" |
2057 "Modified: 19.2.1997 / 12:08:50 / stefan" |
2029 "Created: 5.3.1997 / 16:10:22 / cg" |
2058 "Created: 5.3.1997 / 16:10:22 / cg" |
2030 "Modified: 5.3.1997 / 16:14:44 / cg" |
2059 "Modified: 5.3.1997 / 16:14:44 / cg" |
2272 |
2301 |
2273 tcol := col - 1. |
2302 tcol := col - 1. |
2274 line := self visibleAt:visLineNr. |
2303 line := self visibleAt:visLineNr. |
2275 (fontIsFixedWidth |
2304 (fontIsFixedWidth |
2276 and:[line isNil |
2305 and:[line isNil |
2277 or:[line isMemberOf:String]]) ifTrue:[ |
2306 or:[line isMemberOf:String]]) ifTrue:[ |
2278 ^ (tcol * fontWidth) + textStartLeft |
2307 ^ (tcol * fontWidth) + textStartLeft |
2279 ]. |
2308 ]. |
2280 line notNil ifTrue:[ |
2309 line notNil ifTrue:[ |
2281 lineSize := line size |
2310 lineSize := line size |
2282 ] ifFalse:[ |
2311 ] ifFalse:[ |
2283 lineSize := 0 |
2312 lineSize := 0 |
2284 ]. |
2313 ]. |
2285 (lineSize == 0) ifTrue:[ |
2314 (lineSize == 0) ifTrue:[ |
2286 ^ (tcol * fontWidth) + textStartLeft |
2315 ^ (tcol * fontWidth) + textStartLeft |
2287 ]. |
2316 ]. |
2288 |
2317 |
2289 (lineSize < col) ifTrue:[ |
2318 (lineSize < col) ifTrue:[ |
2290 ^ (line widthOn:self) |
2319 ^ (line widthOn:self) |
2291 + (fontWidth * (tcol - lineSize)) |
2320 + (fontWidth * (tcol - lineSize)) |
2292 + textStartLeft |
2321 + textStartLeft |
2293 ]. |
2322 ]. |
2294 (line isMemberOf:String) ifTrue:[ |
2323 (line isMemberOf:String) ifTrue:[ |
2295 ^ (font widthOf:line from:1 to:tcol) + textStartLeft |
2324 ^ (font widthOf:line from:1 to:tcol) + textStartLeft |
2296 ]. |
2325 ]. |
2297 ^ ((line copyTo:tcol) widthOn:self) + textStartLeft |
2326 ^ ((line copyTo:tcol) widthOn:self) + textStartLeft |
2298 |
2327 |
2299 "Modified: / 3.9.1998 / 21:56:33 / cg" |
2328 "Modified: / 3.9.1998 / 21:56:33 / cg" |
2300 ! |
2329 ! |
2784 "/ ]. |
2813 "/ ]. |
2785 "/ ^ self |
2814 "/ ^ self |
2786 "/ ]. |
2815 "/ ]. |
2787 |
2816 |
2788 (self needScrollToMakeLine:aListLineNr) ifFalse:[ |
2817 (self needScrollToMakeLine:aListLineNr) ifFalse:[ |
2789 ^ self |
2818 ^ self |
2790 ]. |
2819 ]. |
2791 |
2820 |
2792 (aListLineNr < nFullLinesShown) ifTrue:[ |
2821 (aListLineNr < nFullLinesShown) ifTrue:[ |
2793 "/ at the very top of the list - show from top |
2822 "/ at the very top of the list - show from top |
2794 newTopLine := 1 |
2823 newTopLine := 1 |
2795 ] ifFalse:[ |
2824 ] ifFalse:[ |
2796 (nFullLinesShown < 3) ifTrue:[ |
2825 (nFullLinesShown < 3) ifTrue:[ |
2797 "/ a small view - show from that line |
2826 "/ a small view - show from that line |
2798 newTopLine := aListLineNr |
2827 newTopLine := aListLineNr |
2799 ] ifFalse:[ |
2828 ] ifFalse:[ |
2800 bott := self numberOfLines - (nFullLinesShown - 1). |
2829 bott := self numberOfLines - (nFullLinesShown - 1). |
2801 (aListLineNr > bott) ifTrue:[ |
2830 (aListLineNr > bott) ifTrue:[ |
2802 "/ at the end of the list - show the bottom of the list |
2831 "/ at the end of the list - show the bottom of the list |
2803 newTopLine := bott |
2832 newTopLine := bott |
2804 ] ifFalse:[ |
2833 ] ifFalse:[ |
2805 "/ somewhere else - place selected line into the middle of |
2834 "/ somewhere else - place selected line into the middle of |
2806 "/ the view |
2835 "/ the view |
2807 newTopLine := (aListLineNr - (nFullLinesShown // 2) + 1) |
2836 newTopLine := (aListLineNr - (nFullLinesShown // 2) + 1) |
2808 ] |
2837 ] |
2809 ] |
2838 ] |
2810 ]. |
2839 ]. |
2811 |
2840 |
2812 self scrollToLine:newTopLine. |
2841 self scrollToLine:newTopLine. |
2813 |
2842 |
2814 "Modified: / 18.12.1996 / 17:48:22 / stefan" |
2843 "Modified: / 18.12.1996 / 17:48:22 / stefan" |
2820 line containing someString visible." |
2849 line containing someString visible." |
2821 |
2850 |
2822 |line index list| |
2851 |line index list| |
2823 |
2852 |
2824 (list := self list) notNil ifTrue:[ |
2853 (list := self list) notNil ifTrue:[ |
2825 index := list indexOf:someString. |
2854 index := list indexOf:someString. |
2826 index ~~ 0 ifTrue:[ |
2855 index ~~ 0 ifTrue:[ |
2827 self makeLineVisible:index |
2856 self makeLineVisible:index |
2828 ] |
2857 ] |
2829 ] |
2858 ] |
2830 |
2859 |
2831 "Modified: 9.9.1997 / 10:10:13 / cg" |
2860 "Modified: 9.9.1997 / 10:10:13 / cg" |
2832 ! |
2861 ! |
2833 |
2862 |
2834 needScrollToMakeLine:aListLineNr |
2863 needScrollToMakeLine:aListLineNr |
2835 "return true, if a scroll is needd to make a line visible. |
2864 "return true, if a scroll is needd to make a line visible. |
2836 Numbering starts with 1 for the very first line of the text." |
2865 Numbering starts with 1 for the very first line of the text." |
2837 |
2866 |
2838 (aListLineNr >= firstLineShown) ifTrue:[ |
2867 (aListLineNr >= firstLineShown) ifTrue:[ |
2839 (aListLineNr < (firstLineShown + nFullLinesShown)) ifTrue:[ |
2868 (aListLineNr < (firstLineShown + nFullLinesShown)) ifTrue:[ |
2840 ^ false |
2869 ^ false |
2841 ] |
2870 ] |
2842 ]. |
2871 ]. |
2843 ^ true |
2872 ^ true |
2844 |
2873 |
2845 "Created: / 7.8.1998 / 15:13:51 / cg" |
2874 "Created: / 7.8.1998 / 15:13:51 / cg" |
2846 "Modified: / 7.8.1998 / 15:14:44 / cg" |
2875 "Modified: / 7.8.1998 / 15:14:44 / cg" |
3192 dltOrg := anOrigin - viewOrigin. |
3221 dltOrg := anOrigin - viewOrigin. |
3193 |
3222 |
3194 "/ compute valid horizontal offset x |
3223 "/ compute valid horizontal offset x |
3195 |
3224 |
3196 (x := dltOrg x) ~~ 0 ifTrue:[ |
3225 (x := dltOrg x) ~~ 0 ifTrue:[ |
3197 tmp := leftOffset + x. |
3226 tmp := leftOffset + x. |
3198 |
3227 |
3199 x < 0 ifTrue:[ "/ scrolling left |
3228 x < 0 ifTrue:[ "/ scrolling left |
3200 tmp < 0 ifTrue:[x := 1 - leftOffset] |
3229 tmp < 0 ifTrue:[x := 1 - leftOffset] |
3201 ] ifFalse:[ "/ scrolling right |
3230 ] ifFalse:[ "/ scrolling right |
3202 "/ allows scrolling to the right of widest line |
3231 "/ allows scrolling to the right of widest line |
3203 max := self widthOfContents + 10. |
3232 max := self widthOfContents + 10. |
3204 |
3233 |
3205 tmp + width > max ifTrue:[ |
3234 tmp + width > max ifTrue:[ |
3206 x := (max - leftOffset - width) max:0 |
3235 x := (max - leftOffset - width) max:0 |
3207 ] |
3236 ] |
3208 ] |
3237 ] |
3209 ]. |
3238 ]. |
3210 |
3239 |
3211 "/ compute valid vertical offset measured in lines |
3240 "/ compute valid vertical offset measured in lines |
3212 |
3241 |
3213 (y := dltOrg y // fontHeight) ~~ 0 ifTrue:[ |
3242 (y := dltOrg y // fontHeight) ~~ 0 ifTrue:[ |
3214 tmp := firstLineShown + y. |
3243 tmp := firstLineShown + y. |
3215 |
3244 |
3216 y < 0 ifTrue:[ "/ scrolling up |
3245 y < 0 ifTrue:[ "/ scrolling up |
3217 tmp < 1 ifTrue:[y := 1 - firstLineShown] |
3246 tmp < 1 ifTrue:[y := 1 - firstLineShown] |
3218 ] ifFalse:[ "/ scrolling down |
3247 ] ifFalse:[ "/ scrolling down |
3219 max := self size. |
3248 max := self size. |
3220 |
3249 |
3221 tmp + nFullLinesShown > max ifTrue:[ |
3250 tmp + nFullLinesShown > max ifTrue:[ |
3222 y := (max - firstLineShown - nFullLinesShown + 1) max:0 |
3251 y := (max - firstLineShown - nFullLinesShown + 1) max:0 |
3223 ] |
3252 ] |
3224 ] |
3253 ] |
3225 ]. |
3254 ]. |
3226 |
3255 |
3227 (x == 0 and:[y == 0]) ifTrue:[ "/ has viewOrigin changed ? |
3256 (x == 0 and:[y == 0]) ifTrue:[ "/ has viewOrigin changed ? |
3228 ^ self |
3257 ^ self |
3229 ]. |
3258 ]. |
3230 |
3259 |
3231 |
3260 |
3232 (noLn := y) ~~ 0 ifTrue:[ |
3261 (noLn := y) ~~ 0 ifTrue:[ |
3233 y := y * fontHeight |
3262 y := y * fontHeight |
3234 ]. |
3263 ]. |
3235 delta := (x @ y). |
3264 delta := (x @ y). |
3236 |
3265 |
3237 newFirstLine := firstLineShown + noLn. |
3266 newFirstLine := firstLineShown + noLn. |
3238 newViewOrigin := viewOrigin + delta. |
3267 newViewOrigin := viewOrigin + delta. |
3239 newLeftOffset := newViewOrigin x. |
3268 newLeftOffset := newViewOrigin x. |
3240 |
3269 |
3241 (shown and:[doRedraw]) ifFalse:[ |
3270 (shown and:[doRedraw]) ifFalse:[ |
3242 self originWillChange. |
3271 self originWillChange. |
3243 firstLineShown := newFirstLine. |
3272 firstLineShown := newFirstLine. |
3244 viewOrigin := newViewOrigin. |
3273 viewOrigin := newViewOrigin. |
3245 leftOffset := newLeftOffset. |
3274 leftOffset := newLeftOffset. |
3246 ^ self originChanged:delta |
3275 ^ self originChanged:delta |
3247 ]. |
3276 ]. |
3248 |
3277 |
3249 "/ (self sensor notNil and: [self sensor hasExposeEventFor:self]) ifTrue:[ "/ outstanding expose events |
3278 "/ (self sensor notNil and: [self sensor hasExposeEventFor:self]) ifTrue:[ "/ outstanding expose events |
3250 "/ self invalidate. "/ redraw all |
3279 "/ self invalidate. "/ redraw all |
3251 "/ self originWillChange. |
3280 "/ self originWillChange. |
3273 |
3302 |
3274 self catchExpose. |
3303 self catchExpose. |
3275 |
3304 |
3276 x == 0 ifTrue:[ "/ scrolling vertical |
3305 x == 0 ifTrue:[ "/ scrolling vertical |
3277 |
3306 |
3278 y0 := textStartTop + (y abs). |
3307 y0 := textStartTop + (y abs). |
3279 h := height - margin - y0. |
3308 h := height - margin - y0. |
3280 w := width - margin. |
3309 w := width - margin. |
3281 |
3310 |
3282 y > 0 ifTrue:[ "/ copy down |
3311 y > 0 ifTrue:[ "/ copy down |
3283 self copyFrom:self |
3312 self copyFrom:self |
3284 x:0 y:y0 toX:0 y:textStartTop |
3313 x:0 y:y0 toX:0 y:textStartTop |
3285 width:w height:h async:true. |
3314 width:w height:h async:true. |
3286 y1 := h. |
3315 y1 := h. |
3287 ] ifFalse:[ "/ copy up |
3316 ] ifFalse:[ "/ copy up |
3288 self copyFrom:self |
3317 self copyFrom:self |
3289 x:margin y:textStartTop toX:margin y:y0 |
3318 x:margin y:textStartTop toX:margin y:y0 |
3290 width:w height:h async:true. |
3319 width:w height:h async:true. |
3291 y1 := 0. |
3320 y1 := 0. |
3292 ]. |
3321 ]. |
3293 |
3322 |
3294 self redrawX:margin y:y1 width:w height:y0. |
3323 self redrawX:margin y:y1 width:w height:y0. |
3295 |
3324 |
3296 ] ifFalse:[ "/ scrolling horizontal |
3325 ] ifFalse:[ "/ scrolling horizontal |
3297 |
3326 |
3298 x > 0 ifTrue:[ "/ scrolling right |
3327 x > 0 ifTrue:[ "/ scrolling right |
3299 y0 := margin + x. |
3328 y0 := margin + x. |
3300 y1 := width - y0. |
3329 y1 := width - y0. |
3301 ] ifFalse:[ "/ scrolling left |
3330 ] ifFalse:[ "/ scrolling left |
3302 y0 := margin - x. |
3331 y0 := margin - x. |
3303 y1 := 0. |
3332 y1 := 0. |
3304 ]. |
3333 ]. |
3305 h := height - margin - margin. |
3334 h := height - margin - margin. |
3306 w := width - margin - y0. |
3335 w := width - margin - y0. |
3307 |
3336 |
3308 x > 0 ifTrue:[ "/ copy right |
3337 x > 0 ifTrue:[ "/ copy right |
3309 self copyFrom:self x:y0 y:margin toX:margin y:margin |
3338 self copyFrom:self x:y0 y:margin toX:margin y:margin |
3310 width:w height:h async:true. |
3339 width:w height:h async:true. |
3311 ] ifFalse:[ "/ copy left |
3340 ] ifFalse:[ "/ copy left |
3312 "/self copyFrom:self x:textStartLeft y:margin toX:y0 y:margin |
3341 "/self copyFrom:self x:textStartLeft y:margin toX:y0 y:margin |
3313 self copyFrom:self x:margin y:margin toX:y0 y:margin |
3342 self copyFrom:self x:margin y:margin toX:y0 y:margin |
3314 width:w height:h async:true. |
3343 width:w height:h async:true. |
3315 ]. |
3344 ]. |
3316 |
3345 |
3317 self redrawX:y1 y:margin width:y0 height:h. |
3346 self redrawX:y1 y:margin width:y0 height:h. |
3318 ]. |
3347 ]. |
3319 |
3348 |
3320 self waitForExpose. |
3349 self waitForExpose. |
3321 self originChanged:delta. |
3350 self originChanged:delta. |
3322 |
3351 |
3420 line1 "{ Class: SmallInteger }" |
3449 line1 "{ Class: SmallInteger }" |
3421 lineSize "{ Class: SmallInteger }" | |
3450 lineSize "{ Class: SmallInteger }" | |
3422 |
3451 |
3423 patternSize := pattern size. |
3452 patternSize := pattern size. |
3424 (list notNil and:[patternSize ~~ 0]) ifTrue:[ |
3453 (list notNil and:[patternSize ~~ 0]) ifTrue:[ |
3425 self withCursor:Cursor questionMark do:[ |
3454 self withCursor:Cursor questionMark do:[ |
3426 col := startCol - 1. |
3455 col := startCol - 1. |
3427 firstChar1 := pattern at:1. |
3456 firstChar1 := pattern at:1. |
3428 ignCase ifTrue:[ |
3457 ignCase ifTrue:[ |
3429 firstChar1 := firstChar1 asLowercase. |
3458 firstChar1 := firstChar1 asLowercase. |
3430 firstChar2 := firstChar1 asUppercase. |
3459 firstChar2 := firstChar1 asUppercase. |
3431 ] ifFalse:[ |
3460 ] ifFalse:[ |
3432 firstChar2 := firstChar1 |
3461 firstChar2 := firstChar1 |
3433 ]. |
3462 ]. |
3434 col > (list at:startLine) size ifTrue:[ |
3463 col > (list at:startLine) size ifTrue:[ |
3435 col := -999 |
3464 col := -999 |
3436 ]. |
3465 ]. |
3437 line1 := startLine. |
3466 line1 := startLine. |
3438 line1 to:1 by:-1 do:[:lnr | |
3467 line1 to:1 by:-1 do:[:lnr | |
3439 lineString := list at:lnr. |
3468 lineString := list at:lnr. |
3440 lineString notNil ifTrue:[ |
3469 lineString notNil ifTrue:[ |
3441 lineSize := lineString size. |
3470 lineSize := lineString size. |
3442 col == -999 ifTrue:[col := lineSize - patternSize + 1]. |
3471 col == -999 ifTrue:[col := lineSize - patternSize + 1]. |
3443 [(col > 0) |
3472 [(col > 0) |
3444 and:[(c := lineString at:col) ~= firstChar1 |
3473 and:[(c := lineString at:col) ~= firstChar1 |
3445 and:[c ~= firstChar2]]] whileTrue:[ |
3474 and:[c ~= firstChar2]]] whileTrue:[ |
3446 col := col - 1 |
3475 col := col - 1 |
3447 ]. |
3476 ]. |
3448 [col > 0] whileTrue:[ |
3477 [col > 0] whileTrue:[ |
3449 cc := col. |
3478 cc := col. |
3450 found := true. |
3479 found := true. |
3451 1 to:patternSize do:[:cnr | |
3480 1 to:patternSize do:[:cnr | |
3452 cc > lineSize ifTrue:[ |
3481 cc > lineSize ifTrue:[ |
3453 found := false |
3482 found := false |
3454 ] ifFalse:[ |
3483 ] ifFalse:[ |
3455 pc := pattern at:cnr. |
3484 pc := pattern at:cnr. |
3456 c := lineString at:cc. |
3485 c := lineString at:cc. |
3457 pc ~= c ifTrue:[ |
3486 pc ~= c ifTrue:[ |
3458 (ignCase not or:[pc asLowercase ~= c asLowercase]) ifTrue:[ |
3487 (ignCase not or:[pc asLowercase ~= c asLowercase]) ifTrue:[ |
3459 found := false |
3488 found := false |
3460 ] |
3489 ] |
3461 ] |
3490 ] |
3462 ]. |
3491 ]. |
3463 cc := cc + 1 |
3492 cc := cc + 1 |
3464 ]. |
3493 ]. |
3465 found ifTrue:[ |
3494 found ifTrue:[ |
3466 ^ block1 value:lnr value:col. |
3495 ^ block1 value:lnr value:col. |
3467 ]. |
3496 ]. |
3468 col := col - 1. |
3497 col := col - 1. |
3469 [(col > 0) |
3498 [(col > 0) |
3470 and:[(c := lineString at:col) ~= firstChar1 |
3499 and:[(c := lineString at:col) ~= firstChar1 |
3471 and:[c ~= firstChar2]]] whileTrue:[ |
3500 and:[c ~= firstChar2]]] whileTrue:[ |
3472 col := col - 1 |
3501 col := col - 1 |
3473 ] |
3502 ] |
3474 ] |
3503 ] |
3475 ]. |
3504 ]. |
3476 col := -999. |
3505 col := -999. |
3477 ] |
3506 ] |
3478 ] |
3507 ] |
3479 ]. |
3508 ]. |
3480 "not found" |
3509 "not found" |
3481 |
3510 |
3482 ^ block2 value |
3511 ^ block2 value |
3483 |
3512 |
3509 line2 "{Class: SmallInteger}" |
3538 line2 "{Class: SmallInteger}" |
3510 p realPattern| |
3539 p realPattern| |
3511 |
3540 |
3512 patternSize := pattern size. |
3541 patternSize := pattern size. |
3513 (list notNil and:[patternSize ~~ 0]) ifTrue:[ |
3542 (list notNil and:[patternSize ~~ 0]) ifTrue:[ |
3514 self withCursor:Cursor questionMark do:[ |
3543 self withCursor:Cursor questionMark do:[ |
3515 |
3544 |
3516 col := startCol + 1. |
3545 col := startCol + 1. |
3517 line1 := startLine. |
3546 line1 := startLine. |
3518 line2 := list size. |
3547 line2 := list size. |
3519 |
3548 |
3520 pattern includesUnescapedMatchCharacters ifTrue:[ |
3549 pattern includesUnescapedMatchCharacters ifTrue:[ |
3521 p := pattern species new:0. |
3550 p := pattern species new:0. |
3522 (pattern startsWith:$*) ifFalse:[ |
3551 (pattern startsWith:$*) ifFalse:[ |
3523 p := p , '*' |
3552 p := p , '*' |
3524 ]. |
3553 ]. |
3525 p := p , pattern. |
3554 p := p , pattern. |
3526 (pattern endsWith:$*) ifFalse:[ |
3555 (pattern endsWith:$*) ifFalse:[ |
3527 p := p , '*' |
3556 p := p , '*' |
3528 ]. |
3557 ]. |
3529 realPattern := pattern. |
3558 realPattern := pattern. |
3530 (realPattern startsWith:$*) ifTrue:[ |
3559 (realPattern startsWith:$*) ifTrue:[ |
3531 realPattern := realPattern copyFrom:2 |
3560 realPattern := realPattern copyFrom:2 |
3532 ]. |
3561 ]. |
3533 line1 to:line2 do:[:lnr | |
3562 line1 to:line2 do:[:lnr | |
3534 lineString := list at:lnr. |
3563 lineString := list at:lnr. |
3535 lineString notNil ifTrue:[ |
3564 lineString notNil ifTrue:[ |
3536 "/ first a crude check ... |
3565 "/ first a crude check ... |
3537 (p match:lineString ignoreCase:ignCase) ifTrue:[ |
3566 (p match:lineString ignoreCase:ignCase) ifTrue:[ |
3538 "/ ok, there it is; look at which position |
3567 "/ ok, there it is; look at which position |
3539 col := lineString |
3568 col := lineString |
3540 findMatchString:realPattern |
3569 findMatchString:realPattern |
3541 startingAt:col |
3570 startingAt:col |
3542 ignoreCase:ignCase |
3571 ignoreCase:ignCase |
3543 ifAbsent:0. |
3572 ifAbsent:0. |
3544 col ~~ 0 ifTrue:[ |
3573 col ~~ 0 ifTrue:[ |
3545 ^ block1 value:lnr value:col. |
3574 ^ block1 value:lnr value:col. |
3546 ] |
3575 ] |
3547 ]. |
3576 ]. |
3548 ]. |
3577 ]. |
3549 col := 1 |
3578 col := 1 |
3550 ] |
3579 ] |
3551 ] ifFalse:[ |
3580 ] ifFalse:[ |
3552 p := pattern withoutMatchEscapes. |
3581 p := pattern withoutMatchEscapes. |
3553 line1 to:line2 do:[:lnr | |
3582 line1 to:line2 do:[:lnr | |
3554 lineString := list at:lnr. |
3583 lineString := list at:lnr. |
3555 lineString isString ifTrue:[ |
3584 lineString isString ifTrue:[ |
3556 ignCase ifTrue:[ |
3585 ignCase ifTrue:[ |
3557 col := lineString |
3586 col := lineString |
3558 findMatchString:p |
3587 findMatchString:p |
3559 startingAt:col |
3588 startingAt:col |
3560 ignoreCase:ignCase |
3589 ignoreCase:ignCase |
3561 ifAbsent:0. |
3590 ifAbsent:0. |
3562 ] ifFalse:[ |
3591 ] ifFalse:[ |
3563 col := lineString |
3592 col := lineString |
3564 findString:p |
3593 findString:p |
3565 startingAt:col |
3594 startingAt:col |
3566 ifAbsent:0. |
3595 ifAbsent:0. |
3567 ]. |
3596 ]. |
3568 col ~~ 0 ifTrue:[ |
3597 col ~~ 0 ifTrue:[ |
3569 ^ block1 value:lnr value:col. |
3598 ^ block1 value:lnr value:col. |
3570 ] |
3599 ] |
3571 ]. |
3600 ]. |
3572 col := 1 |
3601 col := 1 |
3573 ] |
3602 ] |
3574 ]. |
3603 ]. |
3575 ] |
3604 ] |
3576 ]. |
3605 ]. |
3577 "not found" |
3606 "not found" |
3578 |
3607 |
3579 ^ block2 value |
3608 ^ block2 value |
3580 |
3609 |