本文整理汇总了C#中ScintillaNet.MBSafePosition方法的典型用法代码示例。如果您正苦于以下问题:C# ScintillaNet.MBSafePosition方法的具体用法?C# ScintillaNet.MBSafePosition怎么用?C# ScintillaNet.MBSafePosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScintillaNet
的用法示例。
在下文中一共展示了ScintillaNet.MBSafePosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteActionPoint
/// <summary>
/// Selects the text specified in the action point
/// </summary>
public static void ExecuteActionPoint(ActionPoint point, ScintillaNet.ScintillaControl sci)
{
if (point.EntryPosition != -1 && point.ExitPosition != -1)
{
Int32 start = sci.MBSafePosition(point.EntryPosition);
Int32 end = sci.MBSafePosition(point.ExitPosition);
sci.SetSel(start, end);
}
else if (point.EntryPosition != -1 && point.ExitPosition == -1)
{
Int32 start = sci.MBSafePosition(point.EntryPosition);
sci.SetSel(start, start);
}
}
示例2: PostProcessSnippets
/// <summary>
/// Processes the snippet and template arguments
/// </summary>
public static Int32 PostProcessSnippets(ScintillaNet.ScintillaControl sci, Int32 currentPosition)
{
Int32 delta = 0;
while (sci.SelectText(BOUNDARY, 0) != -1) { sci.ReplaceSel(""); delta -= BOUNDARY.Length; }
String text = sci.Text; // Store text temporarily
Int32 entryPosition = sci.MBSafePosition(text.IndexOf(ENTRYPOINT));
Int32 exitPosition = sci.MBSafePosition(text.IndexOf(EXITPOINT));
if (entryPosition != -1 && exitPosition != -1)
{
sci.SelectText(ENTRYPOINT, 0); sci.ReplaceSel(""); delta -= ENTRYPOINT.Length;
sci.SelectText(EXITPOINT, 0); sci.ReplaceSel(""); delta -= EXITPOINT.Length;
sci.SetSel(entryPosition, exitPosition - ENTRYPOINT.Length);
}
else if (entryPosition != -1 && exitPosition == -1)
{
sci.SelectText(ENTRYPOINT, 0); sci.ReplaceSel(""); delta -= ENTRYPOINT.Length;
sci.SetSel(entryPosition, entryPosition);
}
else sci.SetSel(currentPosition, currentPosition);
return delta;
}
示例3: IsMatchTheTarget
/// <summary>
/// Checks if the given match actually is the declaration.
/// </summary>
public static bool IsMatchTheTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target)
{
if (Sci == null || target == null || target.InFile == null || target.Member == null)
{
return false;
}
String originalFile = Sci.FileName;
// get type at match position
ASResult declaration = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value));
return (declaration.InFile != null && originalFile == declaration.InFile.FileName) && (Sci.CurrentPos == (Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value)));
}
示例4: DoesMatchPointToTarget
/// <summary>
/// Checks if a given search match actually points to the given target source
/// </summary
/// <returns>True if the SearchMatch does point to the target source.</returns>
public static bool DoesMatchPointToTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target, DocumentHelper associatedDocumentHelper)
{
if (Sci == null || target == null) return false;
FileModel targetInFile = null;
if (target.InFile != null)
targetInFile = target.InFile;
else if (target.Member != null && target.InClass == null)
targetInFile = target.Member.InFile;
Boolean matchMember = targetInFile != null && target.Member != null;
Boolean matchType = target.Member == null && target.IsStatic && target.Type != null;
if (!matchMember && !matchType) return false;
ASResult result = null;
// get type at match position
if (match.Index < Sci.Text.Length) // TODO: find out rare cases of incorrect index reported
{
result = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value));
if (associatedDocumentHelper != null)
{
// because the declaration lookup opens a document, we should register it with the document helper to be closed later
associatedDocumentHelper.RegisterLoadedDocument(PluginBase.MainForm.CurrentDocument);
}
}
// check if the result matches the target
if (result == null || (result.InFile == null && result.Type == null)) return false;
if (matchMember)
{
if (result.Member == null) return false;
var resultInFile = result.InClass != null ? result.InFile : result.Member.InFile;
return resultInFile.BasePath == targetInFile.BasePath
&& resultInFile.FileName == targetInFile.FileName
&& result.Member.LineFrom == target.Member.LineFrom
&& result.Member.Name == target.Member.Name;
}
else // type
{
if (result.Type == null) return false;
if (result.Type.QualifiedName == target.Type.QualifiedName) return true;
return false;
}
}
示例5: GotoPosAndFocus
public void GotoPosAndFocus(ScintillaNet.ScintillaControl sci, int position)
{
int pos = sci.MBSafePosition(position);
int line = sci.LineFromPosition(pos);
sci.EnsureVisible(line);
sci.GotoPos(pos);
}
示例6: DoesMatchPointToTarget
/// <summary>
/// Checks if a given search match actually points to the given target source
/// </summary
/// <returns>True if the SearchMatch does point to the target source.</returns>
static public bool DoesMatchPointToTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target, DocumentHelper associatedDocumentHelper)
{
if (Sci == null || target == null || target.inFile == null || target.Member == null)
{
return false;
}
// get type at match position
ASResult result = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value));
if (associatedDocumentHelper != null)
{
// because the declaration lookup opens a document, we should register it with the document helper to be closed later
associatedDocumentHelper.RegisterLoadedDocument(PluginBase.MainForm.CurrentDocument);
}
// check if the result matches the target
// TODO: this method of checking their equality seems pretty crude -- is there a better way?
if (result == null || result.inFile == null || result.Member == null)
{
return false;
}
Boolean doesMatch = result.inFile.BasePath == target.inFile.BasePath && result.inFile.FileName == target.inFile.FileName && result.Member.LineFrom == target.Member.LineFrom && result.Member.Name == target.Member.Name;
return (doesMatch);
}