本文整理汇总了C#中ICSharpCode.AvalonEdit.Document.TextDocument.GetLineByNumber方法的典型用法代码示例。如果您正苦于以下问题:C# TextDocument.GetLineByNumber方法的具体用法?C# TextDocument.GetLineByNumber怎么用?C# TextDocument.GetLineByNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.AvalonEdit.Document.TextDocument
的用法示例。
在下文中一共展示了TextDocument.GetLineByNumber方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClassMemberBookmark
public ClassMemberBookmark(IMember member, TextDocument document)
{
this.member = member;
int lineNr = member.Region.BeginLine;
if (document != null && lineNr > 0 && lineNr <= document.LineCount)
this.line = document.GetLineByNumber(lineNr);
}
示例2: IndentLines
/// <summary>
/// Reindents a set of lines.
/// </summary>
/// <param name="document"></param>
/// <param name="beginLine"></param>
/// <param name="endLine"></param>
public void IndentLines(TextDocument document, int beginLine, int endLine)
{
for (var i = beginLine; i <= endLine; i++)
{
IndentLine(document, document.GetLineByNumber(i));
}
}
示例3: CreateView
/// <summary>
/// Creates a new <see cref="FixedHighlighter"/> for a copy of a portion
/// of the input document (including the original highlighting).
/// </summary>
public static FixedHighlighter CreateView(IHighlighter highlighter, int offset, int endOffset)
{
var oldDocument = highlighter.Document;
// ReadOnlyDocument would be better; but displaying the view in AvalonEdit
// requires a TextDocument
var newDocument = new TextDocument(oldDocument.CreateSnapshot(offset, endOffset - offset));
var oldStartLine = oldDocument.GetLineByOffset(offset);
var oldEndLine = oldDocument.GetLineByOffset(endOffset);
int oldStartLineNumber = oldStartLine.LineNumber;
HighlightedLine[] newLines = new HighlightedLine[oldEndLine.LineNumber - oldStartLineNumber + 1];
highlighter.BeginHighlighting();
try {
for (int i = 0; i < newLines.Length; i++) {
HighlightedLine oldHighlightedLine = highlighter.HighlightLine(oldStartLineNumber + i);
IDocumentLine newLine = newDocument.GetLineByNumber(1 + i);
HighlightedLine newHighlightedLine = new HighlightedLine(newDocument, newLine);
MoveSections(oldHighlightedLine.Sections, -offset, newLine.Offset, newLine.EndOffset, newHighlightedLine.Sections);
newHighlightedLine.ValidateInvariants();
newLines[i] = newHighlightedLine;
}
} finally {
highlighter.EndHighlighting();
}
return new FixedHighlighter(newDocument, newLines);
}
示例4: IndentLines
public void IndentLines(TextDocument document, int beginLine, int endLine)
{
_doBeginUpdateManually = true;
document.BeginUpdate();
while (beginLine <= endLine)
{
IndentLine(document, document.GetLineByNumber(beginLine));
beginLine++;
}
document.EndUpdate();
_doBeginUpdateManually = false;
}
示例5: CreateNewFoldings
public override IEnumerable<NewFolding> CreateNewFoldings(TextDocument document, out int firstErrorOffset)
{
firstErrorOffset = -1;
var folds = new List<NewFolding>();
linenr = 1;
prev = false;
startfold = 0; endfold = 0;
n = 0;
var l = document.GetLineByNumber(linenr);
int sep = 0;
do
{
int N = l.TotalLength;
var line = document.GetText(n, N);
var M = r.Match(line);
if (M.Success)
{
if (!prev)
{
prev = true;
startfold = n;
}
endfold = n + l.Length;
}
else
{
if (prev)
folds.Add(lastfold=new NewFolding{ StartOffset=startfold, EndOffset= endfold, Name="FileSync Complete", DefaultClosed=true});
prev = false;
}
linenr++;
n += N;
}
while ((l = l.NextLine) != null);
return folds;
}
示例6: GetNewLineFromDocument
/// <summary>
/// Gets the newline sequence used in the document at the specified line.
/// </summary>
public static string GetNewLineFromDocument(TextDocument document, int lineNumber)
{
DocumentLine line = document.GetLineByNumber(lineNumber);
if (line.DelimiterLength == 0) {
// at the end of the document, there's no line delimiter, so use the delimiter
// from the previous line
line = line.PreviousLine;
if (line == null)
return Environment.NewLine;
}
return document.GetText(line.Offset + line.Length, line.DelimiterLength);
}
示例7: LineMarker
public LineMarker(TextMarkerService svc, TextDocument doc, int beginLine, int endLine)
{
TextMarkerService = svc;
StartOffset = doc.GetOffset(beginLine, 0);
Length = doc.GetLineByNumber(endLine).EndOffset - StartOffset;
}
示例8: ClassBookmark
public ClassBookmark(IClass @class, TextDocument document)
{
[email protected] = @class;
int lineNr = @class.Region.BeginLine;
if (document != null && lineNr > 0 && lineNr <= document.LineCount)
this.line = document.GetLineByNumber(lineNr);
}
示例9: CreateInlineBuilder
public static HighlightedInlineBuilder CreateInlineBuilder(Location startPosition, Location endPosition, TextDocument document, IHighlighter highlighter)
{
if (startPosition.Line >= 1 && startPosition.Line <= document.LineCount) {
var matchedLine = document.GetLineByNumber(startPosition.Line);
HighlightedInlineBuilder inlineBuilder = new HighlightedInlineBuilder(document.GetText(matchedLine));
if (highlighter != null) {
HighlightedLine highlightedLine = highlighter.HighlightLine(startPosition.Line);
int startOffset = highlightedLine.DocumentLine.Offset;
// copy only the foreground color
foreach (HighlightedSection section in highlightedLine.Sections) {
if (section.Color.Foreground != null) {
inlineBuilder.SetForeground(section.Offset - startOffset, section.Length, section.Color.Foreground.GetBrush(null));
}
}
}
// now highlight the match in bold
if (startPosition.Column >= 1) {
if (endPosition.Line == startPosition.Line && endPosition.Column > startPosition.Column) {
// subtract one from the column to get the offset inside the line's text
int startOffset = startPosition.Column - 1;
int endOffset = Math.Min(inlineBuilder.Text.Length, endPosition.Column - 1);
inlineBuilder.SetFontWeight(startOffset, endOffset - startOffset, FontWeights.Bold);
}
}
return inlineBuilder;
}
return null;
}
示例10: IsEmptyLine
/// <summary>
/// Determines whether a line of a document is empty (no characters or whitespace).
/// </summary>
/// <param name="document">The document.</param>
/// <param name="lineNumber">The line number.</param>
/// <returns>
/// <see langword="true"/> if line is empty of filled with whitespace; otherwise,
/// <see langword="false"/>.
/// </returns>
internal static bool IsEmptyLine(TextDocument document, int lineNumber)
{
return IsEmptyLine(document, document.GetLineByNumber(lineNumber));
}
示例11: GetLineTerminator
/// <summary>
/// Gets the line terminator for the document around the specified line number.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="lineNumber">The line number.</param>
/// <returns>The line terminator.</returns>
internal static string GetLineTerminator(TextDocument document, int lineNumber)
{
DocumentLine line = document.GetLineByNumber(lineNumber);
if (line.DelimiterLength == 0)
{
// at the end of the document, there's no line delimiter, so use the delimiter
// from the previous line
if (lineNumber == 1)
return Environment.NewLine;
line = document.GetLineByNumber(lineNumber - 1);
}
return document.GetText(line.Offset + line.Length, line.DelimiterLength);
}
示例12: CreateInlineBuilder
public static HighlightedInlineBuilder CreateInlineBuilder(Location startPosition, Location endPosition, TextDocument document, ISyntaxHighlighter highlighter)
{
if (startPosition.Line >= 1 && startPosition.Line <= document.LineCount) {
HighlightedInlineBuilder inlineBuilder;
if (highlighter != null) {
inlineBuilder = highlighter.BuildInlines(startPosition.Line);
} else {
inlineBuilder = new HighlightedInlineBuilder(document.GetText(document.GetLineByNumber(startPosition.Line)));
}
// now highlight the match in bold
if (startPosition.Column >= 1) {
if (endPosition.Line == startPosition.Line && endPosition.Column > startPosition.Column) {
// subtract one from the column to get the offset inside the line's text
int startOffset = startPosition.Column - 1;
int endOffset = Math.Min(inlineBuilder.Text.Length, endPosition.Column - 1);
inlineBuilder.SetFontWeight(startOffset, endOffset - startOffset, FontWeights.Bold);
}
}
return inlineBuilder;
}
return null;
}