TranslateIndexToPosition given an index for the text, return the corresponding (row, col) tuple. (0-based. Returns (0, 0) for index=0.)
(index int)
| 386 | // TranslateIndexToPosition given an index for the text, return the corresponding (row, col) tuple. |
| 387 | // (0-based. Returns (0, 0) for index=0.) |
| 388 | func (d *Document) TranslateIndexToPosition(index int) (row int, col int) { |
| 389 | row, rowIndex := d.findLineStartIndex(index) |
| 390 | col = index - rowIndex |
| 391 | return |
| 392 | } |
| 393 | |
| 394 | // TranslateRowColToIndex given a (row, col), return the corresponding index. |
| 395 | // (Row and col params are 0-based.) |