本文整理汇总了C#中Mono.TextEditor.Document.IsEmptyLine方法的典型用法代码示例。如果您正苦于以下问题:C# Document.IsEmptyLine方法的具体用法?C# Document.IsEmptyLine怎么用?C# Document.IsEmptyLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.TextEditor.Document
的用法示例。
在下文中一共展示了Document.IsEmptyLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
public static void Format (TextEditorData data, IType type, IMember member, ProjectDom dom, ICompilationUnit unit, DomLocation caretLocation)
{
if (type == null)
return;
if (member == null) {
// member = type;
return;
}
string wrapper;
int endPos;
wrapper = CreateWrapperClassForMember (member, member != type, data, out endPos);
if (string.IsNullOrEmpty (wrapper) || endPos < 0)
return;
// Console.WriteLine (wrapper);
int bracketIndex = wrapper.IndexOf ('{') + 1;
int col = GetColumn (wrapper, bracketIndex, data.Options.TabSize);
CSharpFormatter formatter = new CSharpFormatter ();
formatter.startIndentLevel = System.Math.Max (0, col / data.Options.TabSize - 1);
string formattedText = formatter.InternalFormat (dom != null && dom.Project != null ? dom.Project.Policies : null, MimeType, wrapper, 0, wrapper.Length);
if (formatter.hasErrors)
return;
int startPos = data.Document.LocationToOffset (member.Location.Line, 1) - 1;
InFormat = true;
if (member != type) {
int len1 = formattedText.IndexOf ('{') + 1;
int last = formattedText.LastIndexOf ('}');
formattedText = formattedText.Substring (len1, last - len1 - 1).TrimStart ('\n', '\r');
} else {
startPos++;
}
//Console.WriteLine ("formattedText0:" + formattedText.Replace ("\t", "->").Replace (" ", "°"));
if (member != type) {
string indentToRemove = GetIndent (formattedText);
// Console.WriteLine ("Remove:" + indentToRemove.Replace ("\t", "->").Replace (" ", "°"));
formattedText = RemoveIndent (formattedText, indentToRemove);
} else {
formattedText = formattedText.TrimStart ();
}
//Console.WriteLine ("Indent:" + GetIndent (data, member.Location.Line - 1).Replace ("\t", "->").Replace (" ", "°"));
//Console.WriteLine ("formattedText1:" + formattedText.Replace ("\t", "->").Replace (" ", "°"));
formattedText = AddIndent (formattedText, GetIndent (data, member.Location.Line));
Document doc = new Document ();
doc.Text = formattedText;
for (int i = doc.LineCount; i --> DocumentLocation.MinLine;) {
LineSegment lineSegment = doc.GetLine (i);
if (doc.IsEmptyLine (lineSegment))
((IBuffer)doc).Remove (lineSegment.Offset, lineSegment.Length);
}
formattedText = doc.Text;
//Console.WriteLine ("formattedText3:" + formattedText.Replace ("\t", "->").Replace (" ", "°").Replace ("\n", "\\n").Replace ("\r", "\\r"));
int textLength = CanInsertFormattedText (data, startPos, data.Document.LocationToOffset (caretLocation.Line, caretLocation.Column), formattedText);
if (textLength > 0) {
// Console.WriteLine (formattedText.Substring (0, textLength));
InsertFormattedText (data, startPos, formattedText.Substring (0, textLength).TrimEnd ());
} else {
Console.WriteLine ("Can't insert !!!");
}
InFormat = false;
}