Exemplo n.º 1
0
        /// <summary>
///
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
        public int IndexOf(T item)
        {
            for (int i = 0; i < m_count; ++i)
            {
                if (m_array[i] == (item))
                {
                    return(i);
                }
            }
            return(-1);
        }
Exemplo n.º 2
0
        /// <summary>
///
/// </summary>
/// <param name="item"></param>
        public void Remove(T item)
        {
            int index = IndexOf(item);

            if (index < 0)
            {
                throw new ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.");
            }

            RemoveAt(index);
        }
Exemplo n.º 3
0
        /// <summary>
///
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
        public int Add(T item)
        {
            if (NeedsGrowth())
            {
                Grow();
            }

            ++m_version;
            m_array[m_count] = item;

            return(m_count++);
        }
Exemplo n.º 4
0
        /// <summary>
///
/// </summary>
/// <param name="position"></param>
/// <param name="item"></param>
        public void Insert(int position, T item)
        {
            ValidateIndex(position, true);             // throws

            if (NeedsGrowth())
            {
                Grow();
            }

            ++m_version;
            // for (int i=m_count; i > position; --i) m_array[i] = m_array[i-1];
            Array.Copy(m_array, position, m_array, position + 1, m_count - position);

            m_array[position] = item;
            m_count++;
        }
Exemplo n.º 5
0
        /// <summary>
///
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
        public bool Contains(T item)
        {
            return((IndexOf(item) == -1) ? false : true);
        }
Exemplo n.º 6
0
        void TriggerImmediateAutoComplete(NTDLS.Windows.Forms.CodeEditorControl editor, KeyEventArgs e)
        {
            //We only auto-insert on tab and enter. This allows users to type words that are not in the list (aka variable names).

            if (e.Control || e.Alt || e.KeyCode == Keys.ShiftKey)
            {
                return; //Close on "control keys".
            }

            if (e.KeyCode == Keys.OemPeriod)
            {
                editor.AutoListClear(); //Reset the auto-list on period press.
            }

            if (!((e.KeyValue >= 'A' && e.KeyValue <= 'Z') || (e.KeyValue > '0' && e.KeyValue < '9') || e.KeyCode == Keys.OemPeriod))
            {
                if (e.KeyCode == Keys.Up || e.KeyCode == Keys.PageUp || e.KeyCode == Keys.PageDown || e.KeyCode == Keys.Down)
                {
                    return; //Allow user to scroll thorugh list.
                }

                editor.AutoListVisible = false; //Close on all invalid keys.
                return;
            }

            //If the auto-list has already been opened, then we will not repopulate it.
            if (editor.AutoListVisible && editor.AutoListItems.Count > 0)
            {
                return;
            }

            //Only open the auto-list if an alpha key (or period) were pressed.
            if (!((e.KeyValue >= 'A' && e.KeyValue <= 'Z') || e.KeyCode == Keys.OemPeriod))
            {
                return;
            }

            NTDLS.Syntax.Segment currentSegment = editor.Caret.CurrentSegment();
            if (currentSegment.BlockType.Name == "Text")
            {
                return; //We do not provide auto-completion within the text area.
            }

            //Save the caret positions.
            int caretX = editor.Caret.Position.X;
            int caretY = editor.Caret.Position.Y;

            if (caretX < 0 || caretY < 0)
            {
                return;
            }

            //Get the current word.
            NTDLS.Syntax.TextPoint currentWordPos = new NTDLS.Syntax.TextPoint(caretX - 1, caretY);
            NTDLS.Syntax.Word      currentWord    = editor.Document.GetValidWordFromPos(currentWordPos);
            if (currentWord == null || currentWord.Text.Length <= 0)
            {
                editor.AutoListVisible = false;
                return;
            }

            //We do not perform auto-listing within strings.
            if (currentWord.Style.Name == "Strings Style" || currentWord.Style.Name == "Comments Style")
            {
                editor.AutoListVisible = false;
                return; //We do not provide auto-completion within strings or comments.
            }

            //Subtract the current word length from the CaretX, this is so that
            //  the X position points to the beginning of the word on the document.
            caretX -= currentWord.Text.Length;
            if (caretX < 0 || caretY < 0)
            {
                return;
            }
            string currentWordText = ParseImmediateAutoCompleteWord(currentWord.Text);

            //If the current word is a period, then get the word before it.
            if (currentWordText == ".")
            {
                caretX--;

                //Get the current word.
                currentWordPos = new NTDLS.Syntax.TextPoint(caretX - 1, caretY);
                currentWord    = editor.Document.GetValidWordFromPos(currentWordPos);
                if (currentWord == null || currentWord.Text.Length <= 0)
                {
                    editor.AutoListVisible = false;
                    return;
                }

                caretX          = currentWord.Column;
                currentWordText = currentWord.Text + '.';
            }

            //string currentWord = editor.Caret.CurrentWord.Text;
            if (_RunningApplication.IsRunning)
            {
                if (_ImmediateText.Caret != null)
                {
                    if (currentWordText.Length > 0)
                    {
                        caretX = _ImmediateText.Caret.Position.X - currentWordText.Length;
                        caretY = _ImmediateText.Caret.Position.Y;

                        NTDLS.Syntax.TextPoint autoListPostion = new NTDLS.Syntax.TextPoint(caretX, caretY);

                        _ImmediateText.AutoListPosition = autoListPostion;
                        WriteToCmdPipe("::ImmediateAutoList~|" + currentWordText);
                    }
                }
            }
        }
