(pos int)
| 33 | } |
| 34 | |
| 35 | func (f File) Position(pos int) Position { |
| 36 | if pos < 0 { |
| 37 | return Position{-1, -1, -1, -1} |
| 38 | } |
| 39 | offset := pos - f.start |
| 40 | i := searchLine(f.lines, offset) |
| 41 | if i < 0 { |
| 42 | return Position{-1, -1, -1, -1} |
| 43 | } |
| 44 | return Position{ |
| 45 | Pos: pos, |
| 46 | Offset: offset, |
| 47 | Line: i + 1, |
| 48 | Column: offset - f.lines[i] + 1, |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func (f File) LineOfPos(src string, pos int) string { |
| 53 | i := searchLine(f.lines, pos-f.start) |