本文整理汇总了C#中ScintillaNet.ScintillaControl.MBSafeCharPosition方法的典型用法代码示例。如果您正苦于以下问题:C# ScintillaControl.MBSafeCharPosition方法的具体用法?C# ScintillaControl.MBSafeCharPosition怎么用?C# ScintillaControl.MBSafeCharPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScintillaNet.ScintillaControl
的用法示例。
在下文中一共展示了ScintillaControl.MBSafeCharPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNextDocumentMatch
/// <summary>
/// Gets the next valid match but fixes position with selected text's length
/// </summary>
public static SearchMatch GetNextDocumentMatch(ScintillaControl sci, List<SearchMatch> matches, Boolean forward, Boolean fixedPosition)
{
SearchMatch nearestMatch = matches[0];
Int32 currentPosition = sci.MBSafeCharPosition(sci.CurrentPos);
if (fixedPosition) currentPosition -= sci.MBSafeTextLength(sci.SelText);
for (Int32 i = 0; i < matches.Count; i++)
{
if (forward)
{
if (currentPosition > matches[matches.Count - 1].Index)
{
return matches[0];
}
if (matches[i].Index >= currentPosition)
{
return matches[i];
}
}
else
{
if (sci.SelText.Length > 0 && currentPosition <= matches[0].Index + matches[0].Value.Length)
{
return matches[matches.Count - 1];
}
if (currentPosition < matches[0].Index + matches[0].Value.Length)
{
return matches[matches.Count - 1];
}
if (sci.SelText.Length == 0 && currentPosition == matches[i].Index + matches[i].Value.Length)
{
return matches[i];
}
if (matches[i].Index > nearestMatch.Index && matches[i].Index + matches[i].Value.Length < currentPosition)
{
nearestMatch = matches[i];
}
}
}
return nearestMatch;
}
示例2: SearchNextNewLineWithoutChar
private static int SearchNextNewLineWithoutChar(ScintillaControl sender, int position, string text, ref char firstChar)
{
char c;
int safe = sender.MBSafeCharPosition(position);
int search = safe + text.Length;
// int pos = 0;
bool findNewLineBefore = false;
do
{
c = sender.Text[search];
if(!char.IsWhiteSpace(c)) break;
if (c == '\n' || c=='\r') findNewLineBefore = true;
search++;
} while (true);
firstChar = c;
if (findNewLineBefore)
{
return 1;
}
return 0;
}
示例3: GetWordFromPosition
/// <summary>
/// Gets a word from the specified position
/// </summary>
public static string GetWordFromPosition(ScintillaControl sci,int position, ref int start, ref int end)
{
try
{
//startPosition = sci.MBSafeCharPosition(sci.WordStartPosition(position, true));
//endPosition = sci.MBSafeCharPosition(sci.WordEndPosition(position, true));
//string keyword = sci.Text.Substring(startPosition, endPosition - startPosition);
start = sci.WordStartPosition(position, true);
end = sci.WordEndPosition(position, true);
int startPosition = sci.MBSafeCharPosition(start);
int endPosition = sci.MBSafeCharPosition(end);
string keyword = sci.Text.Substring(startPosition, endPosition - startPosition);
if (keyword.Length==0 || keyword.Equals(" ")) return null;
//startPosition = sci.WordStartPosition(position, true);
//endPosition = sci.WordEndPosition(position, true);
return keyword.Trim();
}
catch
{
return null;
}
}
示例4: GetNextDocumentMatch
public static SearchMatch GetNextDocumentMatch(ScintillaControl sci, List<SearchMatch> matches, int position)
{
SearchMatch nearestMatch = matches[0];
Int32 currentPosition = sci.MBSafeCharPosition(position);
for (Int32 i = 0; i < matches.Count; i++)
{
if (currentPosition > matches[matches.Count - 1].Index)
{
return matches[0];
}
if (matches[i].Index >= currentPosition)
{
return matches[i];
}
}
return nearestMatch;
}