457 ^ height - (2 * margin) - topMargin |
460 ^ height - (2 * margin) - topMargin |
458 ! ! |
461 ! ! |
459 |
462 |
460 !ListView methodsFor:'accessing-behavior'! |
463 !ListView methodsFor:'accessing-behavior'! |
461 |
464 |
|
465 checkLineEndConventionWhenUpdating |
|
466 "return the line-end convention check when updating behavior. |
|
467 If true (the default), the first line of the list given is checked for having a |
|
468 cr-lf line end (which is a DOS convention), and the lineEndCRLF flag is set dynamically. |
|
469 If false, the lineEndCRLF remains as specified by the user. |
|
470 You may want to disable this flag if it is very expensive to generate a line |
|
471 (although, only the very first line is checked, anyway)" |
|
472 |
|
473 ^ checkLineEndConventionWhenUpdating |
|
474 ! |
|
475 |
|
476 checkLineEndConventionWhenUpdating:aBoolean |
|
477 "define the line-end convention check when updating behavior. |
|
478 If true (the default), the first line of the list given is checked for having a |
|
479 cr-lf line end (which is a DOS convention), and the lineEndCRLF flag is set dynamically. |
|
480 If false, the lineEndCRLF remains as specified by the user. |
|
481 You may want to disable this flag if it is very expensive to generate a line |
|
482 (although, only the very first line is checked, anyway)" |
|
483 |
|
484 checkLineEndConventionWhenUpdating := aBoolean |
|
485 ! |
|
486 |
|
487 compareModelWhenUpdating |
|
488 "return the compare when updating behavior. |
|
489 If true (the default), the list of lines as given due to a model update |
|
490 is processed and compared against the currently shown text. |
|
491 If they are the same, no action is taken. |
|
492 This behavior is ok in 99.99% of all applications. |
|
493 However, you may turn this off iff: |
|
494 - it is very expensive to process the list (for example, because the list |
|
495 is defined by a virtual array, which computes the lines dynamically, on |
|
496 the fly). |
|
497 One use where this flag should be turned off is in the hex-memory display, |
|
498 which is able to simulate texts with millions of lines, but they are actually |
|
499 simulated by generating the presented lines dynamically, as they are displayed." |
|
500 |
|
501 ^ compareModelOnUpdate |
|
502 ! |
|
503 |
|
504 compareModelWhenUpdating:aBoolean |
|
505 "define the compare when updating behavior. |
|
506 If true (the default), the list of lines as given due to a model update |
|
507 is processed and compared against the currently shown text. |
|
508 If they are the same, no action is taken. |
|
509 This behavior is ok in 99.99% of all applications. |
|
510 However, you may turn this off iff: |
|
511 - it is very expensive to process the list (for example, because the list |
|
512 is defined by a virtual array, which computes the lines dynamically, on |
|
513 the fly). |
|
514 One use where this flag should be turned off is in the hex-memory display, |
|
515 which is able to simulate texts with millions of lines, but they are actually |
|
516 simulated by generating the presented lines dynamically, as they are displayed." |
|
517 |
|
518 compareModelOnUpdate := aBoolean |
|
519 ! |
|
520 |
|
521 expandTabsWhenUpdating |
|
522 "return the tab expansion behavior. |
|
523 If true (the default), the list of lines as given via #list: or |
|
524 due to a model update is processed and lines are replaced by lines with |
|
525 tabs expanded. |
|
526 This behavior is ok in 99.99% of all applications. |
|
527 However, you may turn this off iff: |
|
528 - you are certain, that no tabs are in the passed in list |
|
529 - it is very expensive to process the list (for example, because the list |
|
530 is defined by a virtual array, which computes the lines dynamically, on |
|
531 the fly). |
|
532 One use where this flag should be turned off is in the hex-memory display, |
|
533 which is able to simulate texts with millions of lines, but they are actually |
|
534 simulated by generating the presented lines dynamically, as they are displayed." |
|
535 |
|
536 ^ expandTabsWhenUpdating |
|
537 ! |
|
538 |
|
539 expandTabsWhenUpdating:aBoolean |
|
540 "define the tab expansion behavior. |
|
541 If true (the default), the list of lines as given via #list: or |
|
542 due to a model update is processed and lines are replaced by lines with |
|
543 tabs expanded. |
|
544 This behavior is ok in 99.99% of all applications. |
|
545 However, you may turn this off iff: |
|
546 - you are certain, that no tabs are in the passed in list |
|
547 - it is very expensive to process the list (for example, because the list |
|
548 is defined by a virtual array, which computes the lines dynamically, on |
|
549 the fly). |
|
550 One use where this flag should be turned off is in the hex-memory display, |
|
551 which is able to simulate texts with millions of lines, but they are actually |
|
552 simulated by generating the presented lines dynamically, as they are displayed." |
|
553 |
|
554 expandTabsWhenUpdating := aBoolean |
|
555 ! |
|
556 |
462 lineEndCRLF |
557 lineEndCRLF |
463 "answer true, if CRLF is used for the line end. |
558 "answer true, if CRLF is used for the line end. |
464 This is true for DOS/Windows files. |
559 This is true for DOS/Windows files. |
465 Otherwise 'Character cr' is the line end (which is LF in unix)" |
560 Otherwise 'Character cr' is the line end (which is LF in unix)" |
466 |
561 |
467 ^ lineEndCRLF ? false |
562 ^ lineEndCRLF ? false |
468 |
563 |
469 "Created: / 04-07-2006 / 19:05:01 / fm" |
564 "Created: / 04-07-2006 / 19:05:01 / fm" |
|
565 ! |
|
566 |
|
567 numberOfLinesForWidthOfContentsComputation |
|
568 "return the number of lines to consider in the widthOfContents computation, |
|
569 which is needed by the scrollBar interface. |
|
570 If nil (the default), all lines are processed and the width of the longest line is taken. |
|
571 You may want to change this to 1 if it is guaranteed that all linesa are of the same width |
|
572 (for example, when it is very expensive to generate all lines" |
|
573 |
|
574 ^ numberOfLinesForWidthOfContentsComputation |
|
575 ! |
|
576 |
|
577 numberOfLinesForWidthOfContentsComputation:anIntegerOrNil |
|
578 "set the number of lines to consider in the widthOfContents computation, |
|
579 which is needed by the scrollBar interface. |
|
580 If nil (the default), all lines are processed and the width of the longest line is taken. |
|
581 You may want to change this to 1 if it is guaranteed that all linesa are of the same width |
|
582 (for example, when it is very expensive to generate all lines" |
|
583 |
|
584 numberOfLinesForWidthOfContentsComputation := anIntegerOrNil |
470 ! |
585 ! |
471 |
586 |
472 scrollWhenUpdating |
587 scrollWhenUpdating |
473 "return the scroll behavior, when I get a new text |
588 "return the scroll behavior, when I get a new text |
474 (via the model or the #contents/#list) |
589 (via the model or the #contents/#list) |
826 If scan is true, scan the passed list for nonStrings; otherwise, |
941 If scan is true, scan the passed list for nonStrings; otherwise, |
827 assume that it does contain non-strings |
942 assume that it does contain non-strings |
828 (remembered to optimize later redraws)." |
943 (remembered to optimize later redraws)." |
829 |
944 |
830 self |
945 self |
831 list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:true |
946 list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nil |
832 |
947 |
833 "Modified: 5.6.1997 / 12:40:35 / cg" |
948 "Modified: 5.6.1997 / 12:40:35 / cg" |
834 ! |
949 ! |
835 |
950 |
836 list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStrings |
951 list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStringsIfNoScan |
837 "set the contents (a collection of strings) |
952 "set the contents (a collection of strings) |
838 and scroll as specified in scrollWhenUpdating (default:top-left). |
953 and scroll as specified in scrollWhenUpdating (default:top-left). |
839 If expand is true, tabs are expanded (to spaces). |
954 If expand is true, tabs are expanded (to spaces). |
840 If scan is true, scan the passed list for nonStrings; |
955 If scan is true, scan the passed list for nonStrings; |
841 otherwise, take the information from the nonStrings arg. |
956 otherwise, take the information from the nonStrings arg. |
842 (the nonStrings information is remembered to optimize later redraws & height computations)." |
957 (the nonStrings information is remembered to optimize later redraws & height computations)." |
843 |
958 |
|
959 self |
|
960 list:aCollection |
|
961 expandTabs:expand |
|
962 scanForNonStrings:scan |
|
963 includesNonStrings:nonStringsIfNoScan |
|
964 redraw:true |
|
965 ! |
|
966 |
|
967 list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStringsIfNoScan redraw:doRedraw |
|
968 "set the contents (a collection of strings) |
|
969 and scroll as specified in scrollWhenUpdating (default:top-left). |
|
970 If expand is true, tabs are expanded (to spaces). |
|
971 If scan is true, scan the passed list for nonStrings; |
|
972 otherwise, take the information from the nonStrings arg. |
|
973 (the nonStrings information is remembered to optimize later redraws & height computations)." |
|
974 |
844 |oldFirst oldLeft nonStringsBefore fontHeightBefore |
975 |oldFirst oldLeft nonStringsBefore fontHeightBefore |
845 scrollToEnd scrollToTop newLeftOffset wText same firstLine| |
976 scrollToEnd scrollToTop newLeftOffset wText same firstLine| |
846 |
977 |
847 "/ see if there is a change at all. |
978 "/ cg: what is the point in comparing here? |
848 "/ use to compare using =, but thats not enough in case of emphasis change. |
979 "/ I think, if there is something to optimize, |
849 aCollection size == list size ifTrue:[ |
980 "/ the caller should do so (moved to getListFromModel). |
850 same := true. |
981 "/ notice, that it may be very expensive to ask aCollection for each line |
851 aCollection size > 0 ifTrue:[ |
982 "/ for example, iff the lines are generated on the fly by an algorithm |
852 aCollection with:list do:[:eachNewLine :eachOldLine | |
983 false ifTrue:[ |
853 (eachNewLine == eachOldLine) |
984 "/ see if there is a change at all. |
854 "/ ((eachNewLine species == eachOldLine species) |
985 "/ use to compare using =, but that's not enough in case of emphasis change. |
855 "/ and:[eachNewLine = eachOldLine]) |
986 aCollection size == list size ifTrue:[ |
856 ifFalse:[ |
987 same := true. |
857 same := false. |
988 aCollection size > 0 ifTrue:[ |
|
989 aCollection with:list do:[:eachNewLine :eachOldLine | |
|
990 (eachNewLine == eachOldLine) |
|
991 ifFalse:[ |
|
992 same := false. |
|
993 ] |
858 ] |
994 ] |
859 ] |
995 ]. |
|
996 same ifTrue:[^ self]. |
860 ]. |
997 ]. |
861 same ifTrue:[^ self]. |
|
862 ]. |
998 ]. |
863 |
999 |
864 scrollToTop := scrollWhenUpdating == #begin or:[scrollWhenUpdating == #beginOfText]. |
1000 scrollToTop := scrollWhenUpdating == #begin or:[scrollWhenUpdating == #beginOfText]. |
865 scrollToEnd := scrollWhenUpdating == #end or:[scrollWhenUpdating == #endOfText]. |
1001 scrollToEnd := scrollWhenUpdating == #end or:[scrollWhenUpdating == #endOfText]. |
866 |
1002 |
867 (aCollection isNil and:[list isNil]) ifTrue:[ |
1003 (aCollection isEmptyOrNil and:[list isEmptyOrNil]) ifTrue:[ |
868 "no contents change" |
1004 "no contents change" |
869 scrollToTop ifTrue:[ |
1005 list := aCollection. |
870 self scrollToTop. |
1006 scrollLocked ifFalse:[ |
871 ] ifFalse:[ |
1007 scrollToTop ifTrue:[ |
872 scrollToEnd ifTrue:[ |
1008 self scrollToTop. |
873 self scrollToBottom. |
1009 ] ifFalse:[ |
874 ] |
1010 scrollToEnd ifTrue:[ |
|
1011 self scrollToBottom. |
|
1012 ] |
|
1013 ]. |
|
1014 self scrollToLeft. |
875 ]. |
1015 ]. |
876 self scrollToLeft. |
|
877 ^ self |
1016 ^ self |
878 ]. |
1017 ]. |
879 |
1018 |
880 "Check if the we use DOS/Windows line end conventin with CR LF. |
1019 checkLineEndConventionWhenUpdating ifTrue:[ |
881 The LF has already been consumed by the conversion to a StringCollection, |
1020 "Check if the we use DOS/Windows line end convention with CR LF. |
882 now check for and remove the trailing left over CRs" |
1021 The LF has already been consumed by the conversion to a StringCollection, |
883 |
1022 now check for and remove the trailing left over CRs" |
884 lineEndCRLF := (aCollection size > 0 |
1023 |
885 and:[(firstLine := aCollection at:1) isString |
1024 lineEndCRLF := (aCollection size > 0 |
886 and:[firstLine notEmpty |
1025 and:[(firstLine := aCollection at:1) isString |
887 and:[firstLine string endsWith:Character return]]]). |
1026 and:[firstLine notEmpty |
|
1027 and:[firstLine string endsWith:Character return]]]). |
|
1028 ]. |
888 lineEndCRLF ifTrue:[ |
1029 lineEndCRLF ifTrue:[ |
889 list := aCollection |
1030 list := aCollection |
890 collect:[:eachLineWithCROrNil | |
1031 collect:[:eachLineWithCROrNil | |
891 eachLineWithCROrNil isNil |
1032 eachLineWithCROrNil isNil |
892 ifTrue:nil |
1033 ifTrue:nil |
922 |
1063 |
923 (includesNonStrings ~~ nonStringsBefore) ifTrue:[ |
1064 (includesNonStrings ~~ nonStringsBefore) ifTrue:[ |
924 self computeNumberOfLinesShown. |
1065 self computeNumberOfLinesShown. |
925 ]. |
1066 ]. |
926 |
1067 |
927 newLeftOffset := viewOrigin x. |
1068 scrollLocked ifFalse:[ |
928 scrollToTop ifTrue:[ |
1069 newLeftOffset := viewOrigin x. |
929 firstLineShown := 1. |
1070 scrollToTop ifTrue:[ |
930 newLeftOffset := 0. |
1071 firstLineShown := 1. |
931 ] ifFalse:[ |
|
932 scrollToEnd ifTrue:[ |
|
933 firstLineShown := (list size - nFullLinesShown + 1) max:1. |
|
934 newLeftOffset := 0. |
1072 newLeftOffset := 0. |
935 ] |
1073 ] ifFalse:[ |
936 ]. |
1074 scrollToEnd ifTrue:[ |
937 newLeftOffset > 0 ifTrue:[ |
1075 firstLineShown := (list size - nFullLinesShown + 1) max:1. |
938 wText := self widthOfContents. |
1076 newLeftOffset := 0. |
939 (viewOrigin x + self innerWidth) > wText ifTrue:[ |
1077 ] |
940 newLeftOffset := (wText - self innerWidth) max:0. |
|
941 ]. |
1078 ]. |
942 ]. |
1079 newLeftOffset > 0 ifTrue:[ |
943 newLeftOffset ~= oldLeft ifTrue:[ |
1080 wText := self widthOfContents. |
944 viewOrigin := newLeftOffset @ viewOrigin y. |
1081 (viewOrigin x + self innerWidth) > wText ifTrue:[ |
|
1082 newLeftOffset := (wText - self innerWidth) max:0. |
|
1083 ]. |
|
1084 ]. |
|
1085 newLeftOffset ~= oldLeft ifTrue:[ |
|
1086 viewOrigin := newLeftOffset @ viewOrigin y. |
|
1087 ]. |
945 ]. |
1088 ]. |
946 |
1089 |
947 realized ifTrue:[ |
1090 realized ifTrue:[ |
948 self contentsChanged. |
1091 self contentsChanged. |
949 " |
1092 scrollLocked ifFalse:[ |
950 don't use scroll here to avoid double redraw |
1093 " |
951 " |
1094 don't use scroll here to avoid double redraw |
952 viewOrigin := viewOrigin isNil ifTrue:[0@0] ifFalse:[(viewOrigin x) @ 0]. |
1095 " |
953 transformation := nil. |
1096 viewOrigin := viewOrigin isNil ifTrue:[0@0] ifFalse:[(viewOrigin x) @ 0]. |
954 |
1097 transformation := nil. |
955 oldFirst ~~ firstLineShown ifTrue:[ |
1098 |
956 self originChanged:0 @ ((oldFirst - 1) * fontHeight negated). |
1099 oldFirst ~~ firstLineShown ifTrue:[ |
|
1100 self originChanged:0 @ ((oldFirst - 1) * fontHeight negated). |
|
1101 ]. |
957 ]. |
1102 ]. |
958 shown ifTrue:[ |
1103 doRedraw ifTrue:[ |
959 self invalidate. |
1104 shown ifTrue:[ |
960 "/ self redrawFromVisibleLine:1 to:nLinesShown. |
1105 self invalidate. |
961 |
1106 ] |
962 "/ fontHeightBefore > fontHeight ifTrue:[ |
|
963 "/ (self listLineIsVisible:(self size)) ifTrue:[ |
|
964 "/"/ self clearRectangle:((margin @ (self yOfVisibleLine:nLinesShown+1)) |
|
965 "/"/ corner:(width-margin) @ (height-margin)). |
|
966 "/ ]. |
|
967 "/ ] |
|
968 ] |
1107 ] |
969 ] |
1108 ] |
970 |
1109 |
971 "Modified: / 30-08-1995 / 19:07:13 / claus" |
1110 "Modified: / 30-08-1995 / 19:07:13 / claus" |
972 "Created: / 05-06-1997 / 12:40:06 / cg" |
1111 "Created: / 05-06-1997 / 12:40:06 / cg" |
1150 "set the contents (a collection of strings); |
1289 "set the contents (a collection of strings); |
1151 do not change position (i.e. do not scroll). |
1290 do not change position (i.e. do not scroll). |
1152 This can be used to update a self-changing list |
1291 This can be used to update a self-changing list |
1153 (for example: a file list being shown, without disturbing the user too much)" |
1292 (for example: a file list being shown, without disturbing the user too much)" |
1154 |
1293 |
1155 |oldFirst nonStringsBefore| |
1294 self |
1156 |
1295 setList:aCollection expandTabs:expandTabs scanForNonStrings:true includesNonStrings:nil |
1157 (aCollection isNil and:[list isNil]) ifTrue:[ |
1296 redraw:doRedraw |
1158 "no change" |
1297 ! |
1159 ^ self |
1298 |
1160 ]. |
1299 setList:aCollection expandTabs:expandTabs scanForNonStrings:scan includesNonStrings:nonStringsIfNoScan redraw:doRedraw |
1161 |
1300 "set the contents (a collection of strings); |
1162 list := aCollection. |
1301 do not change position (i.e. do not scroll). |
1163 |
1302 This can be used to update a self-changing list |
1164 nonStringsBefore := includesNonStrings. |
1303 (for example: a file list being shown, without disturbing the user too much). |
1165 includesNonStrings := false. |
1304 TODO: this stinks: most of the code is the same as in #list:expandTabs:... |
1166 |
1305 needs a refactoring" |
1167 list notNil ifTrue:[ |
1306 |
1168 expandTabs ifTrue:[ |
1307 |prev| |
1169 self expandTabs |
1308 |
1170 ] ifFalse:[ |
1309 prev := scrollLocked. |
1171 includesNonStrings := (list findFirst:[:e | e isString not]) ~~ 0. |
1310 [ |
1172 ]. |
1311 scrollLocked := false. |
1173 ]. |
1312 self |
1174 (includesNonStrings ~~ nonStringsBefore) ifTrue:[ |
1313 list:aCollection |
1175 self getFontParameters. |
1314 expandTabs:expandTabs |
1176 self computeNumberOfLinesShown. |
1315 scanForNonStrings:scan |
1177 ]. |
1316 includesNonStrings:nonStringsIfNoScan |
1178 |
1317 redraw:doRedraw |
1179 "/ new: reposition horizontally if too big |
1318 ] ensure:[ |
1180 widthOfWidestLine := nil. "/ i.e. unknown |
1319 scrollLocked := prev |
1181 innerWidth >= self widthOfContents ifTrue:[ |
1320 ]. |
1182 viewOrigin := 0 @ viewOrigin y. |
1321 "/ |
1183 ]. |
1322 "/ |
1184 self contentsChanged. |
1323 "/"/ scrollLocked ifTrue:[ |
1185 |
1324 "/"/ self setList:newText expandTabs:expandTabsWhenUpdating |
1186 "/ new: reposition vertically if too big |
1325 "/"/ ] ifFalse:[ |
1187 (firstLineShown + nFullLinesShown) > self size ifTrue:[ |
1326 "/ self list:newText expandTabs:expandTabsWhenUpdating scanForNonStrings:expandTabsWhenUpdating |
1188 oldFirst := firstLineShown. |
1327 "/"/ ] |
1189 firstLineShown := self size - nFullLinesShown + 1. |
1328 "/ |
1190 firstLineShown < 1 ifTrue:[firstLineShown := 1]. |
1329 "/ |oldFirst nonStringsBefore| |
1191 oldFirst ~= firstLineShown ifTrue:[ |
1330 "/ |
1192 viewOrigin y:(firstLineShown - 1 * fontHeight). |
1331 "/ (aCollection isNil and:[list isNil]) ifTrue:[ |
1193 self originChanged:0 @ ((oldFirst - 1) negated * fontHeight). |
1332 "/ "no change" |
1194 shown ifTrue:[ |
1333 "/ ^ self |
1195 self clearView. |
1334 "/ ]. |
1196 ] |
1335 "/ |
1197 ] |
1336 "/ list := aCollection. |
1198 ]. |
1337 "/ |
1199 |
1338 "/ nonStringsBefore := includesNonStrings. |
1200 (shown and:[doRedraw]) ifTrue:[ |
1339 "/ includesNonStrings := false. |
1201 self redrawFromVisibleLine:1 to:nLinesShown |
1340 "/ |
1202 ] |
1341 "/ list notNil ifTrue:[ |
1203 |
1342 "/ expandTabs ifTrue:[ |
1204 "Modified: / 18.12.1995 / 23:27:54 / stefan" |
1343 "/ self expandTabs |
1205 "Created: / 22.4.1998 / 11:11:51 / cg" |
1344 "/ ] ifFalse:[ |
1206 "Modified: / 26.7.1998 / 13:46:49 / cg" |
1345 "/ scan ifTrue:[ |
|
1346 "/ includesNonStrings := (list findFirst:[:e | e isString not]) ~~ 0. |
|
1347 "/ ] ifFalse:[ |
|
1348 "/ includesNonStrings := nonStringsIfNoScan ? nonStringsBefore |
|
1349 "/ ] |
|
1350 "/ ]. |
|
1351 "/ ]. |
|
1352 "/ (includesNonStrings ~~ nonStringsBefore) ifTrue:[ |
|
1353 "/ self getFontParameters. |
|
1354 "/ self computeNumberOfLinesShown. |
|
1355 "/ ]. |
|
1356 "/ |
|
1357 "/ "/ new: reposition horizontally if too big |
|
1358 "/ widthOfWidestLine := nil. "/ i.e. unknown |
|
1359 "/ innerWidth >= self widthOfContents ifTrue:[ |
|
1360 "/ viewOrigin := 0 @ viewOrigin y. |
|
1361 "/ ]. |
|
1362 "/ self contentsChanged. |
|
1363 "/ |
|
1364 "/ "/ new: reposition vertically if too big |
|
1365 "/ (firstLineShown + nFullLinesShown) > self size ifTrue:[ |
|
1366 "/ oldFirst := firstLineShown. |
|
1367 "/ firstLineShown := self size - nFullLinesShown + 1. |
|
1368 "/ firstLineShown < 1 ifTrue:[firstLineShown := 1]. |
|
1369 "/ oldFirst ~= firstLineShown ifTrue:[ |
|
1370 "/ viewOrigin y:((firstLineShown - 1) * fontHeight). |
|
1371 "/ self originChanged:0 @ ((oldFirst - 1) negated * fontHeight). |
|
1372 "/ shown ifTrue:[ |
|
1373 "/ self clearView. |
|
1374 "/ ] |
|
1375 "/ ] |
|
1376 "/ ]. |
|
1377 "/ |
|
1378 "/ (shown and:[doRedraw]) ifTrue:[ |
|
1379 "/ self invalidate |
|
1380 "/ "/ self redrawFromVisibleLine:1 to:nLinesShown |
|
1381 "/ ] |
|
1382 "/ |
|
1383 "/ "Modified: / 18.12.1995 / 23:27:54 / stefan" |
|
1384 "/ "Created: / 22.4.1998 / 11:11:51 / cg" |
|
1385 "/ "Modified: / 26.7.1998 / 13:46:49 / cg" |
1207 ! |
1386 ! |
1208 |
1387 |
1209 size |
1388 size |
1210 "return the size (i.e. number of lines) |
1389 "return the size (i.e. number of lines) |
1211 this allows textViews to be used like collections in some places." |
1390 this allows textViews to be used like collections in some places." |
2621 |
2805 |
2622 getListFromModel |
2806 getListFromModel |
2623 "ask my model (if any) for the text via the listMsg. |
2807 "ask my model (if any) for the text via the listMsg. |
2624 If there is no listMessage, try aspect for backward compatibility." |
2808 If there is no listMessage, try aspect for backward compatibility." |
2625 |
2809 |
2626 |text msg| |
2810 |newText msg| |
2627 |
2811 |
2628 model notNil ifTrue:[ |
2812 model notNil ifTrue:[ |
2629 msg := listMsg ? aspectMsg. |
2813 msg := listMsg ? aspectMsg. |
2630 |
2814 |
2631 msg notNil ifTrue:[ |
2815 msg notNil ifTrue:[ |
2632 text := model perform:msg. |
2816 newText := model perform:msg. |
2633 "/ cg: this makes many optimizations (virtualArray) useless; |
2817 "/ cg: this makes many optimizations (virtualArray) useless; |
2634 "/ I do not think that this is a good idea!! |
2818 "/ I do not think that this is a good idea: |
2635 "/ text notNil ifTrue:[ |
2819 "/ text notNil ifTrue:[ |
2636 "/ so I changed it to: |
2820 "/ so I changed it to: |
2637 (text notNil and:[text isString]) ifTrue:[ |
2821 (newText notNil and:[newText isString]) ifTrue:[ |
2638 text := text asStringCollection. |
2822 newText := newText asStringCollection. |
|
2823 ]. |
|
2824 |
|
2825 compareModelOnUpdate ifTrue:[ |
|
2826 "/ see if there is a change at all. |
|
2827 "/ use to compare using =, but that's not enough in case of emphasis change. |
|
2828 newText size == list size ifTrue:[ |
|
2829 |same| |
|
2830 |
|
2831 same := true. |
|
2832 newText size > 0 ifTrue:[ |
|
2833 newText with:list do:[:eachNewLine :eachOldLine | |
|
2834 (eachNewLine == eachOldLine) ifFalse:[ |
|
2835 same := false. |
|
2836 ] |
|
2837 ] |
|
2838 ]. |
|
2839 same ifTrue:[^ self]. |
|
2840 ]. |
2639 ]. |
2841 ]. |
2640 |
2842 |
2641 "/ SV: this compare does not work, if model uses (i.e. updates) |
2843 "/ SV: this compare does not work, if model uses (i.e. updates) |
2642 "/ the same stringCollection as the view!! |
2844 "/ the same stringCollection as the view!! |
2643 true "text ~= list" ifTrue:[ |
2845 true "text ~= list" ifTrue:[ |
2644 scrollLocked == true ifTrue:[ |
2846 "/ changed #list to care for scrollLocked |
2645 self setList:text |
2847 "/ scrollLocked ifTrue:[ |
2646 ] ifFalse:[ |
2848 "/ self setList:newText expandTabs:expandTabsWhenUpdating |
2647 self list:text |
2849 "/ ] ifFalse:[ |
2648 ] |
2850 self list:newText expandTabs:expandTabsWhenUpdating scanForNonStrings:expandTabsWhenUpdating |
|
2851 "/ ] |
2649 ]. |
2852 ]. |
2650 ]. |
2853 ]. |
2651 ]. |
2854 ]. |
2652 |
2855 |
2653 "Modified: 26.4.1996 / 14:09:42 / cg" |
2856 "Modified: 26.4.1996 / 14:09:42 / cg" |