本文整理汇总了C#中ScintillaNet.BaseStyleAt方法的典型用法代码示例。如果您正苦于以下问题:C# ScintillaNet.BaseStyleAt方法的具体用法?C# ScintillaNet.BaseStyleAt怎么用?C# ScintillaNet.BaseStyleAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScintillaNet
的用法示例。
在下文中一共展示了ScintillaNet.BaseStyleAt方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnChar
static public bool OnChar(ScintillaNet.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: ContextualGenerator
static public void ContextualGenerator(ScintillaNet.ScintillaControl Sci)
{
if (ASContext.Context is ASContext) (ASContext.Context as ASContext).UpdateCurrentFile(false); // update model
if ((ASContext.Context.CurrentClass.Flags & (FlagType.Enum | FlagType.TypeDef)) > 0) return;
lookupPosition = -1;
int position = Sci.CurrentPos;
if (Sci.BaseStyleAt(position) == 19) // on keyword
return;
bool isNotInterface = (ASContext.Context.CurrentClass.Flags & FlagType.Interface) == 0;
int line = Sci.LineFromPosition(position);
contextToken = Sci.GetWordFromPosition(position);
contextMatch = null;
FoundDeclaration found = GetDeclarationAtLine(Sci, line);
string text = Sci.GetLine(line);
bool suggestItemDeclaration = false;
if (isNotInterface && !String.IsNullOrEmpty(contextToken) && Char.IsDigit(contextToken[0]))
{
ShowConvertToConst(found);
return;
}
ASResult resolve = ASComplete.GetExpressionType(Sci, Sci.WordEndPosition(position, true));
contextResolved = resolve;
// ignore automatic vars (MovieClip members)
if (isNotInterface
&& resolve.Member != null
&& (((resolve.Member.Flags & FlagType.AutomaticVar) > 0) || (resolve.InClass != null && resolve.InClass.QualifiedName == "Object")))
{
resolve.Member = null;
resolve.Type = null;
}
if (isNotInterface && found.inClass != ClassModel.VoidClass && contextToken != null)
{
if (resolve.Member == null && resolve.Type != null
&& (resolve.Type.Flags & FlagType.Interface) > 0) // implement interface
{
contextParam = resolve.Type.Type;
ShowImplementInterface(found);
return;
}
if (resolve.Member != null && !ASContext.Context.CurrentClass.IsVoid()
&& (resolve.Member.Flags & FlagType.LocalVar) > 0) // promote to class var
{
contextMember = resolve.Member;
ShowPromoteLocalAndAddParameter(found);
return;
}
}
if (contextToken != null && resolve.Member == null) // import declaration
{
if ((resolve.Type == null || resolve.Type.IsVoid() || !ASContext.Context.IsImported(resolve.Type, line)) && CheckAutoImport(found)) return;
if (resolve.Type == null)
{
int stylemask = (1 << Sci.StyleBits) - 1;
suggestItemDeclaration = ASComplete.IsTextStyle(Sci.StyleAt(position - 1) & stylemask);
}
}
if (isNotInterface && found.member != null)
{
// private var -> property
if ((found.member.Flags & FlagType.Variable) > 0 && (found.member.Flags & FlagType.LocalVar) == 0)
{
// maybe we just want to import the member's non-imported type
Match m = Regex.Match(text, String.Format(patternVarDecl, found.member.Name, contextToken));
if (m.Success)
{
contextMatch = m;
ClassModel type = ASContext.Context.ResolveType(contextToken, ASContext.Context.CurrentModel);
if (type.IsVoid() && CheckAutoImport(found))
return;
}
ShowGetSetList(found);
return;
}
// inside a function
else if ((found.member.Flags & (FlagType.Function | FlagType.Getter | FlagType.Setter)) > 0
&& resolve.Member == null && resolve.Type == null)
{
if (contextToken != null)
{
// "generate event handlers" suggestion
string re = String.Format(patternEvent, contextToken);
Match m = Regex.Match(text, re, RegexOptions.IgnoreCase);
if (m.Success)
{
contextMatch = m;
contextParam = CheckEventType(m.Groups["event"].Value);
ShowEventList(found);
return;
}
m = Regex.Match(text, String.Format(patternAS2Delegate, contextToken), RegexOptions.IgnoreCase);
if (m.Success)
//.........这里部分代码省略.........
示例3: OnMouseHover
private void OnMouseHover(ScintillaNet.ScintillaControl sci, int position)
{
if (ASContext.Locked || !ASContext.Context.IsFileValid())
return;
// get word at mouse position
int style = sci.BaseStyleAt(position);
DebugConsole.Trace("Style="+style);
if (!ASComplete.IsTextStyle(style))
return;
position = sci.WordEndPosition(position, true);
ASResult result = ASComplete.GetExpressionType(sci, position);
// set tooltip
if (!result.IsNull())
{
string text = ASComplete.GetToolTipText(result);
DebugConsole.Trace("SHOW "+text);
if (text == null) return;
// show tooltip
InfoTip.ShowAtMouseLocation(text);
}
}
示例4: ContextualGenerator
static public void ContextualGenerator(ScintillaNet.ScintillaControl Sci)
{
if (ASContext.Context is ASContext)
(ASContext.Context as ASContext).UpdateCurrentFile(false); // update model
lookupPosition = -1;
int position = Sci.CurrentPos;
if (Sci.BaseStyleAt(position) == 19) // on keyword
return;
int line = Sci.LineFromPosition(position);
contextToken = Sci.GetWordFromPosition(position);
contextMatch = null;
FoundDeclaration found = GetDeclarationAtLine(Sci, line);
string text = Sci.GetLine(line);
bool suggestItemDeclaration = false;
if (!String.IsNullOrEmpty(contextToken) && Char.IsDigit(contextToken[0]))
{
ShowConvertToConst(found);
return;
}
ASResult resolve = ASComplete.GetExpressionType(Sci, Sci.WordEndPosition(position, true));
// ignore automatic vars (MovieClip members)
if (resolve.Member != null &&
(((resolve.Member.Flags & FlagType.AutomaticVar) > 0)
|| (resolve.inClass != null && resolve.inClass.QualifiedName == "Object")))
{
resolve.Member = null;
resolve.Type = null;
}
if (found.inClass != ClassModel.VoidClass && contextToken != null)
{
if (resolve.Member == null && resolve.Type != null
&& (resolve.Type.Flags & FlagType.Interface) > 0) // implement interface
{
contextParam = resolve.Type.Type;
ShowImplementInterface(found);
return;
}
if (resolve.Member != null && !ASContext.Context.CurrentClass.IsVoid()
&& (resolve.Member.Flags & FlagType.LocalVar) > 0) // promote to class var
{
contextMember = resolve.Member;
ShowPromoteLocalAndAddParameter(found);
return;
}
if (resolve.Member == null && resolve.Type == null) // import declaration
{
if (CheckAutoImport(found))
{
return;
}
else
{
int stylemask = (1 << Sci.StyleBits) - 1;
if (ASComplete.IsTextStyle(Sci.StyleAt(position - 1) & stylemask))
{
suggestItemDeclaration = true;
}
}
}
}
if (found.member != null)
{
// private var -> property
if ((found.member.Flags & FlagType.Variable) > 0 && (found.member.Flags & FlagType.LocalVar) == 0)
{
// maybe we just want to import the member's non-imported type
Match m = Regex.Match(text, String.Format(patternVarDecl, found.member.Name, contextToken));
if (m.Success)
{
contextMatch = m;
ClassModel type = ASContext.Context.ResolveType(contextToken, ASContext.Context.CurrentModel);
if (type.IsVoid() && CheckAutoImport(found))
return;
}
// create property
ShowGetSetList(found);
return;
}
// inside a function
else if ((found.member.Flags & (FlagType.Function | FlagType.Getter | FlagType.Setter)) > 0
&& resolve.Member == null && resolve.Type == null)
{
if (contextToken != null)
{
// "generate event handlers" suggestion
Match m = Regex.Match(text, String.Format(patternEvent, contextToken), RegexOptions.IgnoreCase);
if (m.Success)
{
contextMatch = m;
contextParam = CheckEventType(m.Groups["event"].Value);
ShowEventList(found);
return;
//.........这里部分代码省略.........
示例5: OnUpdateCallTip
private void OnUpdateCallTip(ScintillaNet.ScintillaControl sci, int position)
{
if (ASComplete.HasCalltip())
{
int pos = sci.CurrentPos - 1;
char c = (char)sci.CharAt(pos);
if ((c == ',' || c == '(') && sci.BaseStyleAt(pos) == 0)
sci.Colourise(0, -1);
ASComplete.HandleFunctionCompletion(sci, false, true);
}
}
示例6: HandleFunctionCompletion
/// <summary>
/// Display method signature
/// </summary>
/// <param name="Sci">Scintilla control</param>
/// <returns>Auto-completion has been handled</returns>
static public bool HandleFunctionCompletion(ScintillaNet.ScintillaControl Sci)
{
// find method
int position = Sci.CurrentPos-1;
int parCount = 0;
int braCount = 0;
int comaCount = 0;
int arrCount = 0;
int style = 0;
int stylemask = (1 << Sci.StyleBits) -1;
char c;
while (position >= 0)
{
style = Sci.StyleAt(position) & stylemask;
if (style == 19)
{
string keyword = GetWordLeft(Sci, ref position);
DebugConsole.Trace("Keyword "+keyword);
if (!"new".StartsWith(keyword))
{
position = -1;
break;
}
}
if (IsTextStyleEx(style))
{
c = (char)Sci.CharAt(position);
if (c == ';')
{
position = -1;
break;
}
// skip {} () [] blocks
if ( ((braCount > 0) && (c != '{'))
|| ((arrCount > 0) && (c != '['))
|| ((parCount > 0) && (c != '(')))
{
position--;
continue;
}
// new block
if (c == '}') braCount++;
else if (c == ']') arrCount++;
else if (c == ')') parCount++;
// block closed
else if (c == '{')
{
if (braCount == 0) comaCount = 0;
else braCount--;
}
else if (c == '[')
{
if (arrCount == 0) comaCount = 0;
else arrCount--;
}
else if (c == '(')
{
if (--parCount < 0)
// function start found
break;
}
// new parameter reached
else if (c == ',' && parCount == 0 && Sci.BaseStyleAt(position) != 6)
comaCount++;
}
position--;
}
// continuing calltip ?
if (HasCalltip())
{
if (calltipPos == position)
{
ShowCalltip(Sci, comaCount);
return true;
}
else InfoTip.Hide();
}
else if (position < 0)
return false;
// get expression at cursor position
ASExpr expr = GetExpression(Sci, position);
DebugConsole.Trace("Expr: "+expr.Value);
if (expr.Value == null || expr.Value.Length == 0 || expr.separator == ':'
|| (expr.Keyword == "function" && expr.separator == ' '))
return false;
DebugConsole.Trace("** Display method parameters");
DebugConsole.Trace(expr.Value);
// Context
expr.LocalVars = ParseLocalVars(expr);
ASClass aClass = ASContext.CurrentClass;
// Expression before cursor
ASResult result = EvalExpression(expr.Value, expr, aClass, true);
//.........这里部分代码省略.........
示例7: HandleStructureCompletion
static private bool HandleStructureCompletion(ScintillaNet.ScintillaControl Sci)
{
try
{
int position = Sci.CurrentPos;
int line = Sci.LineFromPosition(position);
if (line == 0)
return false;
string txt = Sci.GetLine(line-1);
int style = Sci.BaseStyleAt(position);
int eolMode = Sci.EOLMode;
// box comments
if (IsCommentStyle(style) && (Sci.BaseStyleAt(position+1) == style))
{
txt = txt.Trim();
if (txt.StartsWith("/*") || txt.StartsWith("*"))
{
Sci.ReplaceSel("* ");
position = Sci.LineIndentPosition(line)+2;
Sci.SetSel(position,position);
return true;
}
}
// braces
else if (txt.TrimEnd().EndsWith("{") && (line > 1))
{
// find matching brace
int bracePos = Sci.LineEndPosition(line-1)-1;
while ((bracePos > 0) && (Sci.CharAt(bracePos) != '{')) bracePos--;
if (bracePos == 0 || Sci.BaseStyleAt(bracePos) != 10) return true;
int match = Sci.SafeBraceMatch(bracePos);
DebugConsole.Trace("match "+bracePos+" "+match);
int start = line;
int indent = Sci.GetLineIndentation(start-1);
if (match > 0)
{
int endIndent = Sci.GetLineIndentation(Sci.LineFromPosition(match));
if (endIndent+Sci.TabWidth > indent)
return false;
}
// find where to include the closing brace
int startIndent = indent;
int newIndent = indent+Sci.TabWidth;
int count = Sci.LineCount;
int lastLine = line;
line++;
while (line < count-1)
{
txt = Sci.GetLine(line).TrimEnd();
if (txt.Length != 0) {
indent = Sci.GetLineIndentation(line);
DebugConsole.Trace("indent "+(line+1)+" "+indent+" : "+txt);
if (indent <= startIndent) break;
lastLine = line;
}
else break;
line++;
}
if (line >= count-1) lastLine = start;
// insert closing brace
DebugConsole.Trace("Insert at "+position);
position = Sci.LineEndPosition(lastLine);
Sci.InsertText(position, ASContext.MainForm.GetNewLineMarker(eolMode)+"}");
Sci.SetLineIndentation(lastLine+1, startIndent);
return false;
}
}
catch (Exception ex)
{
ErrorHandler.ShowError(ex.Message, ex);
}
return false;
}