public IEnumerable<Chunk> GetChunks (DocumentLine line, int offset, int length) { return document.SyntaxMode.GetChunks (ColorStyle, line, offset, length); }
// for markup syntax mode the syntax highlighting information need to be taken into account // when calculating the selection offsets. static int PosToOffset(TextEditorData data, DocumentLocation loc) { DocumentLine line = data.GetLine(loc.Line); if (line == null) { return(0); } var startChunk = data.GetChunks(line, line.Offset, line.LengthIncludingDelimiter); int col = 1; foreach (var chunk in startChunk) { if (col <= loc.Column && loc.Column < col + chunk.Length) { return(chunk.Offset - col + loc.Column); } col += chunk.Length; } return(line.Offset + line.Length); }