Пример #1
0
        public void OpenReplace()
        {
            if (CodeDocument == null)
            {
                return;
            }

            if (findForm == null || !findForm.Visible)
            {
                findForm = new FindForm(this);
            }
            Point point = this.PointToScreen(new Point(Left, Top));

            findForm.Left = point.X;
            findForm.Top  = point.Y;

            if (findForm.Visible)
            {
                return;
            }
            string initialText = "";

            if (CodeDocument.SelectionStart != CodeDocument.SelectionLast)
            {
                initialText = CodeDocument.CreateString(CodeDocument.SelectionStart, CodeDocument.SelectionLast - CodeDocument.SelectionStart);
            }
            findForm.OpenReplace(initialText, this.PointToScreen(new Point(Width - findForm.Width, 0)));
        }
Пример #2
0
        public void FindNext(string findString)
        {
            string currentText = CodeDocument.CreateString(CodeDocument.SelectionStart, CodeDocument.SelectionLast - CodeDocument.SelectionStart);
            int    findIndex;

            if (currentText == findString)
            {
                findIndex = CodeDocument.FindIndexOf(findString, CodeDocument.SelectionStart + 1);
            }
            else
            {
                findIndex = CodeDocument.FindIndexOf(findString, CodeDocument.CaretIndex);
            }

            if (findIndex == -1)
            {
                findIndex = CodeDocument.FindIndexOf(findString, 0);
                if (findIndex == -1)
                {
                    return;
                }
            }

            CodeDocument.CaretIndex     = findIndex;
            CodeDocument.SelectionStart = findIndex;
            CodeDocument.SelectionLast  = findIndex + findString.Length;
            ScrollToCaret();
            Refresh();
        }
Пример #3
0
        public virtual void Apply(CodeDocument codeDocument, System.Windows.Forms.KeyEventArgs e)
        {
            int prevIndex = codeDocument.CaretIndex;

            if (codeDocument.GetLineStartIndex(codeDocument.GetLineAt(prevIndex)) != prevIndex && prevIndex != 0)
            {
                prevIndex--;
            }
            int headIndex, length;

            codeDocument.GetWord(prevIndex, out headIndex, out length);
            if (codeDocument.GetCharAt(prevIndex) == '.')
            {
                int index = codeDocument.CaretIndex;
                codeDocument.Replace(index, 0, ColorIndex, Text);
                codeDocument.CaretIndex     = index + Text.Length;
                codeDocument.SelectionStart = index + Text.Length;
                codeDocument.SelectionLast  = index + Text.Length;
            }
            else
            {
                // delete after last .
                codeDocument.Replace(headIndex, length, ColorIndex, Text);
                codeDocument.CaretIndex     = headIndex + Text.Length;
                codeDocument.SelectionStart = headIndex + Text.Length;
                codeDocument.SelectionLast  = headIndex + Text.Length;
            }
        }
Пример #4
0
        public void ReplacePrevious(string findString, string replaceString)
        {
            string currentText = CodeDocument.CreateString(CodeDocument.CaretIndex, CodeDocument.SelectionLast - CodeDocument.SelectionStart);

            if (currentText == findString)
            {
                CodeDocument.Replace(CodeDocument.CaretIndex, CodeDocument.SelectionLast - CodeDocument.SelectionStart, 0, replaceString);
                return;
            }
            FindPrevious(findString);
            currentText = CodeDocument.CreateString(CodeDocument.CaretIndex, CodeDocument.SelectionLast - CodeDocument.SelectionStart);
            if (currentText != findString)
            {
                return;
            }
            CodeDocument.Replace(CodeDocument.CaretIndex, CodeDocument.SelectionLast - CodeDocument.SelectionStart, 0, replaceString);
        }
Пример #5
0
 public virtual void Apply(CodeDocument codeDocument)
 {
 }