本文整理汇总了C#中Mono.TextEditor.LineSegment.GetLogicalColumn方法的典型用法代码示例。如果您正苦于以下问题:C# LineSegment.GetLogicalColumn方法的具体用法?C# LineSegment.GetLogicalColumn怎么用?C# LineSegment.GetLogicalColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.TextEditor.LineSegment
的用法示例。
在下文中一共展示了LineSegment.GetLogicalColumn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSelectionOffsets
void GetSelectionOffsets (LineSegment line, out int selectionStart, out int selectionEnd)
{
selectionStart = -1;
selectionEnd = -1;
if (textEditor.IsSomethingSelected) {
TextSegment segment = textEditor.SelectionRange;
selectionStart = segment.Offset;
selectionEnd = segment.EndOffset;
if (textEditor.SelectionMode == SelectionMode.Block) {
DocumentLocation start = textEditor.MainSelection.Anchor;
DocumentLocation end = textEditor.MainSelection.Lead;
DocumentLocation visStart = textEditor.LogicalToVisualLocation (start);
DocumentLocation visEnd = textEditor.LogicalToVisualLocation (end);
int lineOffset = line.Offset;
int lineNumber = Document.OffsetToLineNumber (lineOffset);
if (textEditor.MainSelection.MinLine <= lineNumber && lineNumber <= textEditor.MainSelection.MaxLine) {
selectionStart = lineOffset + line.GetLogicalColumn (this.textEditor.GetTextEditorData (), System.Math.Min (visStart.Column, visEnd.Column)) - 1;
selectionEnd = lineOffset + line.GetLogicalColumn (this.textEditor.GetTextEditorData (), System.Math.Max (visStart.Column, visEnd.Column)) - 1;
}
}
}
}
示例2: CreateLinePartLayout
public LayoutWrapper CreateLinePartLayout (ISyntaxMode mode, LineSegment line, int logicalRulerColumn, int offset, int length, int selectionStart, int selectionEnd)
{
bool containsPreedit = textEditor.ContainsPreedit (offset, length);
LayoutDescriptor descriptor;
if (!containsPreedit && layoutDict.TryGetValue (line, out descriptor)) {
bool isInvalid;
if (descriptor.Equals (line, offset, length, selectionStart, selectionEnd, out isInvalid) && descriptor.Layout != null) {
return descriptor.Layout;
}
descriptor.Dispose ();
layoutDict.Remove (line);
}
var wrapper = new LayoutWrapper (PangoUtil.CreateLayout (textEditor));
wrapper.IsUncached = containsPreedit;
if (logicalRulerColumn < 0)
logicalRulerColumn = line.GetLogicalColumn (textEditor.GetTextEditorData (), textEditor.Options.RulerColumn);
var atts = new FastPangoAttrList ();
wrapper.Layout.Alignment = Pango.Alignment.Left;
wrapper.Layout.FontDescription = textEditor.Options.Font;
wrapper.Layout.Tabs = tabArray;
StringBuilder textBuilder = new StringBuilder ();
var chunks = GetCachedChunks (mode, Document, textEditor.ColorStyle, line, offset, length);
foreach (var chunk in chunks) {
try {
textBuilder.Append (Document.GetTextAt (chunk));
} catch {
Console.WriteLine (chunk);
}
}
var spanStack = line.StartSpan;
int lineOffset = line.Offset;
string lineText = textBuilder.ToString ();
uint preeditLength = 0;
if (containsPreedit) {
lineText = lineText.Insert (textEditor.preeditOffset - offset, textEditor.preeditString);
preeditLength = (uint)textEditor.preeditString.Length;
}
char[] lineChars = lineText.ToCharArray ();
//int startOffset = offset, endOffset = offset + length;
uint curIndex = 0, byteIndex = 0;
uint curChunkIndex = 0, byteChunkIndex = 0;
uint oldEndIndex = 0;
foreach (Chunk chunk in chunks) {
ChunkStyle chunkStyle = chunk != null ? textEditor.ColorStyle.GetChunkStyle (chunk) : null;
spanStack = chunk.SpanStack ?? spanStack;
foreach (TextMarker marker in line.Markers)
chunkStyle = marker.GetStyle (chunkStyle);
if (chunkStyle != null) {
//startOffset = chunk.Offset;
//endOffset = chunk.EndOffset;
uint startIndex = (uint)(oldEndIndex);
uint endIndex = (uint)(startIndex + chunk.Length);
oldEndIndex = endIndex;
HandleSelection (lineOffset, logicalRulerColumn, selectionStart, selectionEnd, chunk.Offset, chunk.EndOffset, delegate(int start, int end) {
if (containsPreedit) {
if (textEditor.preeditOffset < start)
start += (int)preeditLength;
if (textEditor.preeditOffset < end)
end += (int)preeditLength;
}
var si = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex);
var ei = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex);
atts.AddForegroundAttribute (chunkStyle.Color, si, ei);
if (!chunkStyle.TransparentBackround && GetPixel (ColorStyle.Default.BackgroundColor) != GetPixel (chunkStyle.BackgroundColor)) {
wrapper.AddBackground (chunkStyle.CairoBackgroundColor, (int)si, (int)ei);
} else if (chunk.SpanStack != null && ColorStyle != null) {
foreach (var span in chunk.SpanStack) {
if (span == null)
continue;
var spanStyle = ColorStyle.GetChunkStyle (span.Color);
if (!spanStyle.TransparentBackround && GetPixel (ColorStyle.Default.BackgroundColor) != GetPixel (spanStyle.BackgroundColor)) {
wrapper.AddBackground (spanStyle.CairoBackgroundColor, (int)si, (int)ei);
break;
}
}
}
}, delegate(int start, int end) {
if (containsPreedit) {
if (textEditor.preeditOffset < start)
start += (int)preeditLength;
if (textEditor.preeditOffset < end)
end += (int)preeditLength;
}
var si = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex);
var ei = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex);
atts.AddForegroundAttribute (SelectionColor.Color, si, ei);
if (!wrapper.StartSet)
wrapper.SelectionStartIndex = (int)si;
wrapper.SelectionEndIndex = (int)ei;
});
var translatedStartIndex = TranslateToUTF8Index (lineChars, (uint)startIndex, ref curChunkIndex, ref byteChunkIndex);
var translatedEndIndex = TranslateToUTF8Index (lineChars, (uint)endIndex, ref curChunkIndex, ref byteChunkIndex);
//.........这里部分代码省略.........
示例3: ColumnToX
public double ColumnToX (LineSegment line, int column)
{
column--;
if (line == null || line.Length == 0 || column < 0)
return 0;
int logicalRulerColumn = line.GetLogicalColumn (textEditor.GetTextEditorData (), textEditor.Options.RulerColumn);
int lineOffset = line.Offset;
StringBuilder textBuilder = new StringBuilder ();
ISyntaxMode mode = Document.SyntaxMode != null && textEditor.Options.EnableSyntaxHighlighting ? Document.SyntaxMode : new SyntaxMode (Document);
var startChunk = GetCachedChunks (mode, Document, textEditor.ColorStyle, line, lineOffset, line.Length);
foreach (Chunk chunk in startChunk) {
try {
textBuilder.Append (Document.GetTextAt (chunk));
} catch (Exception e) {
Console.WriteLine (e);
return 0;
}
}
string lineText = textBuilder.ToString ();
char[] lineChars = lineText.ToCharArray ();
bool containsPreedit = textEditor.ContainsPreedit (lineOffset, line.Length);
uint preeditLength = 0;
if (containsPreedit) {
lineText = lineText.Insert (textEditor.preeditOffset - lineOffset, textEditor.preeditString);
preeditLength = (uint)textEditor.preeditString.Length;
}
if (column < lineText.Length)
lineText = lineText.Substring (0, column);
var layout = PangoUtil.CreateLayout (textEditor, lineText);
layout.Alignment = Pango.Alignment.Left;
layout.FontDescription = textEditor.Options.Font;
layout.Tabs = tabArray;
int startOffset = lineOffset, endOffset = lineOffset + line.Length;
uint curIndex = 0, byteIndex = 0;
uint curChunkIndex = 0, byteChunkIndex = 0;
List<Pango.Attribute> attributes = new List<Pango.Attribute> ();
uint oldEndIndex = 0;
foreach (Chunk chunk in startChunk) {
ChunkStyle chunkStyle = chunk != null ? textEditor.ColorStyle.GetChunkStyle (chunk) : null;
foreach (TextMarker marker in line.Markers)
chunkStyle = marker.GetStyle (chunkStyle);
if (chunkStyle != null) {
startOffset = chunk.Offset;
endOffset = chunk.EndOffset;
uint startIndex = (uint)(oldEndIndex);
uint endIndex = (uint)(startIndex + chunk.Length);
oldEndIndex = endIndex;
if (containsPreedit) {
if (textEditor.preeditOffset < startOffset)
startIndex += preeditLength;
if (textEditor.preeditOffset < endOffset)
endIndex += preeditLength;
}
HandleSelection (lineOffset, logicalRulerColumn, - 1, -1, chunk.Offset, chunk.EndOffset, delegate(int start, int end) {
Pango.AttrForeground foreGround = new Pango.AttrForeground (chunkStyle.Color.Red, chunkStyle.Color.Green, chunkStyle.Color.Blue);
foreGround.StartIndex = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex);
foreGround.EndIndex = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex);
attributes.Add (foreGround);
if (!chunkStyle.TransparentBackround) {
var background = new Pango.AttrBackground (chunkStyle.BackgroundColor.Red, chunkStyle.BackgroundColor.Green, chunkStyle.BackgroundColor.Blue);
background.StartIndex = foreGround.StartIndex;
background.EndIndex = foreGround.EndIndex;
attributes.Add (background);
}
}, delegate(int start, int end) {
Pango.AttrForeground selectedForeground = new Pango.AttrForeground (SelectionColor.Color.Red, SelectionColor.Color.Green, SelectionColor.Color.Blue);
selectedForeground.StartIndex = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex);
selectedForeground.EndIndex = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex);
attributes.Add (selectedForeground);
});
var translatedStartIndex = TranslateToUTF8Index (lineChars, (uint)startIndex, ref curChunkIndex, ref byteChunkIndex);
var translatedEndIndex = TranslateToUTF8Index (lineChars, (uint)endIndex, ref curChunkIndex, ref byteChunkIndex);
if (chunkStyle.Bold) {
Pango.AttrWeight attrWeight = new Pango.AttrWeight (Pango.Weight.Bold);
attrWeight.StartIndex = translatedStartIndex;
attrWeight.EndIndex = translatedEndIndex;
attributes.Add (attrWeight);
}
if (chunkStyle.Italic) {
Pango.AttrStyle attrStyle = new Pango.AttrStyle (Pango.Style.Italic);
attrStyle.StartIndex = translatedStartIndex;
attrStyle.EndIndex = translatedEndIndex;
attributes.Add (attrStyle);
}
if (chunkStyle.Underline) {
Pango.AttrUnderline attrUnderline = new Pango.AttrUnderline (Pango.Underline.Single);
attrUnderline.StartIndex = translatedStartIndex;
//.........这里部分代码省略.........
示例4: PointToLocation
public DocumentLocation PointToLocation (double xp, double yp)
{
lineNumber = System.Math.Min (margin.YToLine (yp + margin.textEditor.VAdjustment.Value), margin.Document.LineCount);
line = lineNumber <= margin.Document.LineCount ? margin.Document.GetLine (lineNumber) : null;
if (line == null)
return DocumentLocation.Empty;
int offset = line.Offset;
yp = ((int)yp % margin.LineHeight);
xp -= margin.TextStartPosition;
xp += margin.textEditor.HAdjustment.Value;
xp *= Pango.Scale.PangoScale;
yp *= Pango.Scale.PangoScale;
yp = System.Math.Max (0, yp);
if (xp < 0)
return new DocumentLocation (lineNumber, DocumentLocation.MinColumn);
int column = DocumentLocation.MinColumn;
ISyntaxMode mode = margin.Document.SyntaxMode != null && margin.textEditor.Options.EnableSyntaxHighlighting ? margin.Document.SyntaxMode : new SyntaxMode (margin.Document);
IEnumerable<FoldSegment> foldings = margin.Document.GetStartFoldings (line);
bool done = false;
Pango.Layout measueLayout = null;
restart:
int logicalRulerColumn = line.GetLogicalColumn(margin.textEditor.GetTextEditorData(), margin.textEditor.Options.RulerColumn);
foreach (FoldSegment folding in foldings.Where(f => f.IsFolded))
{
int foldOffset = folding.StartLine.Offset + folding.Column - 1;
if (foldOffset < offset)
continue;
layoutWrapper = margin.CreateLinePartLayout(mode, line, logicalRulerColumn, line.Offset, foldOffset - offset, -1, -1);
done |= ConsumeLayout ((int)(xp - xPos), (int)yp);
if (done)
break;
int height, width;
layoutWrapper.Layout.GetPixelSize (out width, out height);
xPos += width * (int)Pango.Scale.PangoScale;
if (measueLayout == null) {
measueLayout = PangoUtil.CreateLayout (margin.textEditor, folding.Description);
measueLayout.FontDescription = margin.textEditor.Options.Font;
}
int delta;
measueLayout.GetPixelSize (out delta, out height);
delta *= (int)Pango.Scale.PangoScale;
xPos += delta;
if (xPos - delta / 2 >= xp) {
index = foldOffset - offset;
done = true;
break;
}
offset = folding.EndLine.Offset + folding.EndColumn;
DocumentLocation foldingEndLocation = margin.Document.OffsetToLocation(offset);
lineNumber = foldingEndLocation.Line;
column = foldingEndLocation.Column;
if (xPos >= xp) {
index = 0;
done = true;
break;
}
if (folding.EndLine != line) {
line = folding.EndLine;
foldings = margin.Document.GetStartFoldings (line);
goto restart;
}
}
if (!done) {
layoutWrapper = margin.CreateLinePartLayout(mode, line, logicalRulerColumn, offset, line.Offset + line.Length - offset, -1, -1);
ConsumeLayout ((int)(xp - xPos), (int)yp);
}
if (measueLayout != null)
measueLayout.Dispose ();
return new DocumentLocation (lineNumber, column + index);
}
示例5: Draw
protected internal override void Draw (Cairo.Context cr, Cairo.Rectangle area, LineSegment line, int lineNr, double x, double y, double _lineHeight)
{
// double xStart = System.Math.Max (area.X, XOffset);
// xStart = System.Math.Max (0, xStart);
var lineArea = new Cairo.Rectangle (XOffset - 1, y, textEditor.Allocation.Width - XOffset + 1, _lineHeight);
int width, height;
double pangoPosition = (x - textEditor.HAdjustment.Value + TextStartPosition) * Pango.Scale.PangoScale;
defaultBgColor = Document.ReadOnly ? ColorStyle.ReadOnlyTextBg : ColorStyle.Default.CairoBackgroundColor;
// Draw the default back color for the whole line. Colors other than the default
// background will be drawn when rendering the text chunks.
DrawRectangleWithRuler (cr, x, lineArea, defaultBgColor, true);
bool isSelectionDrawn = false;
if (BackgroundRenderer != null)
BackgroundRenderer.Draw (cr, area, line, x, y, _lineHeight);
// Check if line is beyond the document length
if (line == null) {
if (textEditor.Options.ShowInvalidLines)
DrawInvalidLineMarker (cr, pangoPosition / Pango.Scale.PangoScale, y);
var marker = Document.GetExtendingTextMarker (lineNr);
if (marker != null)
marker.Draw (textEditor, cr, lineNr, lineArea);
return;
}
IEnumerable<FoldSegment> foldings = Document.GetStartFoldings (line);
int offset = line.Offset;
int caretOffset = Caret.Offset;
bool isEolFolded = false;
restart:
int logicalRulerColumn = line.GetLogicalColumn (textEditor.GetTextEditorData (), textEditor.Options.RulerColumn);
foreach (FoldSegment folding in foldings) {
int foldOffset = folding.StartLine.Offset + folding.Column - 1;
if (foldOffset < offset)
continue;
if (folding.IsFolded) {
DrawLinePart (cr, line, lineNr, logicalRulerColumn, offset, foldOffset - offset, ref pangoPosition, ref isSelectionDrawn, y, area.X + area.Width);
offset = folding.EndLine.Offset + folding.EndColumn;
markerLayout.SetText (folding.Description);
markerLayout.GetSize (out width, out height);
bool isFoldingSelected = !this.HideSelection && textEditor.IsSomethingSelected && textEditor.SelectionRange.Contains (folding.Segment);
double pixelX = pangoPosition / Pango.Scale.PangoScale;
double pixelWidth = (pangoPosition + width) / Pango.Scale.PangoScale - pixelX;
var foldingRectangle = new Cairo.Rectangle (pixelX + 0.5, y + 0.5, pixelWidth - cr.LineWidth, this.LineHeight - cr.LineWidth);
if (BackgroundRenderer == null) {
cr.Color = isFoldingSelected ? SelectionColor.CairoBackgroundColor : defaultBgColor;
cr.Rectangle (foldingRectangle);
cr.Fill ();
}
cr.Color = isFoldingSelected ? SelectionColor.CairoColor : ColorStyle.FoldLine.CairoColor;
cr.Rectangle (foldingRectangle);
cr.Stroke ();
cr.Save ();
cr.Translate (pangoPosition / Pango.Scale.PangoScale, y);
cr.Color = isFoldingSelected ? SelectionColor.CairoColor : ColorStyle.FoldLine.CairoColor;
cr.ShowLayout (markerLayout);
cr.Restore ();
if (caretOffset == foldOffset && !string.IsNullOrEmpty (folding.Description))
SetVisibleCaretPosition ((int)(pangoPosition / Pango.Scale.PangoScale), y);
pangoPosition += width;
if (caretOffset == foldOffset + folding.Length && !string.IsNullOrEmpty (folding.Description))
SetVisibleCaretPosition ((int)(pangoPosition / Pango.Scale.PangoScale), y);
if (folding.EndLine != line) {
line = folding.EndLine;
lineNr = Document.OffsetToLineNumber (line.Offset);
foldings = Document.GetStartFoldings (line);
isEolFolded = line.Length <= folding.EndColumn;
goto restart;
}
isEolFolded = line.Length <= folding.EndColumn;
}
}
// Draw remaining line - must be called for empty line parts as well because the caret may be at this positon
// and the caret position is calculated in DrawLinePart.
if (line.EndOffsetIncludingDelimiter - offset >= 0)
DrawLinePart (cr, line, lineNr, logicalRulerColumn, offset, line.Offset + line.Length - offset, ref pangoPosition, ref isSelectionDrawn, y, area.X + area.Width);
bool isEolSelected = !this.HideSelection && textEditor.IsSomethingSelected && textEditor.SelectionMode == SelectionMode.Normal && textEditor.SelectionRange.Contains (line.Offset + line.Length);
lineArea = new Cairo.Rectangle (pangoPosition / Pango.Scale.PangoScale,
lineArea.Y,
textEditor.Allocation.Width - pangoPosition / Pango.Scale.PangoScale,
lineArea.Height);
if (textEditor.SelectionMode == SelectionMode.Block && textEditor.IsSomethingSelected && textEditor.SelectionRange.Contains (line.Offset + line.Length)) {
DocumentLocation start = textEditor.MainSelection.Anchor;
DocumentLocation end = textEditor.MainSelection.Lead;
//.........这里部分代码省略.........
示例6: HandleSelection
void HandleSelection (LineSegment line, int selectionStart, int selectionEnd, int startOffset, int endOffset, HandleSelectionDelegate handleNotSelected, HandleSelectionDelegate handleSelected)
{
int selectionStartColumn = selectionStart - line.Offset;
int selectionEndColumn = selectionEnd - line.Offset;
int logicalRulerColumn = line.GetLogicalColumn (textEditor.GetTextEditorData (), textEditor.Options.RulerColumn);
int rulerOffset = line.Offset + logicalRulerColumn;
if (textEditor.Options.ShowRuler && selectionStartColumn < logicalRulerColumn && logicalRulerColumn < selectionEndColumn && startOffset < rulerOffset && rulerOffset < endOffset) {
InternalHandleSelection (selectionStart, selectionEnd, startOffset, rulerOffset, handleNotSelected, handleSelected);
InternalHandleSelection (selectionStart, selectionEnd, rulerOffset, endOffset, handleNotSelected, handleSelected);
} else {
InternalHandleSelection (selectionStart, selectionEnd, startOffset, endOffset, handleNotSelected, handleSelected);
}
}
示例7: CreateLinePartLayout
public LayoutWrapper CreateLinePartLayout (SyntaxMode mode, LineSegment line, int logicalRulerColumn, int offset, int length, int selectionStart, int selectionEnd)
{
return GetCachedLayout (line, offset, length, selectionStart, selectionEnd, delegate(LayoutWrapper wrapper) {
if (logicalRulerColumn < 0)
logicalRulerColumn = line.GetLogicalColumn(textEditor.GetTextEditorData(), textEditor.Options.RulerColumn);
var atts = new FastPangoAttrList ();
wrapper.Layout.Alignment = Pango.Alignment.Left;
wrapper.Layout.FontDescription = textEditor.Options.Font;
wrapper.Layout.Tabs = tabArray;
StringBuilder textBuilder = new StringBuilder ();
Chunk startChunk = GetCachedChunks (mode, Document, textEditor.ColorStyle, line, offset, length);
for (Chunk chunk = startChunk; chunk != null; chunk = chunk != null ? chunk.Next : null) {
try {
textBuilder.Append (chunk.GetText (Document));
} catch {
Console.WriteLine (chunk);
}
}
var spanStack = line.StartSpan;
int lineOffset = line.Offset;
string lineText = textBuilder.ToString ();
bool containsPreedit = !string.IsNullOrEmpty (textEditor.preeditString) && offset <= textEditor.preeditOffset && textEditor.preeditOffset <= offset + length;
uint preeditLength = 0;
if (containsPreedit) {
lineText = lineText.Insert (textEditor.preeditOffset - offset, textEditor.preeditString);
preeditLength = (uint)textEditor.preeditString.Length;
}
char[] lineChars = lineText.ToCharArray ();
//int startOffset = offset, endOffset = offset + length;
uint curIndex = 0, byteIndex = 0;
uint curChunkIndex = 0, byteChunkIndex = 0;
uint oldEndIndex = 0;
for (Chunk chunk = startChunk; chunk != null; chunk = chunk != null ? chunk.Next : null) {
ChunkStyle chunkStyle = chunk != null ? chunk.GetChunkStyle (textEditor.ColorStyle) : null;
spanStack = chunk.SpanStack ?? spanStack;
foreach (TextMarker marker in line.Markers)
chunkStyle = marker.GetStyle (chunkStyle);
if (chunkStyle != null) {
//startOffset = chunk.Offset;
//endOffset = chunk.EndOffset;
uint startIndex = (uint)(oldEndIndex);
uint endIndex = (uint)(startIndex + chunk.Length);
oldEndIndex = endIndex;
HandleSelection(lineOffset, logicalRulerColumn, selectionStart, selectionEnd, chunk.Offset, chunk.EndOffset, delegate(int start, int end) {
if (containsPreedit) {
if (textEditor.preeditOffset < start)
start += (int)preeditLength;
if (textEditor.preeditOffset < end)
end += (int)preeditLength;
}
var si = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex);
var ei = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex);
atts.AddForegroundAttribute (chunkStyle.Color, si, ei);
if (!chunkStyle.TransparentBackround && GetPixel (ColorStyle.Default.BackgroundColor) != GetPixel (chunkStyle.BackgroundColor)) {
wrapper.AddBackground (chunkStyle.CairoBackgroundColor, (int)si, (int)ei);
} else if (chunk.SpanStack != null && ColorStyle != null) {
foreach (var span in chunk.SpanStack) {
if (span == null)
continue;
var spanStyle = ColorStyle.GetChunkStyle (span.Color);
if (!spanStyle.TransparentBackround && GetPixel (ColorStyle.Default.BackgroundColor) != GetPixel (spanStyle.BackgroundColor)) {
wrapper.AddBackground (spanStyle.CairoBackgroundColor, (int)si, (int)ei);
break;
}
}
}
}, delegate(int start, int end) {
if (containsPreedit) {
if (textEditor.preeditOffset < start)
start += (int)preeditLength;
if (textEditor.preeditOffset < end)
end += (int)preeditLength;
}
var si = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex);
var ei = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex);
atts.AddForegroundAttribute (SelectionColor.Color, si, ei);
if (!wrapper.StartSet)
wrapper.SelectionStartIndex = (int)si;
wrapper.SelectionEndIndex = (int)ei;
});
var translatedStartIndex = TranslateToUTF8Index (lineChars, (uint)startIndex, ref curChunkIndex, ref byteChunkIndex);
var translatedEndIndex = TranslateToUTF8Index (lineChars, (uint)endIndex, ref curChunkIndex, ref byteChunkIndex);
if (chunkStyle.Bold)
atts.AddWeightAttribute (Pango.Weight.Bold, translatedStartIndex, translatedEndIndex);
if (chunkStyle.Italic)
atts.AddStyleAttribute (Pango.Style.Italic, translatedStartIndex, translatedEndIndex);
if (chunkStyle.Underline)
atts.AddUnderlineAttribute (Pango.Underline.Single, translatedStartIndex, translatedEndIndex);
}
}
//.........这里部分代码省略.........