本文整理汇总了C#中ICSharpCode.AvalonEdit.Document.TextDocument类的典型用法代码示例。如果您正苦于以下问题:C# TextDocument类的具体用法?C# TextDocument怎么用?C# TextDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextDocument类属于ICSharpCode.AvalonEdit.Document命名空间,在下文中一共展示了TextDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchBracket
public BracketSearchResult SearchBracket(TextDocument document, int offset)
{
BracketSearchResult result;
if (offset > 0)
{
var charAt = document.GetCharAt(offset - 1);
var num = "([{".IndexOf(charAt);
var num2 = -1;
if (num > -1)
{
num2 = SearchBracketForward(document, offset, "([{"[num], ")]}"[num]);
}
num = ")]}".IndexOf(charAt);
if (num > -1)
{
num2 = SearchBracketBackward(document, offset - 2, "([{"[num], ")]}"[num]);
}
if (num2 > -1)
{
result = new BracketSearchResult(Math.Min(offset - 1, num2), 1, Math.Max(offset - 1, num2), 1);
return result;
}
}
result = null;
return result;
}
示例2: RawData
public RawData(string name, uint offset, string format, uint address, string value, int length, uint pluginLine)
: base(name, offset, address, pluginLine)
{
_document = new TextDocument(new StringTextSource(value));
_length = length;
_format = format;
}
示例3: HeightTree
public HeightTree(TextDocument document, double defaultLineHeight)
{
this.document = document;
weakLineTracker = WeakLineTracker.Register(document, this);
this.DefaultLineHeight = defaultLineHeight;
RebuildDocument();
}
示例4: BreakpointMarker
public BreakpointMarker(TextMarkerService markerStrategy, Breakpoint bp, TextDocument doc, int line_begin, int line_end)
: base(markerStrategy, doc, line_begin, line_end)
{
this.Breakpoint = bp;
MarkerType = TextMarkerType.None;
BackgroundColor = Colors.Red;
}
示例5: DocumentViewModel
public DocumentViewModel(
IDialogService dialogService,
IWindowManager windowManager,
ISiteContextGenerator siteContextGenerator,
Func<string, IMetaWeblogService> getMetaWeblog,
ISettingsProvider settingsProvider,
IDocumentParser documentParser)
{
this.dialogService = dialogService;
this.windowManager = windowManager;
this.siteContextGenerator = siteContextGenerator;
this.getMetaWeblog = getMetaWeblog;
this.settingsProvider = settingsProvider;
this.documentParser = documentParser;
FontSize = GetFontSize();
title = "New Document";
Original = "";
Document = new TextDocument();
Post = new Post();
timer = new DispatcherTimer();
timer.Tick += TimerTick;
timer.Interval = delay;
}
示例6: AvalonEditDocumentAdapter
/// <summary>
/// Creates a new AvalonEditDocumentAdapter instance.
/// </summary>
/// <param name="document">The document to wrap.</param>
/// <param name="parentServiceProvider">The service provider used for GetService calls.</param>
public AvalonEditDocumentAdapter(TextDocument document, IServiceProvider parentServiceProvider)
{
if (document == null)
throw new ArgumentNullException("document");
this.document = document;
this.parentServiceProvider = parentServiceProvider;
}
示例7: CreateHtmlFragment
/// <summary>
/// Creates a HTML fragment from a part of a document.
/// </summary>
/// <param name="document">The document to create HTML from.</param>
/// <param name="highlighter">The highlighter used to highlight the document. <c>null</c> is valid and will create HTML without any highlighting.</param>
/// <param name="segment">The part of the document to create HTML for. You can pass <c>null</c> to create HTML for the whole document.</param>
/// <param name="options">The options for the HTML creation.</param>
/// <returns>HTML code for the document part.</returns>
public static string CreateHtmlFragment(TextDocument document, IHighlighter highlighter, ISegment segment, HtmlOptions options)
{
if (document == null)
throw new ArgumentNullException("document");
if (options == null)
throw new ArgumentNullException("options");
if (highlighter != null && highlighter.Document != document)
throw new ArgumentException("Highlighter does not belong to the specified document.");
if (segment == null)
segment = new SimpleSegment(0, document.TextLength);
StringBuilder html = new StringBuilder();
int segmentEndOffset = segment.EndOffset;
DocumentLine line = document.GetLineByOffset(segment.Offset);
while (line != null && line.Offset < segmentEndOffset) {
HighlightedLine highlightedLine;
if (highlighter != null)
highlightedLine = highlighter.HighlightLine(line.LineNumber);
else
highlightedLine = new HighlightedLine(document, line);
SimpleSegment s = segment.GetOverlap(line);
if (html.Length > 0)
html.AppendLine("<br>");
html.Append(highlightedLine.ToHtml(s.Offset, s.EndOffset, options));
line = line.NextLine;
}
return html.ToString();
}
示例8: ConvertTextDocumentToBlock
public static Block ConvertTextDocumentToBlock(TextDocument document, IHighlighter highlighter)
{
if (document == null)
throw new ArgumentNullException("document");
// Table table = new Table();
// table.Columns.Add(new TableColumn { Width = GridLength.Auto });
// table.Columns.Add(new TableColumn { Width = new GridLength(1, GridUnitType.Star) });
// TableRowGroup trg = new TableRowGroup();
// table.RowGroups.Add(trg);
Paragraph p = new Paragraph();
foreach (DocumentLine line in document.Lines) {
int lineNumber = line.LineNumber;
// TableRow row = new TableRow();
// trg.Rows.Add(row);
// row.Cells.Add(new TableCell(new Paragraph(new Run(lineNumber.ToString()))) { TextAlignment = TextAlignment.Right });
HighlightedInlineBuilder inlineBuilder = new HighlightedInlineBuilder(document.GetText(line));
if (highlighter != null) {
HighlightedLine highlightedLine = highlighter.HighlightLine(lineNumber);
int lineStartOffset = line.Offset;
foreach (HighlightedSection section in highlightedLine.Sections)
inlineBuilder.SetHighlighting(section.Offset - lineStartOffset, section.Length, section.Color);
}
// Paragraph p = new Paragraph();
// row.Cells.Add(new TableCell(p));
p.Inlines.AddRange(inlineBuilder.CreateRuns());
p.Inlines.Add(new LineBreak());
}
return p;
}
示例9: PythonConsoleHighlightingColorizer
/// <summary>
/// Creates a new HighlightingColorizer instance.
/// </summary>
/// <param name="ruleSet">The root highlighting rule set.</param>
public PythonConsoleHighlightingColorizer(IHighlightingDefinition highlightingDefinition, TextDocument document)
: base(new DocumentHighlighter(document, highlightingDefinition ))
{
if (document == null)
throw new ArgumentNullException("document");
this.document = document;
}
示例10: 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);
}
示例11: 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));
}
}
示例12: 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);
}
}
示例13: 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));
}
示例14: LoadDocumentFromBuffer
/// <summary>
/// Creates a new mutable document from the specified text buffer.
/// </summary>
/// <remarks>
/// Use the more efficient <see cref="LoadReadOnlyDocumentFromBuffer"/> if you only need a read-only document.
/// </remarks>
public static IDocument LoadDocumentFromBuffer(ITextBuffer buffer)
{
if (buffer == null)
throw new ArgumentNullException("buffer");
var doc = new TextDocument(GetTextSource(buffer));
return new AvalonEditDocumentAdapter(doc, null);
}
示例15: TextMarkerService
public TextMarkerService(TextDocument document)
{
if (document == null)
throw new ArgumentNullException("document");
this.document = document;
this.markers = new TextSegmentCollection<TextMarker>(document);
}