ListView.st
changeset 4468 6d711c19c529
parent 4463 8bfe40af7940
child 4495 512fb0a0d8bd
equal deleted inserted replaced
4467:746be61eb7f2 4468:6d711c19c529
  2970 
  2970 
  2971 !ListView methodsFor:'queries'!
  2971 !ListView methodsFor:'queries'!
  2972 
  2972 
  2973 characterPositionOfLine:lineNr col:colArg
  2973 characterPositionOfLine:lineNr col:colArg
  2974     "given a line/col position, return the character index within the contents-string,
  2974     "given a line/col position, return the character index within the contents-string,
  2975      - used with Compilers error-positioning, which is based on character positions
  2975      - used with compiler's error-positioning, which is based on character positions
  2976      of the contents-string."
  2976      of the contents-string."
  2977 
  2977 
  2978     |lineString pos lineEndCharSize col|
  2978     |lineString charPos lineEndCharSize col|
  2979 
  2979 
  2980     lineEndCharSize := self lineEndCRLF ifTrue:[2] ifFalse:[1].
  2980     lineEndCharSize := self lineEndCRLF ifTrue:[2] ifFalse:[1].
  2981 
  2981 
  2982     self checkForExistingLine:lineNr.
  2982     self checkForExistingLine:lineNr.
  2983     pos := 1.
  2983     charPos := 1.
  2984     1 to:(lineNr - 1) do:[:lnr |
  2984     1 to:(lineNr - 1) do:[:lnr |
  2985         lineString := self at:lnr.
  2985         lineString := self at:lnr.
  2986         lineString notNil ifTrue:[
  2986         lineString notNil ifTrue:[
  2987             pos := pos + (lineString string "withoutTrailingSeparators") size
  2987             charPos := charPos + (lineString string "withoutTrailingSeparators") size
  2988         ].
  2988         ].
  2989         pos := pos + lineEndCharSize   "the return-character"
  2989         charPos := charPos + lineEndCharSize   "the return-character"
  2990     ].
  2990     ].
  2991 
  2991 
  2992     "/ if beyond end of line, do not advance into next line
  2992     "/ if beyond end of line, do not advance into next line
  2993     col := colArg min:(self at:lineNr) size.
  2993     col := colArg min:(self at:lineNr) size.
  2994     ^ pos + col - 1
  2994     ^ charPos + col - 1
  2995 
  2995 
  2996     "Modified: / 04-07-2006 / 19:14:25 / fm"
  2996     "Modified: / 04-07-2006 / 19:14:25 / fm"
  2997     "Modified: / 21-08-2011 / 11:03:19 / cg"
  2997     "Modified: / 21-08-2011 / 11:03:19 / cg"
  2998 !
  2998 !
  2999 
  2999 
  4846 ! !
  4846 ! !
  4847 
  4847 
  4848 !ListView class methodsFor:'documentation'!
  4848 !ListView class methodsFor:'documentation'!
  4849 
  4849 
  4850 version_CVS
  4850 version_CVS
  4851     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.355 2012-10-23 12:59:09 cg Exp $'
  4851     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.356 2012-10-24 10:31:56 cg Exp $'
  4852 ! !
  4852 ! !