Пример #1
0
        public new List <codeEditor.CodeEditor.AutocompleteItem> GetAutoCompleteItems(int index, out string cantidateWord)
        {
            cantidateWord = null;

            if (TclParsedDocument == null)
            {
                return(null);
            }
            int line           = CodeDocument.GetLineAt(index);
            int lineStartIndex = CodeDocument.GetLineStartIndex(line);

            List <codeEditor.CodeEditor.AutocompleteItem> items = TclParsedDocument.GetAutoCompleteItems(index, lineStartIndex, line, (CodeEditor.CodeDocument)CodeDocument, out cantidateWord);

            return(items);
        }
Пример #2
0
        private void applyAutoInput()
        {
            int index = CodeDocument.CaretIndex;
            int line  = CodeDocument.GetLineAt(index);

            if (line == 0)
            {
                return;
            }
            int prevLine = line - 1;

            int lineHeadIndex     = CodeDocument.GetLineStartIndex(line);
            int prevLineHeadIndex = CodeDocument.GetLineStartIndex(prevLine);

            int prevTabs = 0;

            for (int i = prevLineHeadIndex; i < lineHeadIndex; i++)
            {
                char ch = CodeDocument.GetCharAt(i);
                if (ch == '\t')
                {
                    prevTabs++;
                }
                else
                {
                    break;
                }
            }
            int indentLength = 0;

            for (int i = lineHeadIndex; i < CodeDocument.Length; i++)
            {
                char ch = CodeDocument.GetCharAt(i);
                if (ch == '\t')
                {
                    indentLength++;
                }
                else if (ch == ' ')
                {
                    indentLength++;
                }
                else
                {
                    break;
                }
            }


            bool prevBegin = isPrevBegin(lineHeadIndex);
            bool nextEnd   = isNextEnd(lineHeadIndex);

            if (prevBegin)
            {
                if (nextEnd) // caret is sandwiched beteen begin and end
                {
                    // BEFORE
                    // begin[enter] end

                    // AFTER
                    // begin
                    //     [caret]
                    // end
                    CodeDocument.Replace(lineHeadIndex, indentLength, 0, new String('\t', prevTabs + 1) + "\r\n" + new String('\t', prevTabs));
                    CodeDocument.CaretIndex = CodeDocument.CaretIndex + prevTabs + 1 + 1 - indentLength;
                    return;
                }
                else
                {   // add indent
                    prevTabs++;
                }
            }

            CodeDocument.Replace(lineHeadIndex, indentLength, 0, new String('\t', prevTabs));
            CodeDocument.CaretIndex = CodeDocument.CaretIndex + prevTabs - indentLength;
        }