本文整理汇总了C#中IDocument.RequestUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# IDocument.RequestUpdate方法的具体用法?C# IDocument.RequestUpdate怎么用?C# IDocument.RequestUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDocument
的用法示例。
在下文中一共展示了IDocument.RequestUpdate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetPosition
public static void SetPosition(string fileName, IDocument document, int makerStartLine, int makerStartColumn, int makerEndLine, int makerEndColumn)
{
Remove();
startLine = makerStartLine;
startColumn = makerStartColumn;
endLine = makerEndLine;
endColumn = makerEndColumn;
if (startLine < 1 || startLine > document.TotalNumberOfLines)
return;
if (endLine < 1 || endLine > document.TotalNumberOfLines) {
endLine = startLine;
endColumn = int.MaxValue;
}
if (startColumn < 1)
startColumn = 1;
LineSegment line = document.GetLineSegment(startLine - 1);
if (endColumn < 1 || endColumn > line.Length)
endColumn = line.Length;
instance = new CurrentLineBookmark(fileName, document, new TextLocation(startColumn - 1, startLine - 1));
document.BookmarkManager.AddMark(instance);
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, startLine - 1, endLine - 1));
document.CommitUpdate();
}
示例2: SetPosition
public static void SetPosition(string fileName, IDocument document, int makerStartLine, int makerStartColumn, int makerEndLine, int makerEndColumn)
{
Remove();
startLine = makerStartLine;
startColumn = makerStartColumn;
endLine = makerEndLine;
endColumn = makerEndColumn;
LineSegment line = document.GetLineSegment(startLine - 1);
instance = new CurrentLineBookmark(fileName, document, startLine - 1);
document.BookmarkManager.AddMark(instance);
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, startLine - 1, endLine - 1));
document.CommitUpdate();
}
示例3: MarkTokens
public void MarkTokens(IDocument document, List<LineSegment> inputLines)
{
if (Rules.Count == 0) {
return;
}
Dictionary<LineSegment, bool> processedLines = new Dictionary<LineSegment, bool>();
bool spanChanged = false;
foreach (LineSegment lineToProcess in inputLines) {
if (!processedLines.ContainsKey(lineToProcess)) {
int lineNumber = document.GetLineNumberForOffset(lineToProcess.Offset);
bool processNextLine = true;
if (lineNumber != -1) {
while (processNextLine && lineNumber < document.TotalNumberOfLines) {
if (lineNumber >= document.LineSegmentCollection.Count) { // may be, if the last line ends with a delimiter
break; // then the last line is not in the collection :)
}
processNextLine = MarkTokensInLine(document, lineNumber, ref spanChanged);
processedLines[currentLine] = true;
++lineNumber;
}
}
}
}
if (spanChanged) {
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
} else {
// document.Caret.ValidateCaretPos();
// document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, document.GetLineNumberForOffset(document.Caret.Offset)));
//
foreach (LineSegment lineToProcess in inputLines) {
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, document.GetLineNumberForOffset(lineToProcess.Offset)));
}
}
document.CommitUpdate();
currentLine = null;
}
示例4: MarkTokens
public virtual void MarkTokens(IDocument document, List<LineSegment> inputLines)
{
if (Rules.Count == 0) {
return;
}
Dictionary<LineSegment, bool> processedLines = new Dictionary<LineSegment, bool>();
bool spanChanged = false;
int documentLineSegmentCount = document.LineSegmentCollection.Count;
foreach (LineSegment lineToProcess in inputLines) {
if (!processedLines.ContainsKey(lineToProcess)) {
int lineNumber = lineToProcess.LineNumber;
bool processNextLine = true;
if (lineNumber != -1) {
while (processNextLine && lineNumber < documentLineSegmentCount) {
processNextLine = MarkTokensInLine(document, lineNumber, ref spanChanged);
processedLines[currentLine] = true;
++lineNumber;
}
}
}
}
if (spanChanged || inputLines.Count > 20) {
// if the span was changed (more than inputLines lines had to be reevaluated)
// or if there are many lines in inputLines, it's faster to update the whole
// text area instead of many small segments
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
} else {
// document.Caret.ValidateCaretPos();
// document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, document.GetLineNumberForOffset(document.Caret.Offset)));
//
foreach (LineSegment lineToProcess in inputLines) {
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, lineToProcess.LineNumber));
}
}
document.CommitUpdate();
currentLine = null;
}
示例5: ToggleBreakpointAt
public static void ToggleBreakpointAt(IDocument document, string fileName, int lineNumber)
{
ReadOnlyCollection<Bookmark> bookmarks = document.BookmarkManager.Marks;
for (int i = bookmarks.Count - 1; i >= 0; --i) {
BreakpointBookmark breakpoint = bookmarks[i] as BreakpointBookmark;
if (breakpoint != null) {
if (breakpoint.LineNumber == lineNumber) {
document.BookmarkManager.RemoveMark(breakpoint);
return;
}
}
}
int column = 0;
foreach (char ch in document.GetText(document.GetLineSegment(lineNumber))) {
if (!char.IsWhiteSpace(ch)) {
document.BookmarkManager.AddMark(new BreakpointBookmark(fileName, document, new TextLocation(column, lineNumber), BreakpointAction.Break, "", ""));
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, lineNumber));
document.CommitUpdate();
break;
}
column++;
}
}
示例6: RemoveMarker
public void RemoveMarker(IDocument doc)
{
try
{
if (oldMarker != null && doc != null && doc.TextLength >= oldMarker.Offset)
{
doc.MarkerStrategy.RemoveMarker(oldMarker);
doc.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine,doc.GetLineNumberForOffset(oldMarker.Offset)));
doc.CommitUpdate();
}
}
catch(System.Exception e)
{
}
}
示例7: MarkTokens
public void MarkTokens(IDocument document)
{
if (document == null)
{
throw new ArgumentNullException(nameof(document));
}
var tokens = GetHighlightedTokens(document.TextContent);
var tokenEnum = tokens.GetEnumerator();
var tokenEnd = !tokenEnum.MoveNext();
foreach (var line in document.LineSegmentCollection)
{
(line.Words = line.Words ?? new List<TextWord>()).Clear();
var offset = line.Offset;
while (!tokenEnd)
{
if (offset >= line.Offset + line.Length)
{
break;
}
var token = tokenEnum.Current;
if (token.End <= offset)
{
tokenEnd = !tokenEnum.MoveNext();
continue;
}
if (offset < token.Start)
{
token = new HighlightedSegment<string>(offset, token.Start, null);
}
var end = Math.Min(line.Offset + line.Length, token.End);
line.Words.Add(new TextWord(document, line, offset - line.Offset, end - offset, this.GetColorFor(token.Value), true));
offset = end;
}
if (offset < line.Offset + line.Length)
{
line.Words.Add(new TextWord(document, line, offset - line.Offset, line.Offset + line.Length - offset, this.GetColorFor(null), true));
}
}
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
document.CommitUpdate();
}
示例8: MarkTokens
// Mark document文档中的某些行.
public void MarkTokens(IDocument document, ArrayList Lines)
{
if (RuleSets.Count == 0) {
return;
}
Hashtable processedLines = new Hashtable();
bool spanChanged = false;
foreach (LineSegment lineToProcess in Lines) {
if (processedLines[lineToProcess] == null) {
int lineNumber = document.GetLineNumberForOffset(lineToProcess.Offset);
bool processNextLine = true;
if (lineNumber != -1) {
while (processNextLine && lineNumber < document.TotalNumberOfLines) {
if (lineNumber >= document.LineSegmentCollection.Count) { // may be, if the last line ends with a delimiter
break; // then the last line is not in the collection :)
}
processNextLine = MarkTokensInLine(document, lineNumber, ref spanChanged);
processedLines[currentLine] = String.Empty;
++lineNumber;
}
}
}
}
if (spanChanged) {
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
} else {
foreach (LineSegment lineToProcess in Lines) {
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, document.GetLineNumberForOffset(lineToProcess.Offset)));
}
}
document.OnUpdateCommited();
}
示例9: MarkTokens
/// <summary>
/// Highlights the tokens in the given lines in the given document.
/// </summary>
/// <param name="document">The document being highlighted.</param>
/// <param name="lines">The lines to highlight.</param>
public void MarkTokens(IDocument document, List<LineSegment> lines)
{
Dictionary<Int32, List<IToken>> dicTokens = new Dictionary<int, List<IToken>>();
AntlrLexerBase lex = LexerFactory.CreateLexer(document.TextContent, new ErrorTracker());
for (IToken tknToken = lex.NextToken(); tknToken.Type > -1; tknToken = lex.NextToken())
{
if (!dicTokens.ContainsKey(tknToken.Line - 1))
dicTokens[tknToken.Line - 1] = new List<IToken>();
dicTokens[tknToken.Line - 1].Add(tknToken);
}
foreach (LineSegment lsgLine in lines)
{
lsgLine.Words = new List<TextWord>();
if (dicTokens.ContainsKey(lsgLine.LineNumber))
foreach (IToken tknToken in dicTokens[lsgLine.LineNumber])
HandleToken(document, tknToken);
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, lsgLine.LineNumber));
}
}
示例10: ToggleBreakpointAt
public static void ToggleBreakpointAt(IDocument document, string fileName, int lineNumber)
{
foreach (Bookmark m in document.BookmarkManager.Marks)
{
CurrentBreakpointBookmark breakpoint = m as CurrentBreakpointBookmark;
if (breakpoint != null)
{
if (breakpoint.LineNumber == lineNumber)
{
document.BookmarkManager.RemoveMark(m);
try
{
if (breakpoints_conditions.ContainsKey(breakpoints[breakpoint]))
breakpoints_conditions.Remove(breakpoints[breakpoint]);
WorkbenchServiceFactory.DebuggerManager.RemoveBreakpoint(breakpoints[breakpoint]);
}
catch (System.Exception e)
{
}
breakpoints.Remove(breakpoint);
breakpoint.RemoveMarker();
return;
}
}
}
foreach (char ch in document.GetText(document.GetLineSegment(lineNumber)))
{
if (!char.IsWhiteSpace(ch))
{
CurrentBreakpointBookmark cbb = new CurrentBreakpointBookmark(fileName, document, lineNumber);
breakpoints.Add(cbb, WorkbenchServiceFactory.DebuggerManager.AddBreakPoint(fileName, lineNumber + 1,true));
document.BookmarkManager.AddMark(cbb);
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, lineNumber));
document.CommitUpdate();
break;
}
}
}
示例11: ToggleBreakpointAtByOpen
public static void ToggleBreakpointAtByOpen(IDocument document, string fileName, int lineNumber, Breakpoint br)
{
foreach (char ch in document.GetText(document.GetLineSegment(lineNumber)))
{
if (!char.IsWhiteSpace(ch))
{
CurrentBreakpointBookmark cbb = new CurrentBreakpointBookmark(fileName, document, lineNumber);
breakpoints.Add(cbb, br);
document.BookmarkManager.AddMark(cbb);
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, lineNumber));
document.CommitUpdate();
break;
}
}
}