ListView.st
branchjv
changeset 5737 98bc0782ffa1
parent 5692 2fb164455e7c
parent 5721 93b70f144978
child 5760 9a0b5601b3f4
equal deleted inserted replaced
5709:219a28ca67d1 5737:98bc0782ffa1
  2852     "Created: / 25-07-2012 / 11:59:58 / cg"
  2852     "Created: / 25-07-2012 / 11:59:58 / cg"
  2853 !
  2853 !
  2854 
  2854 
  2855 getFontParameters
  2855 getFontParameters
  2856     "get some info of the used font. They are cached since we use them often ..
  2856     "get some info of the used font. They are cached since we use them often ..
  2857      The code below uses the fonts average height parameters - these
  2857      The code below uses the font's average height parameters - these
  2858      are not OK for some oversized national characters (such as A-dieresis).
  2858      are not OK for some oversized national characters (such as A-dieresis).
  2859      Therefore, this method should be redefined in views which will be used
  2859      Therefore, this method should be redefined in views which will be used
  2860      with national characters (i.e. editTextViews)."
  2860      with national characters (i.e. editTextViews)."
  2861 
  2861 
  2862     |hMax newDeviceFont|
  2862     |hMax newDeviceFont|
  4808                                     (fullWord not
  4808                                     (fullWord not
  4809                                         or:[ (self findBeginOfWordAtLine:lnr col:col) == col
  4809                                         or:[ (self findBeginOfWordAtLine:lnr col:col) == col
  4810                                               and:[ (self findEndOfWordAtLine:lnr col:col) == (col + patternSize - 1) ]]
  4810                                               and:[ (self findEndOfWordAtLine:lnr col:col) == (col + patternSize - 1) ]]
  4811                                     ) ifTrue:[
  4811                                     ) ifTrue:[
  4812                                         (atBeginOfLineOnly not or:[col == 1]) ifTrue:[
  4812                                         (atBeginOfLineOnly not or:[col == 1]) ifTrue:[
  4813                                             ^ block1 value:lnr value:col.
  4813                                             ^ block1 value:lnr value:col optionalArgument:nil.
  4814                                         ]
  4814                                         ]
  4815                                     ]
  4815                                     ]
  4816                                 ].
  4816                                 ].
  4817                                 col := col - 1.
  4817                                 col := col - 1.
  4818                                 [(col > 0)
  4818                                 [(col > 0)
  4871 !
  4871 !
  4872 
  4872 
  4873 searchForwardUsingSpec:searchSpec startingAtLine:startLine col:startCol ifFound:block1 ifAbsent:block2
  4873 searchForwardUsingSpec:searchSpec startingAtLine:startLine col:startCol ifFound:block1 ifAbsent:block2
  4874     "search for a pattern, if found evaluate block1 with row/col as arguments, 
  4874     "search for a pattern, if found evaluate block1 with row/col as arguments, 
  4875      if not found evaluate block2. 
  4875      if not found evaluate block2. 
  4876      If the block is a three-arg block, it gets the end-col (or nil, if not found)"
  4876      If the block is a three-arg block, it gets the end-col (or nil, if not known)"
  4877 
  4877 
  4878     |lineString col pattern match regexMatch ignCase fullWord atBeginOfLineOnly
  4878     |lineString col pattern match regexMatch ignCase fullWord atBeginOfLineOnly
  4879      wrapAtEndOfText patternSize matcher lnr   "{Class: SmallInteger}"  
  4879      wrapAtEndOfText patternSize matcher lnr   "{Class: SmallInteger}"  
  4880      line1 "{Class: SmallInteger}"
  4880      line1 "{Class: SmallInteger}"
  4881      line2 "{Class: SmallInteger}"
  4881      line2 "{Class: SmallInteger}"
  4882      p realPattern runner foundCol endCol|
  4882      p realPattern runner foundCol endCol|
  4883 
  4883 
  4884     pattern := searchSpec pattern.
  4884     pattern := searchSpec pattern.
  4885     match := searchSpec match.
  4885     match := searchSpec match.
  4886     regexMatch := searchSpec regexMatch.
  4886     regexMatch := searchSpec regexMatch.
       
  4887     (match and:[regexMatch not]) ifTrue:[
       
  4888         pattern := pattern globPatternAsRegexPattern.
       
  4889         regexMatch := true.
       
  4890     ].    
  4887     ignCase := searchSpec ignoreCase.
  4891     ignCase := searchSpec ignoreCase.
  4888     fullWord := searchSpec fullWord.
  4892     fullWord := searchSpec fullWord.
  4889     atBeginOfLineOnly := searchSpec atBeginOfLineOnly.
  4893     atBeginOfLineOnly := searchSpec atBeginOfLineOnly.
  4890     wrapAtEndOfText := searchSpec wrapAtEndOfText.
  4894     wrapAtEndOfText := searchSpec wrapAtEndOfText.
  4891 
  4895 
  4941                                     foundCol >= col ifTrue:[
  4945                                     foundCol >= col ifTrue:[
  4942                                         (atBeginOfLineOnly not or:[foundCol == 1]) ifTrue:[
  4946                                         (atBeginOfLineOnly not or:[foundCol == 1]) ifTrue:[
  4943                                             ^ block1 value:lnr value:foundCol optionalArgument:endCol.
  4947                                             ^ block1 value:lnr value:foundCol optionalArgument:endCol.
  4944                                         ]]]]]].
  4948                                         ]]]]]].
  4945             ] ifFalse:[    
  4949             ] ifFalse:[    
  4946                 (match and:[regexMatch or:[pattern includesUnescapedMatchCharacters]]) ifTrue:[
  4950                 (match and:[pattern includesUnescapedMatchCharacters]) ifTrue:[
  4947                     "perform a findMatchString (glob matching)"
  4951                     "perform a findMatchString (glob matching)"
  4948                     p := pattern species new:0.
  4952                     p := pattern species new:0.
  4949                     (pattern startsWith:$*) ifFalse:[p := p , '*'].
  4953                     (pattern startsWith:$*) ifFalse:[p := p , '*'].
  4950                     p := p , pattern.
  4954                     p := p , pattern.
  4951                     (pattern endsWith:$*) ifFalse:[p := p , '*'].
  4955                     (pattern endsWith:$*) ifFalse:[p := p , '*'].
  4965                                         ^ block1 value:lnr value:foundCol optionalArgument:nil.
  4969                                         ^ block1 value:lnr value:foundCol optionalArgument:nil.
  4966                                     ]]]].
  4970                                     ]]]].
  4967                 ] ifFalse:[
  4971                 ] ifFalse:[
  4968                     "perform a findString (no matching)"
  4972                     "perform a findString (no matching)"
  4969                     p := pattern.
  4973                     p := pattern.
       
  4974                     (match and:[pattern includesMatchCharacters]) ifTrue:[
       
  4975                         p := pattern withoutMatchEscapes
       
  4976                     ].    
  4970                     runner 
  4977                     runner 
  4971                         value:[:lnr :col :lineString |
  4978                         value:[:lnr :col :lineString |
  4972                             foundCol := lineString
  4979                             foundCol := lineString
  4973                                     findString:p startingAt:col ifAbsent:0 caseSensitive: ignCase not.
  4980                                     findString:p startingAt:col ifAbsent:0 caseSensitive: ignCase not.
  4974                             foundCol ~~ 0 ifTrue:[
  4981                             foundCol ~~ 0 ifTrue:[
  5273 
  5280 
  5274 atBeginOfLineOnly
  5281 atBeginOfLineOnly
  5275     ^ atBeginOfLineOnly ? false
  5282     ^ atBeginOfLineOnly ? false
  5276 !
  5283 !
  5277 
  5284 
  5278 atBeginOfLineOnly:something
  5285 atBeginOfLineOnly:aBoolean
  5279     atBeginOfLineOnly := something.
  5286     atBeginOfLineOnly := aBoolean.
  5280 !
  5287 !
  5281 
  5288 
  5282 forward
  5289 forward
  5283     ^ forward ? true
  5290     ^ forward ? true
  5284 !
  5291 !
  5389     forward := forwardBoolean.
  5396     forward := forwardBoolean.
  5390     atBeginOfLineOnly := atBeginOfLineOnlyArg
  5397     atBeginOfLineOnly := atBeginOfLineOnlyArg
  5391 !
  5398 !
  5392 
  5399 
  5393 regexMatch
  5400 regexMatch
  5394     ^ regexMatch
  5401     ^ regexMatch ? false
  5395 !
  5402 !
  5396 
  5403 
  5397 regexMatch:something
  5404 regexMatch:aBoolean
  5398     regexMatch := something.
  5405     regexMatch := aBoolean.
  5399 !
  5406 !
  5400 
  5407 
  5401 variable
  5408 variable
  5402     ^ variable
  5409     ^ variable
  5403 !
  5410 !