本文整理汇总了C#中Mono.TextEditor.FoldSegment类的典型用法代码示例。如果您正苦于以下问题:C# FoldSegment类的具体用法?C# FoldSegment怎么用?C# FoldSegment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FoldSegment类属于Mono.TextEditor命名空间,在下文中一共展示了FoldSegment类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AddMarker
FoldSegment AddMarker (List<FoldSegment> foldSegments, string text, DomRegion region, FoldingType type)
{
Document document = textEditorData.Document;
if (document == null || region.BeginLine <= 0 || region.EndLine <= 0 || region.BeginLine > document.LineCount || region.EndLine > document.LineCount)
return null;
int startOffset = document.LocationToOffset (region.BeginLine, region.BeginColumn);
int endOffset = document.LocationToOffset (region.EndLine, region.EndColumn );
FoldSegment result = new FoldSegment (document, text, startOffset, endOffset - startOffset, type);
foldSegments.Add (result);
return result;
}
开发者ID:telebovich,项目名称:monodevelop,代码行数:14,代码来源:SourceEditorWidget.cs
示例2: RemoveFolding
void RemoveFolding (FoldSegment folding)
{
folding.isAttached = false;
if (folding.isFolded)
foldedSegments.Remove (folding);
foldSegmentTree.Remove (folding);
}
开发者ID:telebovich,项目名称:monodevelop,代码行数:7,代码来源:TextDocument.cs
示例3: GetLineCount
public int GetLineCount (FoldSegment segment)
{
return segment.EndLine.LineNumber - segment.StartLine.LineNumber;
}
开发者ID:telebovich,项目名称:monodevelop,代码行数:4,代码来源:TextDocument.cs
示例4: GetLineCount
public int GetLineCount (FoldSegment segment)
{
return OffsetToLineNumber(segment.EndLine.Offset) - OffsetToLineNumber(segment.StartLine.Offset);
}
开发者ID:kangaroo,项目名称:monodevelop,代码行数:4,代码来源:Document.cs
示例5: Create
public static TextEditorData Create(string content, ITextEditorOptions options = null)
{
var data = new TextEditorData ();
data.Options.DefaultEolMarker = eolMarker;
data.Options.IndentStyle = IndentStyle.Smart;
if (options != null)
data.Options = options;
var sb = new StringBuilder ();
int caretIndex = -1, selectionStart = -1, selectionEnd = -1;
var foldSegments = new List<FoldSegment> ();
var foldStack = new Stack<FoldSegment> ();
for (int i = 0; i < content.Length; i++) {
var ch = content [i];
switch (ch) {
case '$':
caretIndex = sb.Length;
break;
case '<':
if (i + 1 < content.Length) {
if (content [i + 1] == '-') {
selectionStart = sb.Length;
i++;
break;
}
}
goto default;
case '-':
if (i + 1 < content.Length) {
var next = content [i + 1];
if (next == '>') {
selectionEnd = sb.Length;
i++;
break;
}
if (next == '[') {
var segment = new FoldSegment (data.Document, "...", sb.Length, 0, FoldingType.None);
segment.IsFolded = false;
foldStack.Push (segment);
i++;
break;
}
}
goto default;
case '+':
if (i + 1 < content.Length) {
var next = content [i + 1];
if (next == '[') {
var segment = new FoldSegment (data.Document, "...", sb.Length, 0, FoldingType.None);
segment.IsFolded = true;
foldStack.Push (segment);
i++;
break;
}
}
goto default;
case ']':
if (foldStack.Count > 0) {
FoldSegment segment = foldStack.Pop ();
segment.Length = sb.Length - segment.Offset;
foldSegments.Add (segment);
break;
}
goto default;
default:
sb.Append (ch);
break;
}
}
data.Text = sb.ToString ();
if (caretIndex >= 0)
data.Caret.Offset = caretIndex;
if (selectionStart >= 0) {
if (caretIndex == selectionStart) {
data.SetSelection (selectionEnd, selectionStart);
} else {
data.SetSelection (selectionStart, selectionEnd);
if (caretIndex < 0)
data.Caret.Offset = selectionEnd;
}
}
if (foldSegments.Count > 0)
data.Document.UpdateFoldSegments (foldSegments);
return data;
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:87,代码来源:CSharpTextEditorIndentationTests.cs
示例6: FoldSegmentEventArgs
public FoldSegmentEventArgs (FoldSegment foldSegment)
{
this.FoldSegment = foldSegment;
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:4,代码来源:FoldSegment.cs
示例7: FoldSegment
public FoldSegment (FoldSegment foldSegment) : base (foldSegment.Offset, foldSegment.Length)
{
this.doc = foldSegment.doc;
this.isFolded = foldSegment.IsFolded;
this.Description = foldSegment.Description;
this.FoldingType = foldSegment.FoldingType;
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:7,代码来源:FoldSegment.cs
示例8: AddMarker
FoldSegment AddMarker (List<FoldSegment> foldSegments, string text, DomRegion region, FoldingType type)
{
Document document = textEditorData.Document;
if (document == null || region.Start.Line <= 0 || region.End.Line <= 0 || region.Start.Line > document.LineCount || region.End.Line > document.LineCount)
return null;
int startOffset = document.LocationToOffset (region.Start.Line, region.Start.Column);
// end doesn't include the char at that position.
int endOffset = document.LocationToOffset (region.End.Line, region.End.Column) - 1;
FoldSegment result = new FoldSegment (document, text, startOffset, endOffset - startOffset, type);
foldSegments.Add (result);
return result;
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:13,代码来源:SourceEditorWidget.cs
示例9: RemoveFolding
void RemoveFolding (FoldSegment folding)
{
if (folding.isFolded)
foldedSegments.Remove (folding);
foldedSegments.Remove (folding);
}
开发者ID:okrmartin,项目名称:monodevelop,代码行数:6,代码来源:Document.cs
示例10: RemoveFolding
void RemoveFolding (FoldSegment folding)
{
Gtk.Application.Invoke (delegate {
folding.isAttached = false;
if (folding.isFolded)
foldedSegments.Remove (folding);
foldSegmentTree.Remove (folding);
});
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:9,代码来源:Document.cs
示例11: MouseHover
internal protected override void MouseHover (MarginMouseEventArgs args)
{
base.MouseHover (args);
DocumentLine lineSegment = null;
if (args.LineSegment != null) {
lineSegment = args.LineSegment;
if (lineHover != lineSegment) {
lineHover = lineSegment;
editor.RedrawMargin (this);
}
}
lineHover = lineSegment;
hoverSegment = GetSelectedSegment (args.LineNumber);
bool found = hoverSegment != null;
StopTimer ();
if (found) {
var list = new List<FoldSegment>(editor.Document.GetFoldingContaining (lineSegment));
list.Sort ((x, y) => x.Offset.CompareTo (y.Offset));
foldings = list;
if (editor.TextViewMargin.BackgroundRenderer == null) {
timerId = GLib.Timeout.Add (150, SetBackgroundRenderer);
} else {
SetBackgroundRenderer ();
}
} else {
RemoveBackgroundRenderer ();
}
}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:31,代码来源:SolidFoldMarkerMargin.cs
示例12: ParseFoldingRegion
private void ParseFoldingRegion(MatchCollection mc, ref List<FoldSegment> list, int start)
{
int needStart =1;
int findEnd =0;
if(mc == null || mc.Count<1) return;
if(start >= mc.Count) return;
Match startMatch = mc[start];
if(startMatch.Value.Contains("@endregion")){
start++;
ParseFoldingRegion(mc, ref list, start);
return;
}
for(int i=start+1; i<mc.Count;i++){
if(!mc[i].Value.Contains("@endregion")){
needStart++;
} else {
findEnd++;
if(needStart == findEnd){
int startIndex =startMatch.Index;
int endIndex =mc[i].Index- startIndex + mc[i].Value.Length;
Regex regex = new Regex(@"//\s*[email protected]", RegexOptions.Compiled);
string text = regex.Replace(startMatch.Value, "");
text = text.Trim();
if(String.IsNullOrEmpty(text)) text ="....";
FoldSegment fs = new FoldSegment(text,startIndex,endIndex,FoldingType.Region);
list.Add(fs);
break;
}
}
}
start++;
ParseFoldingRegion(mc, ref list, start);
}
开发者ID:moscrif,项目名称:ide,代码行数:42,代码来源:TextEdit.cs
示例13: ParseFolding
private void ParseFolding(MatchCollection mc, ref List<FoldSegment> list, int start, string startExpresion,string endExpresion)
{
int needStart =1;
int findEnd =0;
if(mc == null || mc.Count<1) return;
if(start >= mc.Count) return;
Match startMatch = mc[start];
if(startMatch.Value.Contains(endExpresion)){//"}"
start++;
ParseFolding(mc, ref list, start,startExpresion,endExpresion);
return;
}
for(int i=start+1; i<mc.Count;i++){
if(mc[i].Value.Contains(startExpresion)){//"}"
needStart++;
} else if (mc[i].Value.Contains(endExpresion)){
findEnd++;
if(needStart == findEnd){
int startIndex =startMatch.Index;
int endIndex =mc[i].Index- startIndex + mc[i].Value.Length;
FoldSegment fs = new FoldSegment("....",startIndex,endIndex,FoldingType.Region);
list.Add(fs);
break;
}
}
}
start++;
ParseFolding(mc, ref list, start,startExpresion,endExpresion);
}
开发者ID:moscrif,项目名称:ide,代码行数:38,代码来源:TextEdit.cs
示例14: MouseLeft
internal protected override void MouseLeft ()
{
base.MouseLeft ();
hoverSegment = null;
if (lineHover != null) {
lineHover = null;
editor.RedrawMargin (this);
}
StopTimer ();
RemoveBackgroundRenderer ();
}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:11,代码来源:SolidFoldMarkerMargin.cs
注:本文中的Mono.TextEditor.FoldSegment类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论