コード例 #1
0
ファイル: CodeEditor.cs プロジェクト: ajkfds/codeEditor
        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
ファイル: CodeEditor.cs プロジェクト: ajkfds/codeEditor
        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
ファイル: AutocompleteItem.cs プロジェクト: ajkfds/codeEditor
        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
ファイル: CodeEditor.cs プロジェクト: ajkfds/codeEditor
        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)
 {
 }