public GetChunks ( Mono.TextEditor.DocumentLine line, int offset, int length ) : IEnumerable |
||
line | Mono.TextEditor.DocumentLine | |
offset | int | |
length | int | |
return | IEnumerable |
// 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); }
// for markup syntax mode the syntax highlighting information need to be taken into account // when calculating the selection offsets. int PosToOffset (TextEditorData data, DocumentLocation loc) { LineSegment line = data.GetLine (loc.Line); if (line == null) return 0; var startChunk = data.GetChunks (line, line.Offset, line.LengthIncludingDelimiter); int col = 1; foreach (Chunk 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; }