本文整理汇总了C#中TextEditorData.GetCharAt方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditorData.GetCharAt方法的具体用法?C# TextEditorData.GetCharAt怎么用?C# TextEditorData.GetCharAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextEditorData
的用法示例。
在下文中一共展示了TextEditorData.GetCharAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseForChar
static int? ParseForChar(TextEditorData data, int fromOffset, int toOffset, char oppositeToken, char findToken, bool forward)
{
int increment = forward ? 1 : -1;
var symbolCount = 0;
for (int i = fromOffset; forward && i < toOffset || !forward && i >= toOffset; i += increment)
{
var c = data.GetCharAt(i);
if (c == oppositeToken)
symbolCount++;
else if (c == findToken)
{
if (symbolCount == 0) return i;
symbolCount--;
}
}
return null;
}
示例2: TryFindSymbolBlock
static bool TryFindSymbolBlock (TextEditorData data, char command, out SymbolBlock result)
{
char end, begin;
if (!BeginToEndCharMap.TryGetValue (command, out end)) end = command;
if (!EndToBeginCharMap.TryGetValue (command, out begin)) begin = command;
var offset = data.Caret.Offset;
var startTokenOffset = ParseForChar(data, offset, 0, end, begin, false);
var endTokenOffset = ParseForChar(data, offset, data.Length, begin, end, true);
// Use the editor's FindMatchingBrace built-in functionality. It's better at handling erroneous braces
// inside quotes. We still need to do the above paragraph because we needed to find the braces.
var matchingStartBrace = endTokenOffset.HasValue ? data.Document.GetMatchingBracketOffset(
endTokenOffset.GetValueOrDefault ()) : -1;
if (matchingStartBrace >= 0 && (!startTokenOffset.HasValue
|| matchingStartBrace != startTokenOffset.GetValueOrDefault ()))
startTokenOffset = matchingStartBrace;
var matchingEndBrace = startTokenOffset.HasValue && data.GetCharAt (offset) != end ?
data.Document.GetMatchingBracketOffset(startTokenOffset.GetValueOrDefault ()) : -1;
if (matchingEndBrace >= 0 && (!endTokenOffset.HasValue
|| matchingEndBrace != endTokenOffset.GetValueOrDefault ()))
endTokenOffset = matchingEndBrace;
if (!startTokenOffset.HasValue || !endTokenOffset.HasValue) throw new ViModeAbortException();
result = new SymbolBlock
{
StartOffset = startTokenOffset.GetValueOrDefault (),
EndOffset = endTokenOffset.GetValueOrDefault (),
StartLine = data.GetLineByOffset (startTokenOffset.GetValueOrDefault()),
EndLine = data.GetLineByOffset (endTokenOffset.GetValueOrDefault()),
};
return true;
}