Exemplo n.º 1
0
        private bool ExtendSelectionToSimilarCharsNearByOLD(MatchCharPredicate isMatch)
        {
            bool nextMatches = false;

            if ((Text.Length - 1) > SelectionStart + SelectionLength)
            {
                Char nextChar = getCharAfterSelection(); //char after selection
                nextMatches = isMatch(nextChar);
            }

            bool prevMatches = false;

            if (SelectionStart - 1 > 0)
            {
                Char prevChar = getCharBeforeSelection(); //char before selection
                prevMatches = isMatch(prevChar);
            }

            if (!(prevMatches || nextMatches))
            {
                return(false);
            }

            txt.DoPaint = false;
            try
            { extendSelectionForward(isMatch); }
            catch { }

            try
            { extendSelectionBackwards(isMatch); }
            catch { }

            txt.DoPaint = true;
            return(true);
        }
Exemplo n.º 2
0
        private void extendSelectionForward(MatchCharPredicate matches)
        {
            Char nextChar = getCharAfterSelection(); //char after selection

            while (matches(nextChar))
            {
                SelectionLength += 1;
                nextChar         = getCharAfterSelection(); //char after selection
            }
            SelectionLength += 1;
            if (!matches(SelectedText[SelectionLength - 1]))
            {
                SelectionLength -= 1;
            }
        }
Exemplo n.º 3
0
        private void extendSelectionBackwards(MatchCharPredicate matches)
        {
            Char prevChar = getCharBeforeSelection(); //char before selection

            while (matches(prevChar))
            {
                extendSelectionOneBack();
                prevChar = Text[SelectionStart - 1]; //char after selection
            }
            extendSelectionOneBack();


            if (!matches(SelectedText[0]))
            {
                SelectionLength -= 1;
                SelectionStart  += 1;
            }
        }
        private bool ExtendSelectionToSimilarCharsNearByOLD(MatchCharPredicate isMatch)
        {
            bool nextMatches = false;
            if ((Text.Length - 1) > SelectionStart + SelectionLength)
            {
                Char nextChar = getCharAfterSelection(); //char after selection
                nextMatches = isMatch(nextChar);
            }

            bool prevMatches = false;
            if (SelectionStart - 1 > 0)
            {
                Char prevChar = getCharBeforeSelection(); //char before selection
                prevMatches = isMatch(prevChar);
            }

            if (!(prevMatches || nextMatches))
            {
                return false;
            }

            txt.DoPaint = false;
            try
            { extendSelectionForward(isMatch); }
            catch { }

            try
            { extendSelectionBackwards(isMatch); }
            catch { }

            txt.DoPaint = true;
            return true;
        }
 private void extendSelectionForward(MatchCharPredicate matches)
 {
     Char nextChar = getCharAfterSelection(); //char after selection
     while (matches(nextChar))
     {
         SelectionLength += 1;
         nextChar = getCharAfterSelection(); //char after selection
     }
     SelectionLength += 1;
     if (!matches(SelectedText[SelectionLength - 1]))
     {
         SelectionLength -= 1;
     }
 }
        private void extendSelectionBackwards(MatchCharPredicate matches)
        {
            Char prevChar = getCharBeforeSelection(); //char before selection
            while (matches(prevChar))
            {
                extendSelectionOneBack();
                prevChar = Text[SelectionStart - 1]; //char after selection
            }
            extendSelectionOneBack();

            if (!matches(SelectedText[0]))
            {
                SelectionLength -= 1;
                SelectionStart += 1;
            }
        }