本文整理汇总了C#中MonoDevelop.Ide.Gui.TextEditor.GetCharAt方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.GetCharAt方法的具体用法?C# TextEditor.GetCharAt怎么用?C# TextEditor.GetCharAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.Ide.Gui.TextEditor
的用法示例。
在下文中一共展示了TextEditor.GetCharAt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWhitespaces
public static string GetWhitespaces (TextEditor editor, int insertionOffset)
{
StringBuilder result = new StringBuilder ();
for (int i = insertionOffset; i < editor.Length; i++) {
char ch = editor.GetCharAt (i);
if (ch == ' ' || ch == '\t') {
result.Append (ch);
} else {
break;
}
}
return result.ToString ();
}
示例2: FindPrevWordStart
static int FindPrevWordStart (TextEditor editor, int offset)
{
while (--offset >= 0) {
var c = editor.GetCharAt (offset);
//Only legal characters in template Shortcut
//LetterOrDigit make sense
//_ to allow underscore naming convention
//# is because there are #if templates
//~ because disctructor template
//@ some Razor templates start with @
//in theory we should probably just support LetterOrDigit and _
if (!char.IsLetterOrDigit (c) && c != '_' && c != '#' && c != '~' && c != '@') {
break;
}
}
return ++offset;
}
示例3: IsMatchAt
static bool IsMatchAt (TextEditor editor, int offset, string abbrevWord)
{
if (offset + abbrevWord.Length >= editor.Length)
return false;
if (offset > 0 && IsIdentifierPart (editor.GetCharAt (offset - 1)))
return false;
if (offset + abbrevWord.Length < editor.Length && !IsIdentifierPart (editor.GetCharAt (offset + abbrevWord.Length)))
return false;
return editor.GetTextAt (offset, abbrevWord.Length) == abbrevWord;
}
示例4: SearchEndPos
static int SearchEndPos (int offset, TextEditor editor)
{
while (offset < editor.Length && IsIdentifierPart (editor.GetCharAt (offset))) {
offset++;
}
return offset;
}
示例5: GetWordBeforeCaret
static string GetWordBeforeCaret (TextEditor editor)
{
int startOffset = editor.CaretOffset;
int offset = startOffset - 1;
while (offset > 0) {
char ch = editor.GetCharAt (offset);
if (!IsIdentifierPart (ch)) {
offset++;
break;
}
offset--;
}
if (offset >= startOffset)
return "";
return editor.GetTextBetween (offset, startOffset);
}
示例6: SearchMatchingBracket
static int SearchMatchingBracket (TextEditor editor, int offset, char openBracket, char closingBracket, int direction)
{
bool isInString = false;
bool isInChar = false;
bool isInBlockComment = false;
int depth = -1;
while (offset >= 0 && offset < editor.TextLength) {
char ch = editor.GetCharAt (offset);
switch (ch) {
case '/':
if (isInBlockComment)
isInBlockComment = editor.GetCharAt (offset + direction) != '*';
if (!isInString && !isInChar && offset - direction < editor.TextLength)
isInBlockComment = offset > 0 && editor.GetCharAt (offset - direction) == '*';
break;
case '"':
if (!isInChar && !isInBlockComment)
isInString = !isInString;
break;
case '\'':
if (!isInString && !isInBlockComment)
isInChar = !isInChar;
break;
default :
if (ch == closingBracket) {
if (!(isInString || isInChar || isInBlockComment))
--depth;
} else if (ch == openBracket) {
if (!(isInString || isInChar || isInBlockComment)) {
++depth;
if (depth == 0)
return offset;
}
}
break;
}
offset += direction;
}
return -1;
}