Exemplo n.º 7
0
        void TriggerEditorAutoComplete(NTDLS.Windows.Forms.CodeEditorControl editor, KeyEventArgs e)
        {
            //We only auto-insert on tab and enter. This allows users to type words that are not in the list (aka variable names).

            if (e.Control || e.Alt || e.KeyCode == Keys.ShiftKey)
            {
                return; //Close on "control keys".
            }

            if (e.KeyCode == Keys.OemPeriod)
            {
                editor.AutoListClear(); //Reset the auto-list on period press.
            }

            if (!((e.KeyValue >= 'A' && e.KeyValue <= 'Z') || //A-Z
                  (e.KeyValue > '0' && e.KeyValue < '9') || //0-9
                  e.KeyCode == Keys.OemPeriod ||            //.
                  (e.KeyValue == '3' && e.Shift == true)    //# (for pre-processors)
                  ))
            {
                if (e.KeyCode == Keys.Up || e.KeyCode == Keys.PageUp || e.KeyCode == Keys.PageDown || e.KeyCode == Keys.Down)
                {
                    return; //Allow user to scroll thorugh list.
                }

                editor.AutoListVisible = false; //Close on all invalid keys.
                return;
            }

            //If the auto-list has already been opened, then we will not repopulate it.
            if (editor.AutoListVisible && editor.AutoListItems.Count > 0)
            {
                return;
            }

            //Only open the auto-list if an alpha key (or period) were pressed.
            if (!((e.KeyValue >= 'A' && e.KeyValue <= 'Z') || //A-Z
                  e.KeyCode == Keys.OemPeriod ||            //.
                  (e.KeyValue == '3' && e.Shift == true)    //# (for pre-processors)
                  ))
            {
                return;
            }

            NTDLS.Syntax.Segment currentSegment = editor.Caret.CurrentSegment();
            if (currentSegment.BlockType.Name == "Text")
            {
                return; //We do not provide auto-completion within the text area.
            }

            //Save the caret positions.
            int caretX = editor.Caret.Position.X;
            int caretY = editor.Caret.Position.Y;

            if (caretX < 0 || caretY < 0)
            {
                return;
            }

            //Get the current word.
            NTDLS.Syntax.TextPoint currentWordPos = new NTDLS.Syntax.TextPoint(caretX - 1, caretY);
            NTDLS.Syntax.Word      currentWord    = editor.Document.GetValidWordFromPos(currentWordPos);
            if (currentWord == null || currentWord.Text.Length <= 0)
            {
                editor.AutoListVisible = false;
                return;
            }

            //We do not perform auto-listing within strings.
            if (currentWord.Style.Name == "Strings Style" || currentWord.Style.Name == "Comments Style")
            {
                editor.AutoListVisible = false;
                return; //We do not provide auto-completion within strings or comments.
            }

            //Subtract the current word length from the CaretX, this is so that
            //  the X position points to the beginning of the word on the document.
            caretX -= currentWord.Text.Length;
            if (caretX < 0 || caretY < 0)
            {
                return;
            }
            string currentWordText = currentWord.Text;

            //If the current word is a period, then get the word before it.
            if (currentWordText == ".")
            {
                caretX--;

                //Get the current word.
                currentWordPos = new NTDLS.Syntax.TextPoint(caretX - 1, caretY);
                currentWord    = editor.Document.GetValidWordFromPos(currentWordPos);
                if (currentWord == null || currentWord.Text.Length <= 0)
                {
                    editor.AutoListVisible = false;
                    return;
                }

                caretX          = currentWord.Column;
                currentWordText = currentWord.Text + '.';
            }
            editor.AutoListClear();
            editor.AutoListBeginLoad();

            List <AutoCompleteWord> listWords = new List <AutoCompleteWord>();

            foreach (NTDLS.Syntax.PatternList patternList in currentSegment.BlockType.KeywordsList)
            {
                if (patternList.Name != "Numbers")
                {
                    int imageSegment    = 10;
                    int imageTerminator = 5;

                    if (patternList.Name == "Types")
                    {
                        imageSegment    = 10;
                        imageTerminator = 8;
                    }
                    else if (patternList.Name == "Constants")
                    {
                        imageSegment    = 10;
                        imageTerminator = 5;
                    }
                    else if (patternList.Name == "System")
                    {
                        imageSegment    = 10;
                        imageTerminator = 6;
                    }
                    else if (patternList.Name == "Keywords")
                    {
                        imageSegment    = 10;
                        imageTerminator = 6;
                    }
                    else if (patternList.Name == "Reserved")
                    {
                        imageSegment    = 10;
                        imageTerminator = 9;
                    }
                    else if (patternList.Name == "PreProcessors")
                    {
                        imageSegment    = 10;
                        imageTerminator = 11;
                    }

                    if (_IDEOptions.AutoCompleteSimpleExpressions)
                    {
                        foreach (System.Collections.DictionaryEntry pattern in patternList.SimplePatterns)
                        {
                            string patternText = pattern.Key.ToString();

                            if (_IDEOptions.AutoCompleteMatchOnBeginningOnly)
                            {
                                if (patternText.StartsWith(currentWordText, StringComparison.CurrentCultureIgnoreCase))
                                {
                                    GetAutocompleteWords(listWords, patternText, imageSegment, imageTerminator);
                                }
                            }
                            else
                            {
                                if (patternText.ToLower().Contains(currentWordText.ToLower()))
                                {
                                    GetAutocompleteWords(listWords, patternText, imageSegment, imageTerminator);
                                }
                            }
                        }
                    }

                    if (_IDEOptions.AutoCompleteComplexExpressions)
                    {
                        foreach (NTDLS.Syntax.Pattern pattern in patternList.ComplexPatterns)
                        {
                            if (_IDEOptions.AutoCompleteMatchOnBeginningOnly)
                            {
                                if (pattern.StringPattern.StartsWith(currentWordText, StringComparison.CurrentCultureIgnoreCase))
                                {
                                    GetAutocompleteWords(listWords, pattern.StringPattern, imageSegment, imageTerminator);
                                }
                            }
                            else
                            {
                                if (pattern.StringPattern.ToLower().Contains(currentWordText.ToLower()))
                                {
                                    GetAutocompleteWords(listWords, pattern.StringPattern, imageSegment, imageTerminator);
                                }
                            }
                        }
                    }
                }
            }

            //Add the words to the visual drop-down-list.
            foreach (AutoCompleteWord word in listWords)
            {
                string tipText = GetDocumentationText(word.Text);
                if (tipText == null)
                {
                    //tipText = "No documentation is available for [" + word.Text + "]";
                }

                editor.AutoListAdd(word.Text, word.Text, tipText, word.Image);
            }

            editor.AutoListEndLoad();

            if (editor.AutoListItems.Count > 0)
            {
                NTDLS.Syntax.TextPoint autoListPostion = new NTDLS.Syntax.TextPoint(caretX, caretY);

                editor.AutoListPosition   = autoListPostion;
                editor.AutoListAutoSelect = true;
                editor.AutoListVisible    = true;
            }
            else
            {
                editor.AutoListVisible = false;
            }
        }