public double ColumnToX (DocumentLine line, int column)
{
column--;
// calculate virtual indentation
if (column > 0 && line.Length == 0 && textEditor.GetTextEditorData ().HasIndentationTracker) {
using (var l = textEditor.LayoutCache.RequestLayout ()) {
l.SetText (textEditor.GetTextEditorData ().IndentationTracker.GetIndentationString (line.Offset));
l.Alignment = Pango.Alignment.Left;
l.FontDescription = textEditor.Options.Font;
l.Tabs = tabArray;
Pango.Rectangle ink_rect, logical_rect;
l.GetExtents (out ink_rect, out logical_rect);
return (logical_rect.Width + Pango.Scale.PangoScale - 1) / Pango.Scale.PangoScale;
}
}
if (line == null || line.Length == 0 || column < 0)
return 0;
var wrapper = GetLayout (line);
uint curIndex = 0;
uint byteIndex = 0;
int index;
try {
index = (int)TranslateToUTF8Index (wrapper.LineChars, (uint)System.Math.Min (System.Math.Max (0, column), wrapper.LineChars.Length), ref curIndex, ref byteIndex);
} catch {
return 0;
}
var pos = wrapper.Layout.IndexToPos (index);
if (wrapper.IsUncached)
wrapper.Dispose ();
return (pos.X + Pango.Scale.PangoScale - 1) / Pango.Scale.PangoScale;
}