本文整理汇总了C#中IDocument.GetLineFromLineNumber方法的典型用法代码示例。如果您正苦于以下问题:C# IDocument.GetLineFromLineNumber方法的具体用法?C# IDocument.GetLineFromLineNumber怎么用?C# IDocument.GetLineFromLineNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDocument
的用法示例。
在下文中一共展示了IDocument.GetLineFromLineNumber方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsNotSameScope
bool IsNotSameScope(IDocument view, int lineNo, string original)
{
var line = view.GetLineFromLineNumber(lineNo).Text.ReplaceTabs(view.TabSize);
var lineIndent = line .Length - line .TrimStart().Length;
var originalIndent = original.Length - original.TrimStart().Length;
return line.Trim() == string.Empty || lineIndent != originalIndent;
}
示例2: GetLinesToAlign
public IEnumerable<ILine> GetLinesToAlign(IDocument view)
{
int start = view.StartSelectionLineNumber;
int end = view.EndSelectionLineNumber;
if (start == end)
{
var line = view.GetLineFromLineNumber(start).Text.ReplaceTabs(view.TabSize);
var isMulti = IsMultiLineTag(view, line);
var blanks = isMulti ? start .DownTo(0).Where(x => IsMultiLineStart(view, x))
: (start + 1).DownTo(1).Where(x => IsNotSameScope(view, x - 1, line));
start = blanks.Any() ? blanks.First() : 0;
blanks = isMulti ? end .UpTo(view.LineCount - 1).Where(x => IsMultiLineEnd(view, x))
: (end - 1).UpTo(view.LineCount - 2).Where(x => IsNotSameScope(view, x + 1, line));
end = blanks.Any() ? blanks.First() : view.LineCount - 1;
}
return start.UpTo(end).Select(x => view.GetLineFromLineNumber(x));
}
示例3: GetLinesToAlign
public IEnumerable<ILine> GetLinesToAlign(IDocument view)
{
int start = view.StartSelectionLineNumber;
int end = view.EndSelectionLineNumber;
if (start == end)
{
var blanks = start.DownTo(0).Where(x => IsLineBlank(view, x));
start = blanks.Any() ? blanks.First() + 1 : 0;
blanks = end.UpTo(view.LineCount - 1).Where(x => IsLineBlank(view, x));
end = blanks.Any() ? blanks.First() - 1 : view.LineCount -1;
}
return start.UpTo(end).Select(x => view.GetLineFromLineNumber(x));
}
示例4: IsMultiLineStart
bool IsMultiLineStart(IDocument view, int lineNo)
{
var blankStrings = new[] { string.Empty, };
var line = view.GetLineFromLineNumber(lineNo).Text.Trim();
return line == string.Empty || line.StartsWith("<");
}
示例5: IsMultiLineEnd
bool IsMultiLineEnd(IDocument view, int lineNo)
{
var blankStrings = new[] { string.Empty, };
var line = view.GetLineFromLineNumber(lineNo).Text.Trim();
return line == string.Empty || line.Contains(">");
}
示例6: IsLineBlank
bool IsLineBlank(IDocument view, int lineNo)
{
return Regex.IsMatch(view.GetLineFromLineNumber(lineNo).Text, ScopeSelectorRegex);
}