ListView.st
changeset 1693 e76979454c2f
parent 1656 1202fbc95970
child 1699 b10682bac6f9
equal deleted inserted replaced
1692:920eba722168 1693:e76979454c2f
    16 		textStartTop innerWidth tabPositions lineSpacing fontHeight
    16 		textStartTop innerWidth tabPositions lineSpacing fontHeight
    17 		fontAscent fontIsFixedWidth fontWidth autoScroll autoScrollBlock
    17 		fontAscent fontIsFixedWidth fontWidth autoScroll autoScrollBlock
    18 		autoScrollDeltaT lastSearchPattern lastSearchIgnoredCase
    18 		autoScrollDeltaT lastSearchPattern lastSearchIgnoredCase
    19 		wordCheck includesNonStrings widthOfWidestLine listMsg viewOrigin
    19 		wordCheck includesNonStrings widthOfWidestLine listMsg viewOrigin
    20 		listChannel backgroundAlreadyClearedColor'
    20 		listChannel backgroundAlreadyClearedColor'
    21 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor DefaultTabPositions'
    21 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor DefaultTabPositions
       
    22 			    DefaultLeftMargin DefaultTopMargin'
    22 	poolDictionaries:''
    23 	poolDictionaries:''
    23 	category:'Views-Text'
    24 	category:'Views-Text'
    24 !
    25 !
    25 
    26 
    26 !ListView class methodsFor:'documentation'!
    27 !ListView class methodsFor:'documentation'!
    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 
   151       textBackgroundColor                         defaults to White
   152       textBackgroundColor                         defaults to White
   152       textFont                                    defaults to defaultFont
   153       textFont                                    defaults to defaultFont
   153       textTabPositions                            defaults to #(1 9 17 25 ...)
   154       textTabPositions                            defaults to #(1 9 17 25 ...)
   154 
   155 
   155     [author:]
   156     [author:]
   156         Claus Gittinger
   157 	Claus Gittinger
   157 
   158 
   158     [see also:]
   159     [see also:]
   159         TextView EditTextView
   160 	TextView EditTextView
   160         
   161         
   161 "
   162 "
   162 !
   163 !
   163 
   164 
   164 examples 
   165 examples 
   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 
   491      (which avoids many computations later)"
   500      (which avoids many computations later)"
   492 
   501 
   493     |newMargin|
   502     |newMargin|
   494 
   503 
   495     aNumber ~~ level ifTrue:[
   504     aNumber ~~ level ifTrue:[
   496         newMargin := aNumber abs.
   505 	newMargin := aNumber abs.
   497         textStartLeft := leftMargin + newMargin.
   506 	textStartLeft := leftMargin + newMargin.
   498         textStartTop := topMargin + newMargin.
   507 	textStartTop := topMargin + newMargin.
   499         innerWidth := width - textStartLeft - newMargin.
   508 	innerWidth := width - textStartLeft - newMargin.
   500 
   509 
   501         super level:aNumber.
   510 	super level:aNumber.
   502     ]
   511     ]
   503 
   512 
   504     "Modified: 11.8.1997 / 02:59:15 / cg"
   513     "Modified: 11.8.1997 / 02:59:15 / cg"
   505 !
   514 !
   506 
   515 
   549 add:aString
   558 add:aString
   550     "add a line and redisplay"
   559     "add a line and redisplay"
   551 
   560 
   552     list add:aString.
   561     list add:aString.
   553     includesNonStrings ifFalse:[
   562     includesNonStrings ifFalse:[
   554         includesNonStrings := (aString notNil and:[aString isString not]).
   563 	includesNonStrings := (aString notNil and:[aString isString not]).
   555 "/        includesNonStrings ifTrue:[self getFontParameters].
   564 "/        includesNonStrings ifTrue:[self getFontParameters].
   556     ].
   565     ].
   557     shown ifTrue:[
   566     shown ifTrue:[
   558         self redrawLine:(self size).
   567 	self redrawLine:(self size).
   559         self contentsChanged.             "recompute scrollbars"
   568 	self contentsChanged.             "recompute scrollbars"
   560     ]
   569     ]
   561 
   570 
   562     "Modified: 22.10.1996 / 23:18:47 / cg"
   571     "Modified: 22.10.1996 / 23:18:47 / cg"
   563 !
   572 !
   564 
   573 
   566     "add a line and redisplay"
   575     "add a line and redisplay"
   567 
   576 
   568     list isNil ifTrue:[list := OrderedCollection new].
   577     list isNil ifTrue:[list := OrderedCollection new].
   569     list add:aString beforeIndex:index.
   578     list add:aString beforeIndex:index.
   570     includesNonStrings ifFalse:[
   579     includesNonStrings ifFalse:[
   571         includesNonStrings := (aString notNil and:[aString isString not]).
   580 	includesNonStrings := (aString notNil and:[aString isString not]).
   572 "/        includesNonStrings ifTrue:[self getFontParameters].
   581 "/        includesNonStrings ifTrue:[self getFontParameters].
   573     ].
   582     ].
   574     shown ifTrue:[
   583     shown ifTrue:[
   575         self redrawFromLine:index.
   584 	self redrawFromLine:index.
   576         self contentsChanged.             "recompute scrollbars"
   585 	self contentsChanged.             "recompute scrollbars"
   577     ]
   586     ]
   578 
   587 
   579     "Modified: 22.10.1996 / 23:18:53 / cg"
   588     "Modified: 22.10.1996 / 23:18:53 / cg"
   580 !
   589 !
   581 
   590 
   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 "/        ].
   659 
   668 
   660     |l|
   669     |l|
   661 
   670 
   662     l := something.
   671     l := something.
   663     l notNil ifTrue:[
   672     l notNil ifTrue:[
   664         l isString ifTrue:[
   673 	l isString ifTrue:[
   665             l := l asStringCollection
   674 	    l := l asStringCollection
   666         ]
   675 	]
   667     ].
   676     ].
   668     self list:l
   677     self list:l
   669 
   678 
   670     "Modified: 5.6.1997 / 11:11:54 / cg"
   679     "Modified: 5.6.1997 / 11:11:54 / cg"
   671 !
   680 !
   724      If scan is true, scan the passed list for nonStrings; otherwise,
   733      If scan is true, scan the passed list for nonStrings; otherwise,
   725      assume that it does contain non-strings
   734      assume that it does contain non-strings
   726      (remembered to optimize later redraws)."
   735      (remembered to optimize later redraws)."
   727 
   736 
   728     self
   737     self
   729         list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:true
   738 	list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:true
   730 
   739 
   731     "Modified: 5.6.1997 / 12:40:35 / cg"
   740     "Modified: 5.6.1997 / 12:40:35 / cg"
   732 !
   741 !
   733 
   742 
   734 list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStrings
   743 list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStrings
   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 
   913      (for example: a file list being shown, without disturbing the user too much)"
   922      (for example: a file list being shown, without disturbing the user too much)"
   914 
   923 
   915     |oldFirst nonStringsBefore linesShownBefore|
   924     |oldFirst nonStringsBefore linesShownBefore|
   916 
   925 
   917     (aCollection isNil and:[list isNil]) ifTrue:[
   926     (aCollection isNil and:[list isNil]) ifTrue:[
   918         "no change"
   927 	"no change"
   919         ^ self
   928 	^ self
   920     ].
   929     ].
   921 
   930 
   922 "/    list isNil ifTrue:[
   931 "/    list isNil ifTrue:[
   923 "/        linesShownBefore := (1 to:nLinesShown) collect:[:i | ''].
   932 "/        linesShownBefore := (1 to:nLinesShown) collect:[:i | ''].
   924 "/    ] ifFalse:[
   933 "/    ] ifFalse:[
   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 |
  1011 
  1020 
  1012     |line len s|
  1021     |line len s|
  1013 
  1022 
  1014     len := col2 - col1 + 1.
  1023     len := col2 - col1 + 1.
  1015     list notNil ifTrue:[
  1024     list notNil ifTrue:[
  1016         line := self listAt:lineNr.
  1025 	line := self listAt:lineNr.
  1017         line notNil ifTrue:[
  1026 	line notNil ifTrue:[
  1018             (line size >= col1) ifTrue:[
  1027 	    (line size >= col1) ifTrue:[
  1019                 s := line copyFrom:col1.
  1028 		s := line copyFrom:col1.
  1020                 s size < len ifTrue:[
  1029 		s size < len ifTrue:[
  1021                     ^ s paddedTo:len
  1030 		    ^ s paddedTo:len
  1022                 ].
  1031 		].
  1023                 ^ s copyTo:len
  1032 		^ s copyTo:len
  1024             ]
  1033 	    ]
  1025         ]
  1034 	]
  1026     ].
  1035     ].
  1027     ^ String new:len withAll:Character space
  1036     ^ String new:len withAll:Character space
  1028 
  1037 
  1029     "Created: 7.1.1997 / 19:58:43 / cg"
  1038     "Created: 7.1.1997 / 19:58:43 / cg"
  1030 !
  1039 !
  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 
  1118 
  1127 
  1119 on:aModel aspect:aspectSymbol change:changeSymbol list:listSymbol menu:menuSymbol 
  1128 on:aModel aspect:aspectSymbol change:changeSymbol list:listSymbol menu:menuSymbol 
  1120     "ST-80 compatibility"
  1129     "ST-80 compatibility"
  1121 
  1130 
  1122     aspectSymbol notNil ifTrue:[aspectMsg := aspectSymbol. 
  1131     aspectSymbol notNil ifTrue:[aspectMsg := aspectSymbol. 
  1123                              listMsg isNil ifTrue:[listMsg := aspectSymbol]].
  1132 			     listMsg isNil ifTrue:[listMsg := aspectSymbol]].
  1124     listSymbol notNil ifTrue:[listMsg := listSymbol].
  1133     listSymbol notNil ifTrue:[listMsg := listSymbol].
  1125     changeSymbol notNil ifTrue:[changeMsg := changeSymbol].
  1134     changeSymbol notNil ifTrue:[changeMsg := changeSymbol].
  1126     menuMsg := menuSymbol.
  1135     menuMsg := menuSymbol.
  1127     self model:aModel.
  1136     self model:aModel.
  1128 
  1137 
  1149 
  1158 
  1150 !ListView methodsFor:'change and update '!
  1159 !ListView methodsFor:'change and update '!
  1151 
  1160 
  1152 update:something with:aParameter from:changedObject
  1161 update:something with:aParameter from:changedObject
  1153     changedObject == model ifTrue:[
  1162     changedObject == model ifTrue:[
  1154         (aspectMsg notNil
  1163 	(aspectMsg notNil
  1155         and:[something == aspectMsg]) ifTrue:[
  1164 	and:[something == aspectMsg]) ifTrue:[
  1156             ^ self getListFromModel.
  1165 	    ^ self getListFromModel.
  1157         ].
  1166 	].
  1158 
  1167 
  1159         something == #size ifTrue:[
  1168 	something == #size ifTrue:[
  1160             ^ self getListFromModelScroll:false.
  1169 	    ^ self getListFromModelScroll:false.
  1161         ]
  1170 	]
  1162     ].
  1171     ].
  1163     ^ super update:something with:aParameter from:changedObject
  1172     ^ super update:something with:aParameter from:changedObject
  1164 
  1173 
  1165     "Modified: 5.3.1997 / 16:14:01 / cg"
  1174     "Modified: 5.3.1997 / 16:14:01 / cg"
  1166 ! !
  1175 ! !
  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 
  1405 fillRectangleX:x y:y width:w height:h
  1414 fillRectangleX:x y:y width:w height:h
  1406     "fill rectangle; checks whether the rectangle already is filled with
  1415     "fill rectangle; checks whether the rectangle already is filled with
  1407      the current paint (#redrawX:y:w:h).
  1416      the current paint (#redrawX:y:w:h).
  1408     "
  1417     "
  1409     backgroundAlreadyClearedColor ~~ paint ifTrue:[
  1418     backgroundAlreadyClearedColor ~~ paint ifTrue:[
  1410         super fillRectangleX:x y:y width:w height:h
  1419 	super fillRectangleX:x y:y width:w height:h
  1411     ]
  1420     ]
  1412 
  1421 
  1413 
  1422 
  1414 !
  1423 !
  1415 
  1424 
  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 
  1592     listSize := self numberOfLines.
  1596     listSize := self numberOfLines.
  1593     "
  1597     "
  1594      if we are beyond the end, scroll up a bit
  1598      if we are beyond the end, scroll up a bit
  1595     "
  1599     "
  1596     ((firstLineShown + nFullLinesShown) > listSize) ifTrue:[
  1600     ((firstLineShown + nFullLinesShown) > listSize) ifTrue:[
  1597         newOrigin := listSize - nFullLinesShown + 1.
  1601 	newOrigin := listSize - nFullLinesShown + 1.
  1598         newOrigin < 1 ifTrue:[
  1602 	newOrigin < 1 ifTrue:[
  1599             newOrigin := 1
  1603 	    newOrigin := 1
  1600         ].
  1604 	].
  1601         self scrollToLine: newOrigin.
  1605 	self scrollToLine: newOrigin.
  1602         ^ self
  1606 	^ self
  1603     ].
  1607     ].
  1604 
  1608 
  1605     "Modified: / 18.11.1996 / 19:37:02 / stefan"
  1609     "Modified: / 18.11.1996 / 19:37:02 / stefan"
  1606     "Modified: / 27.1.1998 / 14:10:04 / cg"
  1610     "Modified: / 27.1.1998 / 14:10:04 / cg"
  1607 ! !
  1611 ! !
  1635 !
  1639 !
  1636 
  1640 
  1637 initStyle
  1641 initStyle
  1638     "setup viewStyle specifics"
  1642     "setup viewStyle specifics"
  1639 
  1643 
       
  1644     |n|
       
  1645 
  1640     super initStyle.
  1646     super initStyle.
  1641 
  1647 
  1642 "/    DefaultFont notNil ifTrue:[font := DefaultFont on:device]
  1648 "/    DefaultFont notNil ifTrue:[font := DefaultFont on:device]
  1643 
  1649 
  1644     self topMargin:(self verticalPixelPerMillimeter:0.5) rounded.
  1650     n := DefaultTopMargin.
  1645     self leftMargin:(self horizontalPixelPerMillimeter:0.5) rounded.
  1651     n isInteger ifFalse:[
       
  1652 	n := (self verticalPixelPerMillimeter:n) rounded.
       
  1653     ].
       
  1654     self topMargin:n.
       
  1655 
       
  1656     n := DefaultLeftMargin.
       
  1657     n isInteger ifFalse:[
       
  1658 	n := (self verticalPixelPerMillimeter:n) rounded.
       
  1659     ].
       
  1660     self leftMargin:n.
  1646 
  1661 
  1647     lineSpacing := 0.
  1662     lineSpacing := 0.
  1648     fgColor := DefaultForegroundColor.
  1663     fgColor := DefaultForegroundColor.
  1649     bgColor := DefaultBackgroundColor.
  1664     bgColor := DefaultBackgroundColor.
  1650 
       
  1651     "Modified: 22.1.1997 / 11:57:21 / cg"
       
  1652 !
  1665 !
  1653 
  1666 
  1654 initialize
  1667 initialize
  1655     super initialize.
  1668     super initialize.
  1656 
  1669 
  1677 
  1690 
  1678 realize
  1691 realize
  1679     |sz|
  1692     |sz|
  1680 
  1693 
  1681     extentChanged ifTrue:[
  1694     extentChanged ifTrue:[
  1682         self computeNumberOfLinesShown.
  1695 	self computeNumberOfLinesShown.
  1683     ].
  1696     ].
  1684 
  1697 
  1685     firstLineShown ~~ 1 ifTrue:[
  1698     firstLineShown ~~ 1 ifTrue:[
  1686         sz := self size.
  1699 	sz := self size.
  1687         firstLineShown + nLinesShown > sz ifTrue:[
  1700 	firstLineShown + nLinesShown > sz ifTrue:[
  1688             self scrollToLine:sz - nLinesShown.
  1701 	    self scrollToLine:sz - nLinesShown.
  1689         ]
  1702 	]
  1690     ].
  1703     ].
  1691 
  1704 
  1692     super realize.
  1705     super realize.
  1693 
  1706 
  1694 "/ old: fetch models value on realize;
  1707 "/ old: fetch models value on realize;
  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.
  1971      If there is no listMessage, try aspect for backward compatibility."
  2000      If there is no listMessage, try aspect for backward compatibility."
  1972 
  2001 
  1973     |text msg|
  2002     |text msg|
  1974 
  2003 
  1975     model notNil ifTrue:[
  2004     model notNil ifTrue:[
  1976         msg := listMsg.
  2005 	msg := listMsg.
  1977         msg isNil ifTrue:[
  2006 	msg isNil ifTrue:[
  1978             msg := aspectMsg
  2007 	    msg := aspectMsg
  1979         ].
  2008 	].
  1980 
  2009 
  1981 
  2010 
  1982         msg notNil ifTrue:[
  2011 	msg notNil ifTrue:[
  1983             text := model perform:msg.
  2012 	    text := model perform:msg.
  1984             text notNil ifTrue:[
  2013 	    text notNil ifTrue:[
  1985                 text := text asStringCollection.
  2014 		text := text asStringCollection.
  1986             ].
  2015 	    ].
  1987 "/ SV: this does not work, if model uses (i.e. updates) the same stringCollection
  2016 "/ SV: this does not work, if model uses (i.e. updates) the same stringCollection
  1988 "/ as the view!!
  2017 "/ as the view!!
  1989 "/            text ~= list ifTrue:[
  2018 "/            text ~= list ifTrue:[
  1990                 self list:text
  2019 		self list:text
  1991 "/            ].
  2020 "/            ].
  1992         ].
  2021 	].
  1993     ].
  2022     ].
  1994 
  2023 
  1995     "Modified: 26.4.1996 / 14:09:42 / cg"
  2024     "Modified: 26.4.1996 / 14:09:42 / cg"
  1996     "Modified: 19.2.1997 / 12:08:50 / stefan"
  2025     "Modified: 19.2.1997 / 12:08:50 / stefan"
  1997 !
  2026 !
  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"
  2039 
  2068 
  2040     lineNr := 1.
  2069     lineNr := 1.
  2041     sum := 0.
  2070     sum := 0.
  2042     lastLine := self size.
  2071     lastLine := self size.
  2043     [(sum < charPos) and:[lineNr <= lastLine]] whileTrue:[
  2072     [(sum < charPos) and:[lineNr <= lastLine]] whileTrue:[
  2044         sum := sum + (self at:lineNr) size + 1.
  2073 	sum := sum + (self at:lineNr) size + 1.
  2045         lineNr := lineNr + 1
  2074 	lineNr := lineNr + 1
  2046     ].
  2075     ].
  2047     sum == charPos ifTrue:[
  2076     sum == charPos ifTrue:[
  2048         ^ lineNr
  2077 	^ lineNr
  2049     ].
  2078     ].
  2050 
  2079 
  2051     ^ lineNr - 1
  2080     ^ lineNr - 1
  2052 
  2081 
  2053     "Modified: / 5.4.1998 / 17:19:28 / cg"
  2082     "Modified: / 5.4.1998 / 17:19:28 / 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"
  2873 
  2902 
  2874 scrollDown:nLines
  2903 scrollDown:nLines
  2875     "change origin to scroll down some lines (towards the bottom of the text)"
  2904     "change origin to scroll down some lines (towards the bottom of the text)"
  2876 
  2905 
  2877     nLines > 0 ifTrue:[
  2906     nLines > 0 ifTrue:[
  2878         self scrollTo:(viewOrigin + (0 @ (fontHeight * nLines)))
  2907 	self scrollTo:(viewOrigin + (0 @ (fontHeight * nLines)))
  2879                redraw:true
  2908 	       redraw:true
  2880     ]
  2909     ]
  2881 
  2910 
  2882 
  2911 
  2883 
  2912 
  2884 !
  2913 !
  2887     "change origin to scroll down some pixels 
  2916     "change origin to scroll down some pixels 
  2888      (towards the bottom of the text)
  2917      (towards the bottom of the text)
  2889      THIS WILL VANISH!!"
  2918      THIS WILL VANISH!!"
  2890 
  2919 
  2891     pix > 0 ifTrue:[
  2920     pix > 0 ifTrue:[
  2892         self scrollTo:(viewOrigin + (0 @ (pix abs))) redraw:true
  2921 	self scrollTo:(viewOrigin + (0 @ (pix abs))) redraw:true
  2893     ]
  2922     ]
  2894 
  2923 
  2895 
  2924 
  2896 !
  2925 !
  2897 
  2926 
  2920 
  2949 
  2921 scrollLeft:nPixel
  2950 scrollLeft:nPixel
  2922     "change origin to scroll left some cols"
  2951     "change origin to scroll left some cols"
  2923 
  2952 
  2924     nPixel > 0 ifTrue:[
  2953     nPixel > 0 ifTrue:[
  2925         self scrollTo:(viewOrigin - (nPixel @ 0)) redraw:true
  2954 	self scrollTo:(viewOrigin - (nPixel @ 0)) redraw:true
  2926     ]
  2955     ]
  2927 
  2956 
  2928 
  2957 
  2929 !
  2958 !
  2930 
  2959 
  2937 
  2966 
  2938 scrollRight:nPixel
  2967 scrollRight:nPixel
  2939     "change origin to scroll right some cols"
  2968     "change origin to scroll right some cols"
  2940 
  2969 
  2941     nPixel > 0 ifTrue:[
  2970     nPixel > 0 ifTrue:[
  2942         self scrollTo:(viewOrigin + (nPixel @ 0)) redraw:true
  2971 	self scrollTo:(viewOrigin + (nPixel @ 0)) redraw:true
  2943     ]
  2972     ]
  2944 
  2973 
  2945 
  2974 
  2946 !
  2975 !
  2947 
  2976 
  3034 
  3063 
  3035 scrollUp:nLines
  3064 scrollUp:nLines
  3036     "change origin to scroll up some lines (towards the top of the text)"
  3065     "change origin to scroll up some lines (towards the top of the text)"
  3037 
  3066 
  3038     nLines > 0 ifTrue:[
  3067     nLines > 0 ifTrue:[
  3039         self scrollTo:(viewOrigin - (0 @ (fontHeight * nLines)))
  3068 	self scrollTo:(viewOrigin - (0 @ (fontHeight * nLines)))
  3040                redraw:true
  3069 	       redraw:true
  3041     ]
  3070     ]
  3042 
  3071 
  3043 
  3072 
  3044 !
  3073 !
  3045 
  3074 
  3047     "change origin to scroll up some pixels 
  3076     "change origin to scroll up some pixels 
  3048      (towards the top of the text)
  3077      (towards the top of the text)
  3049     THIS WILL VANISH!!"
  3078     THIS WILL VANISH!!"
  3050 
  3079 
  3051     pix > 0 ifTrue:[
  3080     pix > 0 ifTrue:[
  3052         self scrollTo:(viewOrigin - (0 @ pix)) redraw:true
  3081 	self scrollTo:(viewOrigin - (0 @ pix)) redraw:true
  3053     ]
  3082     ]
  3054 
  3083 
  3055 
  3084 
  3056 !
  3085 !
  3057 
  3086 
  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.
  3254 
  3283 
  3255     (     (y ~~ 0 and:[x ~~ 0])                                 "/ both x and y changed
  3284     (     (y ~~ 0 and:[x ~~ 0])                                 "/ both x and y changed
  3256       or:[(noLn abs) >= nLinesShown                             "/ at least one area is
  3285       or:[(noLn abs) >= nLinesShown                             "/ at least one area is
  3257       or:[(x abs) > (width // 4 * 3)]]                          "/ big enough to redraw all
  3286       or:[(x abs) > (width // 4 * 3)]]                          "/ big enough to redraw all
  3258     ) ifTrue:[
  3287     ) ifTrue:[
  3259         self originWillChange.
  3288 	self originWillChange.
  3260         firstLineShown := newFirstLine.
  3289 	firstLineShown := newFirstLine.
  3261         viewOrigin := newViewOrigin.
  3290 	viewOrigin := newViewOrigin.
  3262         leftOffset := newLeftOffset.
  3291 	leftOffset := newLeftOffset.
  3263         self invalidate.
  3292 	self invalidate.
  3264         ^ self originChanged:delta
  3293 	^ self originChanged:delta
  3265     ].
  3294     ].
  3266 
  3295 
  3267     self repairDamage.
  3296     self repairDamage.
  3268 
  3297 
  3269     self originWillChange.
  3298     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 
  3489     "search for a pattern, if found evaluate block1 with row/col as arguments, if not
  3518     "search for a pattern, if found evaluate block1 with row/col as arguments, if not
  3490      found evaluate block2.
  3519      found evaluate block2.
  3491      Sorry, but pattern is no regular expression pattern (yet)"
  3520      Sorry, but pattern is no regular expression pattern (yet)"
  3492 
  3521 
  3493     ^ self
  3522     ^ self
  3494         searchBackwardFor:pattern 
  3523 	searchBackwardFor:pattern 
  3495         ignoreCase:false 
  3524 	ignoreCase:false 
  3496         startingAtLine:startLine col:startCol 
  3525 	startingAtLine:startLine col:startCol 
  3497         ifFound:block1 
  3526 	ifFound:block1 
  3498         ifAbsent:block2
  3527 	ifAbsent:block2
  3499 
  3528 
  3500     "Modified: 13.9.1997 / 01:07:36 / cg"
  3529     "Modified: 13.9.1997 / 01:07:36 / cg"
  3501 !
  3530 !
  3502 
  3531 
  3503 searchForwardFor:pattern ignoreCase:ignCase startingAtLine:startLine col:startCol ifFound:block1 ifAbsent:block2
  3532 searchForwardFor:pattern ignoreCase:ignCase startingAtLine:startLine col:startCol ifFound:block1 ifAbsent:block2
  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 
  3585 searchForwardFor:pattern startingAtLine:startLine col:startCol ifFound:block1 ifAbsent:block2
  3614 searchForwardFor:pattern startingAtLine:startLine col:startCol ifFound:block1 ifAbsent:block2
  3586     "search for a pattern, if found evaluate block1 with row/col as arguments, if not
  3615     "search for a pattern, if found evaluate block1 with row/col as arguments, if not
  3587      found evaluate block2."
  3616      found evaluate block2."
  3588 
  3617 
  3589     ^ self
  3618     ^ self
  3590         searchForwardFor:pattern 
  3619 	searchForwardFor:pattern 
  3591         ignoreCase:false 
  3620 	ignoreCase:false 
  3592         startingAtLine:startLine col:startCol 
  3621 	startingAtLine:startLine col:startCol 
  3593         ifFound:block1 
  3622 	ifFound:block1 
  3594         ifAbsent:block2
  3623 	ifAbsent:block2
  3595 
  3624 
  3596     "Modified: 13.9.1997 / 01:07:11 / cg"
  3625     "Modified: 13.9.1997 / 01:07:11 / cg"
  3597 ! !
  3626 ! !
  3598 
  3627 
  3599 !ListView methodsFor:'tabulators'!
  3628 !ListView methodsFor:'tabulators'!
  3788 ! !
  3817 ! !
  3789 
  3818 
  3790 !ListView class methodsFor:'documentation'!
  3819 !ListView class methodsFor:'documentation'!
  3791 
  3820 
  3792 version
  3821 version
  3793     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.173 1998-09-04 16:27:18 cg Exp $'
  3822     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.174 1998-09-28 09:25:54 cg Exp $'
  3794 ! !
  3823 ! !