Bug fix for disabling the GOTO Button when you right arrow off of linked text.
Find/Replace logic.
This commit is contained in:
parent
281ef2abd3
commit
ed53060f48
@ -1647,7 +1647,34 @@ namespace Volian.Controls.Library
|
||||
int selLength = len;
|
||||
foreach (LinkLocation ll in _LinkLocations)
|
||||
{
|
||||
if (sel >= ll.Start && sel < ll.Start + ll.Length + 7) return true;
|
||||
// When the selector moved to the right of a link, the GOTO button was still lit.
|
||||
// Removing the "+7" seems to have fixed this. - jsj 1/08/2010
|
||||
//if (sel >= ll.Start && sel < ll.Start + ll.Length + 7) return true;
|
||||
if (sel >= ll.Start && sel < ll.Start + ll.Length) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// For use in Find/Replace.
|
||||
/// If text is found is part of the link information and not the link value,
|
||||
/// then we want to continue searching.
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="len"></param>
|
||||
/// <returns></returns>
|
||||
public bool SkipLinkInfo(int index, int len)
|
||||
{
|
||||
if (_LinkLocations == null)return false;
|
||||
int sel = index;
|
||||
int selLength = len;
|
||||
foreach (LinkLocation ll in _LinkLocations)
|
||||
{
|
||||
if (sel >= ll.Start - 7 && sel < ll.Start + ll.Length)
|
||||
{
|
||||
int pos = ll.Text.IndexOf("#Link:");
|
||||
if (sel < ll.Start || sel >= ll.Start-7+pos)
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1771,6 +1798,60 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private RichTextBoxFinds _FindOptions = RichTextBoxFinds.None;
|
||||
public void FindText(string str, bool caseSensitive, bool matchWholeWord, bool reverse)
|
||||
{
|
||||
RTF savRTF = new RTF();
|
||||
int startpos = SelectionStart + SelectionLength;
|
||||
savRTF.Text = this.Text;
|
||||
|
||||
_FindOptions = RichTextBoxFinds.None;
|
||||
if (caseSensitive)
|
||||
_FindOptions |= RichTextBoxFinds.MatchCase;
|
||||
if (matchWholeWord)
|
||||
_FindOptions |= RichTextBoxFinds.WholeWord;
|
||||
if (reverse)
|
||||
{
|
||||
_FindOptions |= RichTextBoxFinds.Reverse;
|
||||
savRTF.Text = this.Text.Substring(0, SelectionStart);
|
||||
startpos = savRTF.Text.Length;
|
||||
if (startpos == 0)
|
||||
return; // at beginning of rtfbox during a reverse find
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startpos >= savRTF.Text.Length)
|
||||
return; // at end of rtfbox during a forward find
|
||||
}
|
||||
// look for the find string in the temporary rtfbox
|
||||
// then set the cursor selection in the real rtfbox
|
||||
bool keepgoing = true;
|
||||
while (keepgoing)
|
||||
{
|
||||
int pos = savRTF.Find(str, startpos, _FindOptions);
|
||||
keepgoing = false;
|
||||
if (pos >= 0)
|
||||
{
|
||||
if (this.SkipLinkInfo(pos,str.Length))
|
||||
{
|
||||
if (reverse)
|
||||
{
|
||||
startpos--;
|
||||
savRTF.Text = savRTF.Text.Substring(0, startpos);
|
||||
}
|
||||
else
|
||||
startpos++;
|
||||
if (startpos > 0 && startpos < savRTF.Text.Length)
|
||||
keepgoing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectionStart = pos;
|
||||
SelectionLength = str.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private int FindStart()
|
||||
{
|
||||
foreach (LinkLocation ll in _LinkLocations)
|
||||
|
Loading…
x
Reference in New Issue
Block a user