本文整理汇总了C#中ScintillaNet.ScintillaControl.GetWordFromPosition方法的典型用法代码示例。如果您正苦于以下问题:C# ScintillaControl.GetWordFromPosition方法的具体用法?C# ScintillaControl.GetWordFromPosition怎么用?C# ScintillaControl.GetWordFromPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScintillaNet.ScintillaControl
的用法示例。
在下文中一共展示了ScintillaControl.GetWordFromPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContextualGenerator
public static void ContextualGenerator(ScintillaControl Sci, List<ICompletionListItem> options)
{
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;
int style = Sci.BaseStyleAt(position);
if (style == 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 && ASComplete.IsLiteralStyle(style))
{
ShowConvertToConst(found, options);
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, options);
return;
}
if (resolve.Member != null && !ASContext.Context.CurrentClass.IsVoid()
&& (resolve.Member.Flags & FlagType.LocalVar) > 0) // promote to class var
{
contextMember = resolve.Member;
ShowPromoteLocalAndAddParameter(found, options);
return;
}
}
if (contextToken != null && resolve.Member == null) // import declaration
{
if ((resolve.Type == null || resolve.Type.IsVoid() || !ASContext.Context.IsImported(resolve.Type, line)) && CheckAutoImport(found, options)) return;
if (resolve.Type == null)
{
suggestItemDeclaration = ASComplete.IsTextStyle(Sci.BaseStyleAt(position - 1));
}
}
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, options))
return;
}
ShowGetSetList(found, options);
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, options);
return;
}
m = Regex.Match(text, String.Format(patternAS2Delegate, contextToken), RegexOptions.IgnoreCase);
//.........这里部分代码省略.........
示例2: GetStatementReturnType
private static StatementReturnType GetStatementReturnType(ScintillaControl sci, ClassModel inClass, string line, int startPos)
{
Regex target = new Regex(@"[;\s\n\r]*", RegexOptions.RightToLeft);
Match m = target.Match(line);
if (!m.Success)
{
return null;
}
line = line.Substring(0, m.Index);
if (line.Length == 0)
{
return null;
}
line = ReplaceAllStringContents(line);
ASResult resolve = null;
int pos = -1;
string word = null;
ClassModel type = null;
if (line[line.Length - 1] == ')')
{
pos = -1;
int lastIndex = 0;
int bracesBalance = 0;
while (true)
{
int pos1 = line.IndexOf('(', lastIndex);
int pos2 = line.IndexOf(')', lastIndex);
if (pos1 != -1 && pos2 != -1)
{
lastIndex = Math.Min(pos1, pos2);
}
else if (pos1 != -1 || pos2 != -1)
{
lastIndex = Math.Max(pos1, pos2);
}
else
{
break;
}
if (lastIndex == pos1)
{
bracesBalance++;
if (bracesBalance == 1)
{
pos = lastIndex;
}
}
else if (lastIndex == pos2)
{
bracesBalance--;
}
lastIndex++;
}
}
else
{
pos = line.Length;
}
if (pos != -1)
{
line = line.Substring(0, pos);
pos += startPos;
pos -= line.Length - line.TrimEnd().Length + 1;
pos = sci.WordEndPosition(pos, true);
resolve = ASComplete.GetExpressionType(sci, pos);
if (resolve.IsNull()) resolve = null;
word = sci.GetWordFromPosition(pos);
}
IASContext ctx = inClass.InFile.Context;
m = Regex.Match(line, "new\\s+([\\w\\d.<>,_$-]+)+(<[^]]+>)|(<[^]]+>)", RegexOptions.IgnoreCase);
if (m.Success)
{
string m1 = m.Groups[1].Value;
string m2 = m.Groups[2].Value;
string cname;
if (string.IsNullOrEmpty(m1) && string.IsNullOrEmpty(m2))
cname = m.Groups[0].Value;
else
cname = String.Concat(m1, m2);
if (cname.StartsWith('<'))
cname = "Vector." + cname; // literal vector
type = ctx.ResolveType(cname, inClass.InFile);
if (!type.IsVoid()) resolve = null;
}
else
{
char c = (char)sci.CharAt(pos);
if (c == '"' || c == '\'')
{
type = ctx.ResolveType(ctx.Features.stringKey, inClass.InFile);
}
//.........这里部分代码省略.........
示例3: OnUpdateUI
/// <summary>
/// Support for selection highlighting and selection changed event
/// </summary>
private void OnUpdateUI(ScintillaControl sci)
{
if (lastSelectionStart != sci.SelectionStart || lastSelectionEnd != sci.SelectionEnd || lastSelectionLength != sci.SelText.Length)
{
if (SelectionChanged != null) SelectionChanged(sci);
switch (PluginBase.MainForm.Settings.HighlightMatchingWordsMode) // Handle selection highlighting
{
case Enums.HighlightMatchingWordsMode.SelectionOrPosition:
{
StartHighlightSelectionTimer(sci);
break;
}
case Enums.HighlightMatchingWordsMode.SelectedWord:
{
if (sci.SelText == sci.GetWordFromPosition(sci.CurrentPos))
{
StartHighlightSelectionTimer(sci);
}
break;
}
}
}
lastSelectionStart = sci.SelectionStart;
lastSelectionEnd = sci.SelectionEnd;
lastSelectionLength = sci.SelText.Length;
}
示例4: PositionInfos
public PositionInfos(ScintillaControl sci, Int32 position, String argString)
{
// Variables
String[] vars = argString.Split('¤');
this.ArgCurWord = vars[0];
this.ArgPackageName = vars[1];
this.ArgClassName = vars[2];
this.ArgClassType = vars[3];
this.ArgMemberName = vars[4];
this.ArgMemberType = vars[5];
// Selection
Int32 ss = sci.SelectionStart;
Int32 se = sci.SelectionEnd;
if (se != ss)
{
this.SelectionStart = ss;
this.SelectionEnd = se;
this.HasSelection = true;
if (sci.LineFromPosition(ss) != sci.LineFromPosition(se))
this.SelectionIsMultiline = true;
else SelectedText = sci.SelText;
}
// Current
this.CurrentPosition = position;
this.CurrentCharCode = sci.CharAt(position);
this.CurrentIsWhiteChar = (HelpTools.IsWhiteChar(this.CurrentCharCode));
this.CurrentIsDotChar = (this.CurrentCharCode == 46);
this.CurrentIsActionScriptChar = HelpTools.IsActionScriptChar(this.CurrentCharCode);
this.CurrentIsWordChar = HelpTools.IsWordChar((byte)this.CurrentCharCode);
Int32 s = sci.StyleAt(position);
this.CurrentIsInsideComment = (s == 1 || s == 2 || s == 3 || s == 17);
// Next
Int32 np = sci.PositionAfter(position);
if (np != position)
this.NextPosition = np;
else
this.CaretIsAtEndOfDocument = true;
// Word
this.CodePage = sci.CodePage; // (UTF-8|Big Endian|Little Endian : 65001) (8 Bits|UTF-7 : 0)
if (this.CurrentIsInsideComment == false && this.SelectionIsMultiline == false)
{
Int32 wsp = sci.WordStartPosition(position, true);
// Attention (WordEndPosition n'est pas estimé comme par defaut)
Int32 wep = sci.PositionBefore(sci.WordEndPosition(position, true));
if (this.CodePage != 65001)
{
wsp = HelpTools.GetWordStartPositionByWordChar(sci, position);
// Attention (WordEndPosition n'est pas estimé comme par defaut)
wep = sci.PositionBefore(HelpTools.GetWordEndPositionByWordChar(sci, position));
}
this.WordStartPosition = wsp;
this.WordEndPosition = wep;
if (this.CodePage == 65001)
this.WordFromPosition = this.ArgCurWord;
else
this.WordFromPosition = HelpTools.GetText(sci, wsp, sci.PositionAfter(wep));
if (position > wep)
this.CaretIsAfterLastLetter = true;
}
// Previous
if (this.CurrentPosition > 0)
{
this.PreviousPosition = sci.PositionBefore(position);
this.PreviousCharCode = sci.CharAt(this.PreviousPosition);
this.PreviousIsWhiteChar = HelpTools.IsWhiteChar(this.PreviousCharCode);
this.PreviousIsDotChar = (this.PreviousCharCode == 46);
this.PreviousIsActionScriptChar = HelpTools.IsActionScriptChar(this.PreviousCharCode);
}
// Line
this.CurrentLineIdx = sci.LineFromPosition(position);
if (this.CurrentPosition > 0)
this.PreviousLineIdx = sci.LineFromPosition(this.PreviousPosition);
this.LineIdxMax = sci.LineCount - 1;
this.LineStartPosition = HelpTools.LineStartPosition(sci, this.CurrentLineIdx);
this.LineEndPosition = sci.LineEndPosition(this.CurrentLineIdx);
this.NewLineMarker = LineEndDetector.GetNewLineMarker(sci.EOLMode);
// Previous / Next
if (this.WordStartPosition != -1)
{
this.PreviousNonWhiteCharPosition = HelpTools.PreviousNonWhiteCharPosition(sci, this.WordStartPosition);
this.PreviousWordIsFunction = (sci.GetWordFromPosition(this.PreviousNonWhiteCharPosition) == "function");
this.NextNonWhiteCharPosition = HelpTools.NextNonWhiteCharPosition(sci, this.WordEndPosition);
}
// Function
if (this.PreviousWordIsFunction)
{
//.........这里部分代码省略.........
示例5: UpdateHighlightUnderCursor
/// <summary>
///
/// </summary>
private void UpdateHighlightUnderCursor(ScintillaControl sci)
{
string file = PluginBase.MainForm.CurrentDocument.FileName;
if (!IsValidFile(file)) return;
int currentPos = sci.CurrentPos;
string newToken = sci.GetWordFromPosition(currentPos);
if (!string.IsNullOrEmpty(newToken)) newToken = newToken.Trim();
if (!string.IsNullOrEmpty(newToken))
{
if (prevResult == null && prevToken == newToken) return;
ASResult result = IsValidFile(file) ? ASComplete.GetExpressionType(sci, sci.WordEndPosition(currentPos, true)) : null;
if (result != null && !result.IsNull())
{
if (prevResult != null && (result.Member != prevResult.Member || result.Type != prevResult.Type || result.Path != prevResult.Path)) return;
RemoveHighlights(sci);
prevToken = newToken;
prevResult = result;
List<SearchMatch> matches = FilterResults(GetResults(sci, prevToken), result, sci);
if (matches == null || matches.Count == 0) return;
highlightUnderCursorTimer.Stop();
AddHighlights(sci, matches);
}
else RemoveHighlights(sci);
}
else RemoveHighlights(sci);
}