ListView.st
changeset 4280 61a16b0a99d5
parent 4247 a2786871ebe7
child 4303 dbd6a7f7c3f9
equal deleted inserted replaced
4279:f944300bc0be 4280:61a16b0a99d5
  3101      return the lineNumber where the character is
  3101      return the lineNumber where the character is
  3102      - used to find line to hilight from Compilers error-position"
  3102      - used to find line to hilight from Compilers error-position"
  3103 
  3103 
  3104     |lineNr sum lastLine lineEndCharSize|
  3104     |lineNr sum lastLine lineEndCharSize|
  3105 
  3105 
  3106     lineEndCharSize := self lineEndCRLF ifTrue:2 ifFalse:1.
  3106     lineEndCharSize := self lineEndCRLF ifTrue:[2] ifFalse:[1].
  3107 
  3107 
  3108     lineNr := 1.
  3108     lineNr := 1.
  3109     sum := 0.
  3109     sum := 0.
  3110     lastLine := self size.
  3110     lastLine := self size.
  3111     [(sum < charPos) and:[lineNr <= lastLine]] whileTrue:[
  3111     [(sum < charPos) and:[lineNr <= lastLine]] whileTrue:[
  3112 	sum := sum + (self at:lineNr) size + lineEndCharSize.
  3112         sum := sum + (self at:lineNr) size + lineEndCharSize.
  3113 	lineNr := lineNr + 1
  3113         lineNr := lineNr + 1
  3114     ].
  3114     ].
  3115     sum == charPos ifTrue:[
  3115     sum == charPos ifTrue:[
  3116 	^ lineNr
  3116         ^ lineNr
  3117     ].
  3117     ].
  3118 
  3118 
  3119     ^ lineNr - 1
  3119     ^ lineNr - 1
  3120 
  3120 
  3121     "Modified: / 05-04-1998 / 17:19:28 / cg"
       
  3122     "Modified: / 04-07-2006 / 19:13:32 / fm"
  3121     "Modified: / 04-07-2006 / 19:13:32 / fm"
       
  3122     "Modified: / 05-07-2011 / 22:52:11 / cg"
  3123 !
  3123 !
  3124 
  3124 
  3125 numberOfLines
  3125 numberOfLines
  3126     "return the number of lines the text has"
  3126     "return the number of lines the text has"
  3127 
  3127 
  4635     startLine := something.
  4635     startLine := something.
  4636 ! !
  4636 ! !
  4637 
  4637 
  4638 !ListView class methodsFor:'documentation'!
  4638 !ListView class methodsFor:'documentation'!
  4639 
  4639 
  4640 version
       
  4641     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.345 2011-05-02 12:08:38 sr Exp $'
       
  4642 !
       
  4643 
       
  4644 version_CVS
  4640 version_CVS
  4645     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.345 2011-05-02 12:08:38 sr Exp $'
  4641     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.346 2011-07-05 21:27:11 cg Exp $'
  4646 ! !
  4642 ! !