本文整理汇总了C#中Mono.TextEditor.TextViewMargin类的典型用法代码示例。如果您正苦于以下问题:C# TextViewMargin类的具体用法?C# TextViewMargin怎么用?C# TextViewMargin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextViewMargin类属于Mono.TextEditor命名空间,在下文中一共展示了TextViewMargin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetErrorCountBounds
Tuple<int, int> GetErrorCountBounds (TextViewMargin.LayoutWrapper wrapper = null)
{
EnsureLayoutCreated (editor);
var layout = wrapper ?? editor.TextViewMargin.GetLayout (lineSegment);
try {
var lineTextPx = editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition + layout.PangoWidth / Pango.Scale.PangoScale;
if (errors.Count > 1 && errorCountLayout != null || editor.Allocation.Width < lineTextPx + layouts [0].Width) {
int ew = 0, eh = 0;
if (errorCountLayout != null) {
errorCountLayout.GetPixelSize (out ew, out eh);
} else {
ew = 10;
}
return Tuple.Create (ew + 10, eh);
}
return Tuple.Create (0, 0);
} finally {
if (wrapper == null && layout.IsUncached)
layout.Dispose ();
}
}
示例2: DrawBackground
public bool DrawBackground (TextEditor editor, Cairo.Context g, TextViewMargin.LayoutWrapper layout2, int selectionStart, int selectionEnd, int startOffset, int endOffset, double y, double startXPos, double endXPos, ref bool drawBg)
{
if (!IsVisible || DebuggingService.IsDebugging)
return true;
EnsureLayoutCreated (editor);
double x = editor.TextViewMargin.XOffset;
int right = editor.Allocation.Width;
int errorCounterWidth = 0;
bool isCaretInLine = startOffset <= editor.Caret.Offset && editor.Caret.Offset <= endOffset;
int ew = 0, eh = 0;
if (errors.Count > 1 && errorCountLayout != null) {
errorCountLayout.GetPixelSize (out ew, out eh);
errorCounterWidth = ew + 10;
}
double x2 = System.Math.Max (right - LayoutWidth - border - (ShowIconsInBubble ? errorPixbuf.Width : 0) - errorCounterWidth, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
bool isEolSelected = editor.IsSomethingSelected && editor.SelectionMode != SelectionMode.Block ? editor.SelectionRange.Contains (lineSegment.Offset + lineSegment.EditableLength) : false;
int active = editor.Document.GetTextAt (lineSegment) == initialText ? 0 : 1;
int highlighted = active == 0 && isCaretInLine ? 1 : 0;
int selected = 0;
double topSize = editor.LineHeight / 2;
double bottomSize = editor.LineHeight / 2 + editor.LineHeight % 2;
if (!fitsInSameLine) {
if (isEolSelected) {
x -= (int)editor.HAdjustment.Value;
editor.TextViewMargin.DrawRectangleWithRuler (g, x, new Cairo.Rectangle (x, y + editor.LineHeight, editor.TextViewMargin.TextStartPosition, editor.LineHeight), editor.ColorStyle.Default.CairoBackgroundColor, true);
editor.TextViewMargin.DrawRectangleWithRuler (g, x + editor.TextViewMargin.TextStartPosition, new Cairo.Rectangle (x + editor.TextViewMargin.TextStartPosition, y + editor.LineHeight, editor.Allocation.Width + (int)editor.HAdjustment.Value, editor.LineHeight), editor.ColorStyle.Selection.CairoBackgroundColor, true);
x += (int)editor.HAdjustment.Value;
} else {
editor.TextViewMargin.DrawRectangleWithRuler (g, x, new Cairo.Rectangle (x, y + editor.LineHeight, x2, editor.LineHeight), editor.ColorStyle.Default.CairoBackgroundColor, true);
}
}
DrawRectangle (g, x, y, right, topSize);
g.Color = colorMatrix[active, TOP, LIGHT, highlighted, selected];
g.Fill ();
DrawRectangle (g, x, y + topSize, right, bottomSize);
g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, selected];
g.Fill ();
g.MoveTo (new Cairo.PointD (x, y + 0.5));
g.LineTo (new Cairo.PointD (x + right, y + 0.5));
g.Color = colorMatrix[active, TOP, LINE, highlighted, selected];
g.Stroke ();
g.MoveTo (new Cairo.PointD (x, y + editor.LineHeight - 0.5));
g.LineTo (new Cairo.PointD ((fitsInSameLine ? x + right : x2 + 1), y + editor.LineHeight - 0.5));
g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
g.Stroke ();
if (editor.Options.ShowRuler) {
double divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
g.MoveTo (new Cairo.PointD (divider + 0.5, y));
g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, selected];
g.Stroke ();
}
// draw background
if (layout2.StartSet || selectionStart == endOffset) {
double startX;
double endX;
if (selectionStart != endOffset) {
var start = layout2.Layout.IndexToPos ((int)layout2.SelectionStartIndex);
startX = (int)(start.X / Pango.Scale.PangoScale);
var end = layout2.Layout.IndexToPos ((int)layout2.SelectionEndIndex);
endX = (int)(end.X / Pango.Scale.PangoScale);
} else {
startX = x2;
endX = startX;
}
if (editor.MainSelection.SelectionMode == SelectionMode.Block && startX == endX)
endX = startX + 2;
startX += startXPos;
endX += startXPos;
startX = Math.Max (editor.TextViewMargin.XOffset, startX);
// clip region to textviewmargin start
if (isEolSelected)
endX = editor.Allocation.Width + (int)editor.HAdjustment.Value;
if (startX < endX) {
DrawRectangle (g, startX, y, endX - startX, topSize);
g.Color = colorMatrix[active, TOP, LIGHT, highlighted, 1];
g.Fill ();
DrawRectangle (g, startX, y + topSize, endX - startX, bottomSize);
g.Color = colorMatrix[active, BOTTOM, LIGHT, highlighted, 1];
g.Fill ();
g.MoveTo (new Cairo.PointD (startX, y + 0.5));
g.LineTo (new Cairo.PointD (endX, y + 0.5));
g.Color = colorMatrix[active, TOP, LINE, highlighted, 1];
g.Stroke ();
if (startX < x2) {
g.MoveTo (new Cairo.PointD (startX, y + editor.LineHeight - 0.5));
g.LineTo (new Cairo.PointD (System.Math.Min (endX, x2 + 1), y + editor.LineHeight - 0.5));
g.Color = colorMatrix[active, BOTTOM, LINE, highlighted, 1];
g.Stroke ();
//.........这里部分代码省略.........
示例3: DrawBackground
public bool DrawBackground (TextEditor editor, Cairo.Context cr, TextViewMargin.LayoutWrapper layout, int selectionStart, int selectionEnd, int startOffset, int endOffset, double y, double startXPos, double endXPos, ref bool drawBg)
{
drawBg = false;
if (selectionStart > 0)
return true;
cr.Color = color;
cr.Rectangle (startXPos, y, endXPos - startXPos, editor.LineHeight);
cr.Fill ();
return true;
}
示例4: IsCurrentErrorTextFitting
bool IsCurrentErrorTextFitting (TextViewMargin.LayoutWrapper wrapper = null)
{
int errorCounterWidth = GetErrorCountBounds (wrapper).Item1;
double labelWidth = LayoutWidth + border + (ShowIconsInBubble ? cache.errorPixbuf.Width : 0) + errorCounterWidth + editor.LineHeight / 2;
var layout = wrapper ?? editor.TextViewMargin.GetLayout (lineSegment);
var lineTextPx = editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition + layout.PangoWidth / Pango.Scale.PangoScale;
if (wrapper == null && layout.IsUncached)
layout.Dispose ();
return labelWidth < editor.Allocation.Width - lineTextPx - editor.TextViewMargin.TextStartPosition;
}
示例5: DrawBackground
public bool DrawBackground (TextEditor editor, Cairo.Context g, TextViewMargin.LayoutWrapper layout2, int selectionStart, int selectionEnd, int startOffset, int endOffset, double startYPos, double startXPos, double endXPos, ref bool drawBg)
{
if (!IsVisible)
return true;
EnsureLayoutCreated (editor);
double x = editor.TextViewMargin.XOffset;
double y = startYPos;
int right = editor.Allocation.Width;
bool isCaretInLine = startOffset <= editor.Caret.Offset && editor.Caret.Offset <= endOffset;
var lineTextPx = editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition + layout2.PangoWidth / Pango.Scale.PangoScale;
int errorCounterWidth = GetErrorCountBounds (layout2).Item1;
// int eh = GetErrorCountBounds ().Item2;
double x2 = System.Math.Max (right - LayoutWidth - border - (ShowIconsInBubble ? cache.errorPixbuf.Width : 0) - errorCounterWidth, fitsInSameLine ? editor.TextViewMargin.XOffset + editor.LineHeight / 2 : editor.TextViewMargin.XOffset);
bool isEolSelected = editor.IsSomethingSelected && editor.SelectionMode != SelectionMode.Block ? editor.SelectionRange.Contains (lineSegment.Offset + lineSegment.Length) : false;
int active = editor.Document.GetTextAt (lineSegment) == initialText ? 0 : 1;
bool highlighted = active == 0 && isCaretInLine;
bool selected = false;
double topSize = Math.Floor (editor.LineHeight / 2);
double bottomSize = editor.LineHeight / 2 + editor.LineHeight % 2;
if (!fitsInSameLine) {
if (isEolSelected) {
x -= (int)editor.HAdjustment.Value;
editor.TextViewMargin.DrawRectangleWithRuler (g, x, new Cairo.Rectangle (x, y + editor.LineHeight, editor.TextViewMargin.TextStartPosition, editor.LineHeight), editor.ColorStyle.PlainText.Background, true);
editor.TextViewMargin.DrawRectangleWithRuler (g, x + editor.TextViewMargin.TextStartPosition, new Cairo.Rectangle (x + editor.TextViewMargin.TextStartPosition, y + editor.LineHeight, editor.Allocation.Width + (int)editor.HAdjustment.Value, editor.LineHeight), editor.ColorStyle.SelectedText.Background, true);
x += (int)editor.HAdjustment.Value;
} else {
editor.TextViewMargin.DrawRectangleWithRuler (g, x, new Cairo.Rectangle (x, y + editor.LineHeight, x2, editor.LineHeight), editor.ColorStyle.PlainText.Background, true);
}
}
DrawRectangle (g, x, y, right, topSize);
g.Color = GetLineColorTop (highlighted, selected);
g.Fill ();
DrawRectangle (g, x, y + topSize, right, bottomSize);
g.Color = GetLineColorBottom (highlighted, selected);
g.Fill ();
g.MoveTo (new Cairo.PointD (x, y + 0.5));
g.LineTo (new Cairo.PointD (x + right, y + 0.5));
g.Color = GetLineColorBorder (highlighted, selected);
g.Stroke ();
g.MoveTo (new Cairo.PointD (x, y + editor.LineHeight - 0.5));
g.LineTo (new Cairo.PointD ((fitsInSameLine ? x + right : x2 + 1), y + editor.LineHeight - 0.5));
g.Color = GetLineColorBorder (highlighted, selected);
g.Stroke ();
/*
if (editor.Options.ShowRuler) {
double divider = Math.Max (editor.TextViewMargin.XOffset, x + editor.TextViewMargin.RulerX);
g.MoveTo (new Cairo.PointD (divider + 0.5, y));
g.LineTo (new Cairo.PointD (divider + 0.5, y + editor.LineHeight));
g.Color = GetLineColorBorder (highlighted, selected);
g.Stroke ();
}*/
// draw background
if (layout2.StartSet || selectionStart == endOffset) {
double startX;
double endX;
if (selectionStart != endOffset) {
var start = layout2.Layout.IndexToPos ((int)layout2.SelectionStartIndex);
startX = (int)(start.X / Pango.Scale.PangoScale);
var end = layout2.Layout.IndexToPos ((int)layout2.SelectionEndIndex);
endX = (int)(end.X / Pango.Scale.PangoScale);
} else {
startX = x2;
endX = startX;
}
if (editor.MainSelection.SelectionMode == SelectionMode.Block && startX == endX)
endX = startX + 2;
startX += startXPos;
endX += startXPos;
startX = Math.Max (editor.TextViewMargin.XOffset, startX);
// clip region to textviewmargin start
if (isEolSelected)
endX = editor.Allocation.Width + (int)editor.HAdjustment.Value;
if (startX < endX) {
DrawRectangle (g, startX, y, endX - startX, topSize);
g.Color = GetLineColorTop (highlighted, true);
g.Fill ();
DrawRectangle (g, startX, y + topSize, endX - startX, bottomSize);
g.Color = GetLineColorBottom (highlighted, true);
g.Fill ();
g.MoveTo (new Cairo.PointD (startX, y + 0.5));
g.LineTo (new Cairo.PointD (endX, y + 0.5));
g.Color = GetLineColorBorder (highlighted, true);
g.Stroke ();
if (startX < x2) {
g.MoveTo (new Cairo.PointD (startX, y + editor.LineHeight - 0.5));
g.LineTo (new Cairo.PointD (System.Math.Min (endX, x2 + 1), y + editor.LineHeight - 0.5));
g.Color = GetLineColorBorder (highlighted, true);
g.Stroke ();
if (x2 + 1 < endX) {
//.........这里部分代码省略.........
示例6: VisualLocationTranslator
public VisualLocationTranslator (TextViewMargin margin, int xp, int yp)
{
this.margin = margin;
lineNumber = System.Math.Min (margin.textEditor.CalculateLineNumber (yp + (int)margin.textEditor.VAdjustment.Value), margin.Document.LineCount - 1);
line = lineNumber < margin.Document.LineCount ? margin.Document.GetLine (lineNumber) : null;
}
示例7: SearchBackward
public override SearchResult SearchBackward (System.ComponentModel.BackgroundWorker worker, TextViewMargin.SearchWorkerArguments args, int fromOffset)
{
if (regex == null || String.IsNullOrEmpty (searchRequest.SearchPattern))
return null;
System.Text.RegularExpressions.Match found = null;
System.Text.RegularExpressions.Match last = null;
foreach (System.Text.RegularExpressions.Match match in regex.Matches (args.Text)) {
if (match.Index < fromOffset) {
found = match;
}
last = match;
}
bool wrapped = false;
if (found == null) {
found = last;
wrapped = true;
}
if (found != null) {
return new SearchResult (found.Index, found.Length, wrapped);
}
return null;
}
示例8: SearchForward
public override SearchResult SearchForward (System.ComponentModel.BackgroundWorker worker, TextViewMargin.SearchWorkerArguments args, int fromOffset)
{
if (regex == null || String.IsNullOrEmpty (searchRequest.SearchPattern))
return null;
System.Text.RegularExpressions.Match match = regex.Match (args.Text, fromOffset);
if (match.Success) {
return new SearchResult (match.Index,
match.Length, false);
}
match = regex.Match (args.Text, 0, fromOffset);
if (match.Success) {
return new SearchResult (match.Index,
match.Length, true);
}
return null;
}
示例9: DrawBackground
public bool DrawBackground (TextEditor editor, Gdk.Drawable win, TextViewMargin.LayoutWrapper layout, int selectionStart, int selectionEnd, int startOffset, int endOffset, int y, int startXPos, int endXPos, ref bool drawBg)
{
drawBg = false;
if (selectionStart >= 0 || editor.CurrentMode is TextLinkEditMode)
return true;
foreach (ISegment usage in Usages) {
int markerStart = usage.Offset;
int markerEnd = usage.EndOffset;
if (markerEnd < startOffset || markerStart > endOffset)
return true;
int @from;
int to;
if (markerStart < startOffset && endOffset < markerEnd) {
@from = startXPos;
to = endXPos;
} else {
int start = startOffset < markerStart ? markerStart : startOffset;
int end = endOffset < markerEnd ? endOffset : markerEnd;
uint curIndex = 0, byteIndex = 0;
TextViewMargin.TranslateToUTF8Index (layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);
int x_pos = layout.Layout.IndexToPos ((int)byteIndex).X;
@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
TextViewMargin.TranslateToUTF8Index (layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
x_pos = layout.Layout.IndexToPos ((int)byteIndex).X;
to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
}
@from = System.Math.Max (@from, editor.TextViewMargin.XOffset);
to = System.Math.Max (to, editor.TextViewMargin.XOffset);
if (@from < to) {
using (Gdk.GC gc = new Gdk.GC(win)) {
gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.BackgroundColor;
win.DrawRectangle (gc, true, @from + 1, y + 1, to - @from - 1, editor.LineHeight - 2);
gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.Color;
win.DrawRectangle (gc, false, @from, y, to - @from, editor.LineHeight - 1);
}
}
}
return true;
}
示例10: DrawBackground
public bool DrawBackground (TextEditor editor, Drawable win, TextViewMargin.LayoutWrapper layout, int selectionStart, int selectionEnd, int startOffset, int endOffset, int y, int startXPos, int endXPos, ref bool drawBg)
{
drawBg = false;
if (selectionStart > 0)
return true;
using (Gdk.GC gc = new Gdk.GC (win)) {
gc.RgbFgColor = color;
win.DrawRectangle (gc, true, startXPos, y, endXPos - startXPos, editor.LineHeight);
}
return true;
}
示例11: DrawBackground
public bool DrawBackground (TextEditor editor, Cairo.Context cr, TextViewMargin.LayoutWrapper layout, int selectionStart, int selectionEnd, int startOffset, int endOffset, double y, double startXPos, double endXPos, ref bool drawBg)
{
drawBg = false;
if (selectionStart >= 0 || editor.CurrentMode is TextLinkEditMode)
return true;
foreach (ISegment usage in Usages) {
int markerStart = usage.Offset;
int markerEnd = usage.EndOffset;
if (markerEnd < startOffset || markerStart > endOffset)
return true;
double @from;
double to;
if (markerStart < startOffset && endOffset < markerEnd) {
@from = startXPos;
to = endXPos;
} else {
int start = startOffset < markerStart ? markerStart : startOffset;
int end = endOffset < markerEnd ? endOffset : markerEnd;
uint curIndex = 0, byteIndex = 0;
TextViewMargin.TranslateToUTF8Index (layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);
int x_pos = layout.Layout.IndexToPos ((int)byteIndex).X;
@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
TextViewMargin.TranslateToUTF8Index (layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
x_pos = layout.Layout.IndexToPos ((int)byteIndex).X;
to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
}
@from = System.Math.Max (@from, editor.TextViewMargin.XOffset);
to = System.Math.Max (to, editor.TextViewMargin.XOffset);
if (@from < to) {
cr.Color = (HslColor)editor.ColorStyle.BracketHighlightRectangle.BackgroundColor;
cr.Rectangle (@from + 1, y + 1, to - @from - 1, editor.LineHeight - 2);
cr.Fill ();
cr.Color = (HslColor)editor.ColorStyle.BracketHighlightRectangle.Color;
cr.Rectangle (@from, y, to - @from, editor.LineHeight - 1);
cr.Fill ();
}
}
return true;
}
示例12: DrawErrorMarkers
void DrawErrorMarkers (TextEditor editor, Cairo.Context g, TextViewMargin.LayoutWrapper layout2, double x, double y)
{
uint curIndex = 0, byteIndex = 0;
foreach (var task in errors.Select (t => t.Task)) {
int index = (int)layout2.TranslateToUTF8Index ((uint)(task.Column - 1), ref curIndex, ref byteIndex);
var pos = layout2.Layout.IndexToPos (index);
g.Color = MarkerColor.Color;
g.MoveTo (
x + editor.TextViewMargin.TextStartPosition + pos.X / Pango.Scale.PangoScale,
y + editor.LineHeight - 4
);
g.RelLineTo (3, 3);
g.RelLineTo (-6, 0);
g.ClosePath ();
g.Fill ();
}
}
示例13: VisualLocationTranslator
public VisualLocationTranslator (TextViewMargin margin)
{
this.margin = margin;
}
示例14: QuickTaskOverviewMode
public QuickTaskOverviewMode (QuickTaskStrip parent)
{
this.parentStrip = parent;
Events |= EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.ButtonMotionMask |
EventMask.PointerMotionMask | EventMask.LeaveNotifyMask | EventMask.EnterNotifyMask;
vadjustment = this.parentStrip.VAdjustment;
vadjustment.ValueChanged += RedrawOnVAdjustmentChange;
vadjustment.Changed += RedrawOnVAdjustmentChange;
parentStrip.TaskProviderUpdated += RedrawOnUpdate;
TextEditor = parent.TextEditor;
caret = TextEditor.Caret;
// caret.PositionChanged += CaretPositionChanged;
TextEditor.HighlightSearchPatternChanged += RedrawOnUpdate;
textViewMargin = TextEditor.TextViewMargin;
textViewMargin.SearchRegionsUpdated += RedrawOnUpdate;
textViewMargin.MainSearchResultChanged += RedrawOnUpdate;
heightTree = TextEditor.GetTextEditorData ().HeightTree;
heightTree.LineUpdateFrom += HandleLineUpdateFrom;
TextEditor.HighlightSearchPatternChanged += HandleHighlightSearchPatternChanged;
HasTooltip = true;
fadeInStage.ActorStep += delegate (Actor<QuickTaskOverviewMode> actor) {
barColorValue = actor.Percent;
return true;
};
fadeInStage.Iteration += (sender, e) => QueueDraw ();
fadeOutStage.ActorStep += delegate (Actor<QuickTaskOverviewMode> actor) {
barColorValue = 1 - actor.Percent;
return true;
};
fadeOutStage.Iteration += (sender, e) => QueueDraw ();
fadeInStage.UpdateFrequency = fadeOutStage.UpdateFrequency = 10;
}
示例15: OnDestroyed
protected override void OnDestroyed ()
{
DestroyBackgroundSurface ();
RemoveIndicatorIdleHandler ();
DestroyIndicatorSwapSurface ();
DestroyIndicatorSurface ();
CancelFadeInTimeout ();
RemovePreviewPopupTimeout ();
DestroyPreviewWindow ();
if (caret != null) {
caret.PositionChanged -= CaretPositionChanged;
caret = null;
}
TextEditor.HighlightSearchPatternChanged -= HandleHighlightSearchPatternChanged;
if (heightTree != null) {
heightTree.LineUpdateFrom -= HandleLineUpdateFrom;
heightTree = null;
}
TextEditor.HighlightSearchPatternChanged -= RedrawOnUpdate;
textViewMargin.SearchRegionsUpdated -= RedrawOnUpdate;
textViewMargin.MainSearchResultChanged -= RedrawOnUpdate;
textViewMargin = null;
parentStrip.TaskProviderUpdated -= RedrawOnUpdate;
vadjustment.ValueChanged -= RedrawOnVAdjustmentChange;
vadjustment.Changed -= RedrawOnVAdjustmentChange;
base.OnDestroyed ();
}