本文整理汇总了C#中ICSharpCode.AvalonEdit.Document.DocumentLine类的典型用法代码示例。如果您正苦于以下问题:C# DocumentLine类的具体用法?C# DocumentLine怎么用?C# DocumentLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentLine类属于ICSharpCode.AvalonEdit.Document命名空间,在下文中一共展示了DocumentLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ColorizeLine
protected override void ColorizeLine(DocumentLine line)
{
var sections = _textEditor.OnHighlightLine(line);
if (sections != null)
foreach (var section in sections)
ChangeLinePart(section.Offset, section.Offset + section.Length, element => ApplyColorToElement(element, section.Color));
}
示例2: RawlyIndentLine
public void RawlyIndentLine(int tabsToInsert, ICSharpCode.AvalonEdit.Document.TextDocument document, DocumentLine line)
{
if (!_doBeginUpdateManually)
document.BeginUpdate();
/*
* 1) Remove old indentation
* 2) Insert new one
*/
// 1)
int prevInd = 0;
int curOff = line.Offset;
if (curOff < document.TextLength)
{
char curChar = '\0';
while (curOff < document.TextLength && ((curChar = document.GetCharAt(curOff)) == ' ' || curChar == '\t'))
{
prevInd++;
curOff++;
}
document.Remove(line.Offset, prevInd);
}
// 2)
string indentString = "";
for (int i = 0; i < tabsToInsert; i++)
indentString += dEditor.Editor.Options.IndentationString;
document.Insert(line.Offset, indentString);
if (!_doBeginUpdateManually)
document.EndUpdate();
}
示例3: LineAdapter
public LineAdapter(TextDocument document, DocumentLine line)
{
Debug.Assert(document != null);
Debug.Assert(line != null);
this.document = document;
this.line = line;
}
示例4: VisualLine
internal VisualLine(TextView textView, DocumentLine firstDocumentLine)
{
Debug.Assert(textView != null);
Debug.Assert(firstDocumentLine != null);
this.textView = textView;
this.FirstDocumentLine = firstDocumentLine;
}
示例5: IndentLine
public void IndentLine(TextDocument document, DocumentLine line)
{
if (document == null || line == null)
{
return;
}
DocumentLine previousLine = line.PreviousLine;
if (previousLine != null)
{
ISegment indentationSegment = TextUtilities.GetWhitespaceAfter(document, previousLine.Offset);
string indentation = document.GetText(indentationSegment);
if (Program.OptionsObject.Editor_AgressiveIndentation)
{
string currentLineTextTrimmed = (document.GetText(line)).Trim();
string lastLineTextTrimmed = (document.GetText(previousLine)).Trim();
char currentLineFirstNonWhitespaceChar = ' ';
if (currentLineTextTrimmed.Length > 0)
{
currentLineFirstNonWhitespaceChar = currentLineTextTrimmed[0];
}
char lastLineLastNonWhitespaceChar = ' ';
if (lastLineTextTrimmed.Length > 0)
{
lastLineLastNonWhitespaceChar = lastLineTextTrimmed[lastLineTextTrimmed.Length - 1];
}
if (lastLineLastNonWhitespaceChar == '{' && currentLineFirstNonWhitespaceChar != '}')
{
indentation += "\t";
}
else if (currentLineFirstNonWhitespaceChar == '}')
{
if (indentation.Length > 0)
{
indentation = indentation.Substring(0, indentation.Length - 1);
}
else
{
indentation = string.Empty;
}
}
/*if (lastLineTextTrimmed == "{" && currentLineTextTrimmed != "}")
{
indentation += "\t";
}
else if (currentLineTextTrimmed == "}")
{
if (indentation.Length > 0)
{
indentation = indentation.Substring(0, indentation.Length - 1);
}
else
{
indentation = string.Empty;
}
}*/
}
indentationSegment = TextUtilities.GetWhitespaceAfter(document, line.Offset);
document.Replace(indentationSegment, indentation);
}
}
示例6: Colorize
/*
protected override void Colorize(ITextRunConstructionContext context)
{
//base.Colorize(context);
foreach (var line in context.Document.Lines)
{
ColorizeText(line, context.Document.GetText(line));
}
}
*/
protected override void ColorizeLine(DocumentLine line)
{
if (CurrentContext == null) return;
string text = CurrentContext.Document.GetText(line);
ColorizeText(line, text);
}
示例7: IndentLine
public virtual void IndentLine(TextDocument document, DocumentLine line)
{
if(line == null)
throw new ArgumentNullException("line");
formatting_strategy.IndentLine(editor, editor.Document.GetLineByNumber(line.LineNumber));
}
示例8: HeightTreeNode
internal HeightTreeNode(DocumentLine documentLine, double height)
{
this.documentLine = documentLine;
this.totalCount = 1;
this.lineNode = new HeightTreeLineNode(height);
this.totalHeight = height;
}
示例9: ColorizeLine
protected override void ColorizeLine(DocumentLine line)
{
int lineStartOffset = line.Offset;
string text = CurrentContext.Document.GetText(line);
int start = 0;
int index;
while ((index = text.IndexOf("AvalonEdit", start)) >= 0) {
base.ChangeLinePart(
lineStartOffset + index, // startOffset
lineStartOffset + index + 10, // endOffset
(VisualLineElement element) => {
// This lambda gets called once for every VisualLineElement
// between the specified offsets.
Typeface tf = element.TextRunProperties.Typeface;
// Replace the typeface with a modified version of
// the same typeface
element.TextRunProperties.SetTypeface(new Typeface(
tf.FontFamily,
FontStyles.Italic,
FontWeights.Bold,
tf.Stretch
));
});
start = index + 1; // search for next occurrence
}
}
示例10: Colorize
/// <inheritdoc/>
protected override void Colorize(ITextRunConstructionContext context)
{
if (context == null)
throw new ArgumentNullException(nameof(context));
CurrentContext = context;
currentDocumentLine = context.VisualLine.FirstDocumentLine;
firstLineStart = currentDocumentLineStartOffset = currentDocumentLine.Offset;
currentDocumentLineEndOffset = currentDocumentLineStartOffset + currentDocumentLine.Length;
if (context.VisualLine.FirstDocumentLine == context.VisualLine.LastDocumentLine)
{
ColorizeLine(currentDocumentLine);
}
else
{
ColorizeLine(currentDocumentLine);
// ColorizeLine modifies the visual line elements, loop through a copy of the line elements
foreach (VisualLineElement e in context.VisualLine.Elements.ToArray())
{
int elementOffset = firstLineStart + e.RelativeTextOffset;
if (elementOffset >= currentDocumentLineEndOffset)
{
currentDocumentLine = context.Document.GetLineByOffset(elementOffset);
currentDocumentLineStartOffset = currentDocumentLine.Offset;
currentDocumentLineEndOffset = currentDocumentLineStartOffset + currentDocumentLine.Length;
ColorizeLine(currentDocumentLine);
}
}
}
currentDocumentLine = null;
CurrentContext = null;
}
示例11: GetCompletionData
/// <summary>
/// Retrieve completion suggestions
/// </summary>
/// <param name="completionWord">Word to complete</param>
/// <param name="content">Script that we're working with</param>
/// <param name="lineContent">Content of the current line</param>
/// <param name="line">Line object from AvaloneEdit</param>
/// <param name="runbookToken">Token containing the name of the runbook (if not runbook, null)</param>
/// <param name="position">Caret offset</param>
/// <param name="triggerChar">Not used</param>
/// <param name="triggerTag">Counter</param>
public void GetCompletionData(string completionWord, string content, string lineContent, DocumentLine line, Token runbookToken, int position, char? triggerChar, long triggerTag)
{
if (_requestTrigger != 0 && triggerTag <= _requestTrigger)
return;
DismissGetCompletionResults();
ProcessCompletion(content, triggerChar, completionWord, runbookToken, position, triggerTag);
}
示例12: CommentLine
public bool CommentLine(TextDocument document, DocumentLine documentLine)
{
if (Mode == CommentMode.BeginOfLine)
{
return CommentAtBeginOfLine(document, documentLine);
}
return CommentAtBeginOfText(document, documentLine);
}
示例13: IsEmpty
private bool IsEmpty( DocumentLine dl )
{
for ( int i = dl.Offset; i<dl.EndOffset; i++){
char ch = ta.Document.GetCharAt(i);
if ((ch!=' ')&&(ch!='\t')) return false;
}
return true;
}
示例14:
void ILineTracker.LineInserted(DocumentLine insertionPos, DocumentLine newLine)
{
ILineTracker targetTracker = targetObject.Target as ILineTracker;
if (targetTracker != null)
targetTracker.LineInserted(insertionPos, newLine);
else
Deregister();
}
示例15:
void ILineTracker.SetLineLength(DocumentLine line, int newTotalLength)
{
CheckIsHighlighting();
int number = line.LineNumber;
isValid[number] = false;
if (number < firstInvalidLine)
firstInvalidLine = number;
}