本文整理汇总了C#中ScintillaNet.ScintillaControl.CharAt方法的典型用法代码示例。如果您正苦于以下问题:C# ScintillaControl.CharAt方法的具体用法?C# ScintillaControl.CharAt怎么用?C# ScintillaControl.CharAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScintillaNet.ScintillaControl
的用法示例。
在下文中一共展示了ScintillaControl.CharAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnChar
static public bool OnChar(ScintillaControl Sci, int Value, int position, int style)
{
if (style == 3 || style == 124)
{
switch (Value)
{
// documentation tag
case '@':
return HandleDocTagCompletion(Sci);
// documentation bloc
case '*':
if ((position > 2) && (Sci.CharAt(position-3) == '/') && (Sci.CharAt(position-2) == '*')
&& ((position == 3) || (Sci.BaseStyleAt(position-4) != 3)))
HandleBoxCompletion(Sci, position);
break;
}
}
return false;
}
示例2: SciControl_BeforeDelete
void SciControl_BeforeDelete(ScintillaControl sender, int position, int length)
{
int c = sender.CharAt(position);
// char c = sender.Text[position];
if (c == bracketOpen)
{
if (sender.CharAt(position + length) != bracketClose)
{
return;
}
}
else if (c == squareBracketOpen)
{
if (sender.CharAt(position + length) != squareBracketClose)
{
return;
}
}
else if (c == quote)
{
if (sender.CharAt(position + length) != quote)
{
return;
}
}
else
return;
sender.BeginInvoke(HanldeRemoveBracket, new object[] { sender });
}
示例3: GenerateDefaultHandlerName
private static void GenerateDefaultHandlerName(ScintillaControl sci, int position, int targetPos, string eventName, bool closeBrace)
{
string target = null;
int contextOwnerPos = GetContextOwnerEndPos(sci, sci.WordStartPosition(targetPos, true));
if (contextOwnerPos != -1)
{
ASResult contextOwnerResult = ASComplete.GetExpressionType(sci, contextOwnerPos);
if (contextOwnerResult != null && !contextOwnerResult.IsNull()
&& contextOwnerResult.Member != null)
{
if (contextOwnerResult.Member.Name == "contentLoaderInfo" && sci.CharAt(contextOwnerPos) == '.')
{
// we want to name the event from the loader var and not from the contentLoaderInfo parameter
contextOwnerPos = GetContextOwnerEndPos(sci, sci.WordStartPosition(contextOwnerPos - 1, true));
if (contextOwnerPos != -1)
{
contextOwnerResult = ASComplete.GetExpressionType(sci, contextOwnerPos);
if (contextOwnerResult != null && !contextOwnerResult.IsNull()
&& contextOwnerResult.Member != null)
{
target = contextOwnerResult.Member.Name;
}
}
}
else
{
target = contextOwnerResult.Member.Name;
}
}
}
eventName = Camelize(eventName.Substring(eventName.LastIndexOf('.') + 1));
if (target != null) target = target.TrimStart(new char[] { '_' });
switch (ASContext.CommonSettings.HandlerNamingConvention)
{
case HandlerNamingConventions.handleTargetEventName:
if (target == null) contextToken = "handle" + Capitalize(eventName);
else contextToken = "handle" + Capitalize(target) + Capitalize(eventName);
break;
case HandlerNamingConventions.onTargetEventName:
if (target == null) contextToken = "on" + Capitalize(eventName);
else contextToken = "on" + Capitalize(target) + Capitalize(eventName);
break;
case HandlerNamingConventions.target_eventNameHandler:
if (target == null) contextToken = eventName + "Handler";
else contextToken = target + "_" + eventName + "Handler";
break;
default: //HandlerNamingConventions.target_eventName
if (target == null) contextToken = eventName;
else contextToken = target + "_" + eventName;
break;
}
char c = (char)sci.CharAt(position - 1);
if (c == ',') InsertCode(position, "$(Boundary) " + contextToken + "$(Boundary)", sci);
else InsertCode(position, contextToken, sci);
position = sci.WordEndPosition(position + 1, true);
sci.SetSel(position, position);
c = (char)sci.CharAt(position);
if (c <= 32) if (closeBrace) sci.ReplaceSel(");"); else sci.ReplaceSel(";");
sci.SetSel(position, position);
}
示例4: GetOrSetPointOfInsertion
/// <summary>
/// Looks for the best next position to insert new code, inserting new lines if needed
/// </summary>
/// <param name="startPos">The position inside the Scintilla document to start looking for the insertion position</param>
/// <param name="endPos">The end position inside the Scintilla document</param>
/// <param name="baseLine">The line inside the document to use as the base for the indentation level and detect if the desired point
/// matches the end line</param>
/// <param name="sci">The ScintillaControl where our document resides</param>
/// <returns>The insertion point position</returns>
private static int GetOrSetPointOfInsertion(int startPos, int endPos, int baseLine, ScintillaControl sci)
{
char[] characterClass = { ' ', '\r', '\n', '\t' };
int nCount = 0;
int extraLine = 1;
int initialLn = sci.LineFromPosition(startPos);
int baseIndent = sci.GetLineIndentation(baseLine);
bool found = false;
while (startPos <= endPos)
{
char c = (char)sci.CharAt(startPos);
if (Array.IndexOf(characterClass, c) == -1)
{
int endLn = sci.LineFromPosition(startPos);
if (endLn == baseLine || endLn == initialLn)
{
sci.InsertText(startPos, sci.NewLineMarker);
// Do we want to set the line indentation no matter what? {\r\t\t\t\r} -> {\r\t\r}
// Better results in most cases, but maybe highly unwanted in others?
sci.SetLineIndentation(++endLn, baseIndent + sci.Indent);
startPos = sci.LineIndentPosition(endLn);
}
if (c == '}')
{
sci.InsertText(startPos, sci.NewLineMarker);
sci.SetLineIndentation(endLn + 1, baseIndent);
// In relation with previous comment... we'll reinden this one: {\r} -> {\r\t\r}
if (sci.GetLineIndentation(endLn) <= baseIndent)
{
sci.SetLineIndentation(endLn, baseIndent + sci.Indent);
startPos = sci.LineIndentPosition(endLn);
}
}
found = true;
break;
}
else if (sci.EOLMode == 1 && c == '\r' && (++nCount) > extraLine)
{
found = true;
break;
}
else if (c == '\n' && (++nCount) > extraLine)
{
if (sci.EOLMode != 2)
{
startPos--;
}
found = true;
break;
}
startPos++;
}
if (!found) startPos--;
return startPos;
}
示例5: ParseFunctionParameters
private static List<FunctionParameter> ParseFunctionParameters(ScintillaControl sci, int p)
{
List<FunctionParameter> prms = new List<FunctionParameter>();
StringBuilder sb = new StringBuilder();
List<ASResult> types = new List<ASResult>();
bool isFuncStarted = false;
bool isDoubleQuote = false;
bool isSingleQuote = false;
bool wasEscapeChar = false;
bool doBreak = false;
bool writeParam = false;
int subClosuresCount = 0;
ASResult result = null;
IASContext ctx = ASContext.Context;
char[] charsToTrim = new char[] { ' ', '\t', '\r', '\n' };
int counter = sci.TextLength; // max number of chars in parameters line (to avoid infinitive loop)
string characterClass = ScintillaControl.Configuration.GetLanguage(sci.ConfigurationLanguage).characterclass.Characters;
int lastMemberPos = p;
// add [] and <>
while (p < counter && !doBreak)
{
char c = (char)sci.CharAt(p++);
if (c == '(' && !isFuncStarted)
{
if (sb.ToString().Trim(charsToTrim).Length == 0)
{
isFuncStarted = true;
}
else
{
break;
}
}
else if (c == ';' && !isFuncStarted)
{
break;
}
else if (c == ')' && isFuncStarted && !wasEscapeChar && !isDoubleQuote && !isSingleQuote && subClosuresCount == 0)
{
isFuncStarted = false;
writeParam = true;
doBreak = true;
}
else if ((c == '(' || c == '[' || c == '<' || c == '{') && !wasEscapeChar && !isDoubleQuote && !isSingleQuote)
{
if (subClosuresCount == 0)
{
if (c == '{')
{
if (sb.ToString().TrimStart().Length > 0)
{
result = new ASResult();
result.Type = ctx.ResolveType("Function", null);
types.Insert(0, result);
}
else
{
result = new ASResult();
result.Type = ctx.ResolveType(ctx.Features.objectKey, null);
types.Insert(0, result);
}
}
else if (c == '(')
{
result = ASComplete.GetExpressionType(sci, lastMemberPos + 1);
if (!result.IsNull())
{
types.Insert(0, result);
}
}
else if (c == '<')
{
if (sb.ToString().TrimStart().Length == 0)
{
result = new ASResult();
result.Type = ctx.ResolveType("XML", null);
types.Insert(0, result);
}
}
}
subClosuresCount++;
sb.Append(c);
wasEscapeChar = false;
}
else if ((c == ')' || c == ']' || c == '>' || c == '}') && !wasEscapeChar && !isDoubleQuote && !isSingleQuote)
{
if (c == ']')
{
result = ASComplete.GetExpressionType(sci, p);
if (result.Type != null) result.Member = null;
else result.Type = ctx.ResolveType(ctx.Features.arrayKey, null);
types.Insert(0, result);
writeParam = true;
}
subClosuresCount--;
sb.Append(c);
wasEscapeChar = false;
}
else if (c == '\\')
//.........这里部分代码省略.........
示例6: NextCharPosition
public static Int32 NextCharPosition(ScintillaControl sci, Int32 position, String c)
{
Int32 curPos = sci.CurrentPos;
sci.GotoPos(position);
char currentChar = (char)sci.CharAt(sci.CurrentPos);
if (currentChar.ToString().Equals(c)) sci.CharRight();
sci.SearchAnchor();
Int32 next = sci.SearchNext(0, c);
sci.GotoPos(curPos);
return next;
}
示例7: GetBodyStart
/// <summary>
/// Tries to get the start position of a code block, delimited by { and }
/// </summary>
/// <param name="lineFrom">The line inside the Scintilla document where the owner member of the body starts</param>
/// <param name="lineTo">The line inside the Scintilla document where the owner member of the body ends</param>
/// <param name="sci">The Scintilla control containing the document</param>
/// <param name="needsPointOfInsertion">If true looks for the position to add new code, inserting new lines if needed</param>
/// <returns>The position inside the Scintilla document, or -1 if not suitable position was found</returns>
public static int GetBodyStart(int lineFrom, int lineTo, ScintillaControl sci, bool needsPointOfInsertion)
{
int posStart = sci.PositionFromLine(lineFrom);
int posEnd = sci.LineEndPosition(lineTo);
int funcBodyStart = -1;
int genCount = 0;
for (int i = posStart; i <= posEnd; i++)
{
char c = (char)sci.CharAt(i);
if (c == '{')
{
int style = sci.BaseStyleAt(i);
if (ASComplete.IsCommentStyle(style) || ASComplete.IsLiteralStyle(style) || genCount > 0)
continue;
funcBodyStart = i;
break;
}
else if (c == '<')
{
int style = sci.BaseStyleAt(i);
if (style == 10)
genCount++;
}
else if (c == '>')
{
int style = sci.BaseStyleAt(i);
if (style == 10)
genCount--;
}
}
if (funcBodyStart == -1)
return -1;
if (needsPointOfInsertion)
{
int ln = sci.LineFromPosition(funcBodyStart);
funcBodyStart++;
return GetOrSetPointOfInsertion(funcBodyStart, posEnd, ln, sci);
}
return funcBodyStart + 1;
}
示例8: ReadAttribute
private string ReadAttribute(ScintillaControl sci, int i)
{
bool inWord = false;
string word = "";
while (i > 1)
{
char c = (char)sci.CharAt(i--);
if (wordChars.IndexOf(c) >= 0)
{
inWord = true;
word = c + word;
}
else if (c > 32) return "";
else if (inWord) break;
}
if (word.Length > 0 && word[0] == '-')
{
Match m = reNavPrefix.Match(word);
if (m.Success) word = m.Groups[1].Value;
}
return word;
}
示例9: OnCharAdded
internal void OnCharAdded(ScintillaControl sci, int position, int value)
{
if (!enabled) return;
bool autoInsert = false;
char c = (char)value;
if (wordChars.IndexOf(c) < 0)
{
if (c == ':')
{
if (lastColonInsert == position - 1)
{
sci.DeleteBack();
lastColonInsert = -1;
return;
}
}
else if (c == ';')
{
char c2 = (char)sci.CharAt(position);
if (c2 == ';')
{
sci.DeleteBack();
sci.SetSel(position, position);
return;
}
}
else if (c == '\n' && !settings.DisableAutoCloseBraces)
{
int line = sci.LineFromPosition(position);
string text = sci.GetLine(line - 1).TrimEnd();
if (text.EndsWith("{")) AutoCloseBrace(sci, line);
}
else if (c == '\t') // TODO get tab notification!
{
position--;
autoInsert = true;
}
else return;
}
var context = GetContext(sci, position);
var mode = CompleteMode.None;
if (context.InComments) return;
else if (context.InBlock)
{
if (context.Word == "-") mode = CompleteMode.Prefix;
else if (context.Word.Length >= 2 || (char)value == '-')
mode = CompleteMode.Attribute;
}
else if (context.InValue)
{
if (features.Mode != "CSS" && c == features.Trigger)
{
context.Word = context.Word.Substring(1);
context.Position++;
mode = CompleteMode.Variable;
}
else if (context.Word.Length == 1 && "abcdefghijklmnopqrstuvwxyz".IndexOf(context.Word[0]) >= 0)
mode = CompleteMode.Value;
}
else if (c == ':' && !context.IsVar) mode = CompleteMode.Pseudo;
HandleCompletion(mode, context, autoInsert, true);
}
示例10: GetContext
private LocalContext GetContext(ScintillaControl sci, int position)
{
var ctx = new LocalContext(sci);
int i = position - 1;
int style = sci.StyleAt(i-1);
if (style == (int)CSS.COMMENT) // inside comments
{
ctx.InComments = true;
return ctx;
}
int inString = 0;
if (style == 14) inString = 1;
if (style == 13) inString = 2;
bool inWord = true;
bool inComment = false;
bool inPar = false;
string word = "";
int lastCharPos = i;
while (i > 1)
{
char c = (char)sci.CharAt(i--);
if (wordChars.IndexOf(c) >= 0)
{
lastCharPos = i + 1;
if (inWord) word = c + word;
}
else inWord = false;
if (inString > 0)
{
if (inString == 1 && c == '\'') inString = 0;
else if (inString == 2 && c == '"') inString = 0;
continue;
}
if (inComment)
{
if (c == '*' && i > 0 && (char)sci.CharAt(i) == '/') inComment = false;
continue;
}
if (c == '/' && i > 0 && (char)sci.CharAt(i) == '*') // entering comment
inComment = true;
if (c == '\'') inString = 1; // entering line
else if (c == '"') inString = 2;
else if (c == ')') inPar = true;
else if (inPar)
{
if (c == '(') inPar = false;
continue;
}
else if (c == ':')
{
ctx.Separator = c;
ctx.Position = lastCharPos;
string attr = ReadAttribute(sci, i);
if (attr.Length > 1)
{
if (attr[0] == features.Trigger || IsVarDecl(sci, i))
ctx.IsVar = true;
else if (!IsTag(attr))
{
ctx.InValue = true;
ctx.Property = attr;
}
}
break;
}
else if (c == ';' || c == '{')
{
ctx.Separator = c;
ctx.Position = lastCharPos;
ctx.InBlock = !IsVarDecl(sci, i);
break;
}
else if (c == '}' || c == ',' || c == '.' || c == '#')
{
ctx.Separator = c;
ctx.Position = lastCharPos;
break;
}
else if (c == '(')
{
string tok = ReadWordLeft(sci, i);
if (tok == "url")
{
ctx.Separator = '(';
ctx.InUrl = true;
ctx.Position = i + 1;
word = "";
for (int j = i + 2; j < position; j++)
word += (char)sci.CharAt(j);
break;
}
}
//.........这里部分代码省略.........
示例11: ReadWordLeft
private string ReadWordLeft(ScintillaControl sci, int i)
{
bool inWord = false;
string word = "";
while (i > 1)
{
char c = (char)sci.CharAt(i--);
if (wordChars.IndexOf(c) >= 0)
{
inWord = true;
word = c + word;
}
else if (inWord) break;
}
return word;
}
示例12: OnInsert
internal void OnInsert(ScintillaControl sci, int position, string text, char trigger, ICompletionListItem item)
{
if (!(item is CompletionItem)) return;
CompletionItem it = item as CompletionItem;
if (trigger == ':')
{
lastColonInsert = position + text.Length + 1;
}
else if (it.Kind == ItemKind.Property && !settings.DisableInsertColon)
{
int pos = position + text.Length;
char c = (char)sci.CharAt(pos);
if (c != ':') sci.InsertText(pos, ":");
sci.SetSel(pos + 1, pos + 1);
lastColonInsert = pos + 1;
}
else lastColonInsert = -1;
}
示例13: thereIsNewWord
/// <summary>
/// Search the word new left current word
/// </summary>
/// <param name="sci"></param>
/// <returns></returns>
private bool thereIsNewWord(ScintillaControl sci)
{
sci.WordLeft();
int pos = sci.CurrentPos;
bool find = true;
while(true)
{
pos--;
if (!char.IsWhiteSpace((char) sci.CharAt(pos)))
{
pos++;
break;
}
}
for (int i = 0; i < 3; i++)
{
pos--;
if (sci.CharAt(pos) != newChars[i])
{
find = false;
break;
}
}
return find;
}
示例14: SciControl_CharAdded
unsafe void SciControl_CharAdded(ScintillaControl sender, int ch)
{
if (ch == bracketOpen)
{
insert = arrBracketClose;
}
else if (ch == quote)
{
insert = arrQuote;
}
else if (ch == squareBracketOpen)
{
insert = arrSquareBracketClose;
}
else if (ch == bracketClose)
{
if (sender.CharAt(sender.CurrentPos) == bracketClose)
{
// temporary disable
sender.ModEventMask ^= (Int32)ScintillaNet.Enums.ModificationFlags.BeforeDelete;
sender.CharRight();
sender.DeleteBack();
sender.ModEventMask ^= (Int32)ScintillaNet.Enums.ModificationFlags.BeforeDelete;
return;
}
return;
}
else if (ch == squareBracketClose)
{
if (sender.CharAt(sender.CurrentPos) == squareBracketClose)
{
// temporary disable
sender.ModEventMask ^= (Int32)ScintillaNet.Enums.ModificationFlags.BeforeDelete;
sender.CharRight();
sender.DeleteBack();
sender.ModEventMask ^= (Int32)ScintillaNet.Enums.ModificationFlags.BeforeDelete;
return;
}
return;
}
else
{
return;
}
int pos = sender.CurrentPos;
uint actPos = (uint)pos;
char character;
do
{
character =(char) sender.CharAt(pos);
if (character == '\n') break;
if (!Char.IsWhiteSpace(character)) break;
pos++;
} while (true);
// if (Char.IsLetterOrDigit(character) || character == ch || character == insert[0]) return;
if (Char.IsLetterOrDigit(character) || character == ch ) return;
int stylemask = (1 << sender.StyleBits) - 1;
bool isTextStyle = ASComplete.IsTextStyle(sender.StyleAt(sender.CurrentPos) & stylemask);
int style = sender.StyleAt(sender.CurrentPos - 1) & stylemask;
if (ch == quote)
{
if (!isTextStyle)
{
fixed (byte* b = System.Text.Encoding.GetEncoding(sender.CodePage).GetBytes(insert))
{
sender.SPerform(2003, actPos, (uint)b);
}
}
return;
}
if (!ASComplete.IsTextStyle(style) && !isTextStyle)
{
return;
}
fixed (byte* b = System.Text.Encoding.GetEncoding(sender.CodePage).GetBytes(insert))
{
sender.SPerform(2003, actPos, (uint)b);
}
}
示例15: PreviousNonWhiteCharPosition
public static Int32 PreviousNonWhiteCharPosition(ScintillaControl sci, Int32 position)
{
Int32 pos = position;
Int32 bef = sci.PositionBefore(pos);
if (bef == pos)
return -1;
while (IsWhiteChar(sci.CharAt(bef)) == true)
{
pos = bef;
bef = sci.PositionBefore(pos);
if (bef == pos)
return -1;
}
return bef;
}