예제 #1
0
 /// <summary>
 /// Called when entry should be inserted. Forward to the insertion action of the completion data.
 /// </summary>
 public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
 {
     textArea.Caret.Position = textArea.Document.OffsetToPosition(
         Math.Min(insertionOffset, textArea.Document.TextLength)
         );
     return(data.InsertAction(textArea, key));
 }
예제 #2
0
        bool InsertSelectedItem(char ch)
        {
            ICompletionData data   = codeCompletionListView.SelectedCompletionData;
            bool            result = false;

            if (data != null)
            {
                control.BeginUpdate();

                if (endOffset - startOffset > 0)
                {
                    control.Document.Remove(startOffset, endOffset - startOffset);
                }
                if (dataProvider.InsertSpace)
                {
                    control.Document.Insert(startOffset++, " ");
                }
                control.ActiveTextAreaControl.Caret.Position = control.Document.OffsetToPosition(startOffset);

                result = data.InsertAction(control.ActiveTextAreaControl.TextArea, ch);
                control.EndUpdate();
            }
            Close();
            return(result);
        }
예제 #3
0
        void InsertSelectedItem()
        {
            ICompletionData data = codeCompletionListView.SelectedCompletionData;

            if (data != null)
            {
                control.BeginUpdate();

                if (endOffset - startOffset > 0)
                {
                    try
                    {
                        int dif          = endOffset - startOffset;
                        int startOffset2 = control.Document.PositionToOffset(control.ActiveTextAreaControl.Caret.Position);
                        control.Document.Remove(startOffset2 - dif, dif);
                        startOffset = startOffset2 - dif;
                        // control.Document.Insert(startOffset2, " ");
                    }
                    finally
                    {
                        control.ActiveTextAreaControl.Caret.Position = control.Document.OffsetToPosition(startOffset);
                    }
                }
                data.InsertAction(control.ActiveTextAreaControl.TextArea, '\0');
                control.EndUpdate();
            }
            Close();
        }
예제 #4
0
        public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            textArea.Caret.Position = textArea.Document.OffsetToPosition(
                Math.Min(insertionOffset, textArea.Document.TextLength));

            return data.InsertAction(textArea, key);
        }
예제 #5
0
        /// <summary>
        /// Called when entry should be inserted. Forward to the insertion action of the completion data.
        /// </summary>
        public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);
            var res = data.InsertAction(textArea, key);

            return(res);
        }
예제 #6
0
        /// <summary>
        /// Called when entry should be inserted. Forward to the insertion action of the completion data.
        /// </summary>
        public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);
            bool temp = data.InsertAction(textArea, key);

            textArea.Refresh();
            return(temp);
        }
        public virtual bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            if (InsertSpace)
            {
                textArea.Document.Insert(insertionOffset++, " ");
            }
            textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);

            return data.InsertAction(textArea, key);
        }
        public virtual bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            if (InsertSpace)
            {
                textArea.Document.Insert(insertionOffset++, " ");
            }
            textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);

            return(data.InsertAction(textArea, key));
        }
예제 #9
0
        public override bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            var preOffset = PreSelection.LastIndexOfAny(new[] { '\\', '/', '"' });

            if (preOffset < 0)
            {
                return(false);
            }
            textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);
            textArea.InsertString(PreSelection.Substring(0, preOffset + 1));
            return(data.InsertAction(textArea, key));
        }
예제 #10
0
        public virtual bool InsertAction(ICompletionData data, EditViewControl textArea, int insertionOffset, char key)
        {
            if (InsertSpace)
            {
                {
                    TextPoint loc = textArea.Document.IntPosToPoint(insertionOffset++);
                    textArea.Document.InsertText(" ", loc.X, loc.Y);
                }
            }
            textArea.Caret.Position = textArea.Document.IntPosToPoint(insertionOffset);

            return(data.InsertAction(textArea, key));
        }
예제 #11
0
        /// <summary>
        /// Inserts the selected completion value.
        /// </summary>
        /// <remarks>
        /// If we are closing a tag, we request a reformatting of the line.
        /// </remarks>
        /// <param name="p_cdtData">The code completion selection that was chosen.</param>
        /// <param name="p_txaTextArea">The area containing the document being edited.</param>
        /// <param name="p_intInsertionOffset">Where the selection should be inserted into the document.</param>
        /// <param name="p_chrKey">The character that was used to choose this completion selection.</param>
        /// <returns><c>true</c> if the insertion of <paramref name="p_chrKey"/> was handled;
        /// <c>false</c> otherwise.</returns>
        public bool InsertAction(ICompletionData p_cdtData, TextArea p_txaTextArea, int p_intInsertionOffset, char p_chrKey)
        {
            p_txaTextArea.Caret.Position = p_txaTextArea.Document.OffsetToPosition(p_intInsertionOffset);
            bool booInserted = p_cdtData.InsertAction(p_txaTextArea, p_chrKey);

            if (p_cdtData.Text.StartsWith("/"))
            {
                p_txaTextArea.Document.FormattingStrategy.IndentLine(p_txaTextArea, p_txaTextArea.Caret.Position.Line);
                if (p_chrKey == '/')
                {
                    return(true);
                }
            }
            return(booInserted);
        }
예제 #12
0
        private void InsertSelectedItem()
        {
            ICompletionData selectedCompletionData = this.codeCompletionListView.SelectedCompletionData;

            if (selectedCompletionData != null)
            {
                this.control.BeginUpdate();
                if (this.endOffset - this.startOffset > 0)
                {
                    this.control.Document.Remove(this.startOffset, this.endOffset - this.startOffset);
                    this.control.ActiveTextAreaControl.Caret.Position = this.control.Document.OffsetToPosition(this.startOffset);
                }
                selectedCompletionData.InsertAction(this.control);
                this.control.EndUpdate();
            }
            base.Close();
        }
        /// <summary>
        /// Called when entry should be inserted. Forward to the insertion action of the completion data.
        /// </summary>
        public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);
            if (!(data as UserDefaultCompletionData).IsOnOverrideWindow)
            {
                int ind = data.Text.IndexOf('<');
                if (ind != -1 && data.Text.Length > ind + 1 && data.Text[ind + 1] == '>')
                {
                    data.Text = data.Text.Substring(0, ind);
                }
            }
            else
            {
                data.Text = data.Description;
            }

            return(data.InsertAction(textArea, key));
        }
예제 #14
0
        /// <summary>
        ///     Called when a completion entry should be inserted. Forward to the insertion action of the completion data.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="textArea"></param>
        /// <param name="insertionOffset"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            var prevWord = GetCharsToLeftOfCursor(textArea);
            var prevText = prevWord.Text;

            if (prevText != "")
            {
                if (data.Text.StartsWith(prevText, true, CultureInfo.CurrentUICulture))
                {
                    textArea.SelectionManager.SetSelection(
                        new TextLocation(prevWord.ColumnNumber, prevWord.LineNumber),
                        new TextLocation(prevWord.ColumnNumber + prevWord.Length, prevWord.LineNumber)
                        );
                }
            }

            return(data.InsertAction(textArea, key));
        }
        void InsertSelectedItem()
        {
            ICompletionData data = codeCompletionListView.SelectedCompletionData;

            if (data != null)
            {
                control.BeginUpdate();

                if (endOffset - startOffset > 0)
                {
                    //Console.WriteLine("start {0} length {1}", startOffset, endOffset - startOffset);
                    control.Document.Remove(startOffset, endOffset - startOffset);
                    control.ActiveTextAreaControl.Caret.Position = control.Document.OffsetToPosition(startOffset);
                }
                data.InsertAction(control);
                control.EndUpdate();
            }
            Close();
        }
        public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            if (this.InsertSpace)
            {
                textArea.Document.Insert(insertionOffset++, " ");
            }
            textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);

            var res     = data.InsertAction(textArea, key);
            var fdoComp = (FdoCompletionData)data;

            if (fdoComp.ImageIndex == 0 && fdoComp.AppendText.Length > 2) //Function and not an empty function call
            {
                //Rewind caret so it is at the start of the function call (at first parameter)
                var offset = textArea.Caret.Offset;
                offset -= (fdoComp.AppendText.Length - 1);
                textArea.Caret.Position = textArea.Document.OffsetToPosition(offset);
                textArea.SelectionManager.ClearSelection();
                textArea.SelectionManager.SetSelection(textArea.Caret.Position, textArea.Document.OffsetToPosition(offset + (fdoComp.HighlightLength - 1)));
            }
            return(res);
        }
예제 #17
0
		/// <summary>
		/// Called when entry should be inserted. Forward to the insertion action of the completion data.
		/// </summary>
		public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key) {
			int endOffset = insertionOffset;
			LineSegment line = textArea.Document.GetLineSegment(textArea.Caret.Line);
			// Try to find the last word and replace it
			if (insertionOffset != 0) {
				// insertionOffset represent the current Caret, so this isnt needed
				// But just in case..
				if (textArea.Caret.Column > 0) {
					TextWord word = line.GetWord(textArea.Caret.Column - 1);
					if (word != null) {
						// Nothing todo?
						if (word.Word == data.Text) {
							data.Text = "";
						} else {
							// cap insert data
							data.Text = data.Text.Substring(word.Length);
						}
					}
				}
			}

			return data.InsertAction(textArea, key);
		}
        /// <summary>
        /// Called when entry should be inserted. Forward to the insertion action of the completion data.
        /// </summary>
        public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            if (textArea.Document.TextLength == 0)
            {
                return(false);
            }

            var startOffset = Math.Max(0, textArea.Document.PositionToOffset(textArea.Caret.Position) - 1);

            while (startOffset >= 0 && _validIdentifierCharacters.IsMatch(textArea.Document.GetText(startOffset, 1)))
            {
                --startOffset;
            }
            ++startOffset;

            var endOffset = textArea.Document.PositionToOffset(textArea.Caret.Position);

            while (endOffset < textArea.Document.TextLength && _validIdentifierCharacters.IsMatch(textArea.Document.GetText(endOffset, 1)))
            {
                ++endOffset;
            }

            var posn = textArea.Document.OffsetToPosition(startOffset);

            textArea.Document.UndoStack.StartUndoGroup();
            if (endOffset - startOffset > 0)
            {
                textArea.Document.Remove(startOffset, endOffset - startOffset);
            }
            textArea.Caret.Position = posn; // new TextLocation(pos.Column, pos.Line);
            bool returnValue = data.InsertAction(textArea, key);

            textArea.Document.UndoStack.EndUndoGroup();

            return(returnValue);
        }
예제 #19
0
        /// <summary>
        /// Inserts the selected completion value.
        /// </summary>
        /// <remarks>
        /// If we are closing a tag, we request a reformatting of the line.
        /// </remarks>
        /// <param name="p_cdtData">The code completion selection that was chosen.</param>
        /// <param name="p_txaTextArea">The area containing the document being edited.</param>
        /// <param name="p_intInsertionOffset">Where the selection should be inserted into the document.</param>
        /// <param name="p_chrKey">The character that was used to choose this completion selection.</param>
        /// <returns><lang cref="true"/> if the insertion of <paramref name="p_chrKey"/> was handled;
        /// <lang cref="false"/> otherwise.</returns>
        public bool InsertAction(ICompletionData p_cdtData, TextArea p_txaTextArea, int p_intInsertionOffset, char p_chrKey)
        {
            p_txaTextArea.Caret.Position = p_txaTextArea.Document.OffsetToPosition(p_intInsertionOffset);
            bool booInserted = p_cdtData.InsertAction(p_txaTextArea, p_chrKey);

            if (p_cdtData.Text.StartsWith("/"))
            {
                p_txaTextArea.Document.FormattingStrategy.IndentLine(p_txaTextArea, p_txaTextArea.Caret.Position.Line);
                if (p_chrKey == '/')
                    return true;
            }
            return booInserted;
        }
        /// <summary>
        /// Called when entry should be inserted. Forward to the insertion action of the completion data.
        /// </summary>
        public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);
            if (!(data as UserDefaultCompletionData).IsOnOverrideWindow)
            {
                int ind = data.Text.IndexOf('<');
                if (ind != -1 && data.Text.Length > ind + 1 && data.Text[ind + 1] == '>') data.Text = data.Text.Substring(0, ind);
            }
            else
                data.Text = data.Description;

            return data.InsertAction(textArea, key);
        }
        public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
        {
            if (this.InsertSpace)
            {
                textArea.Document.Insert(insertionOffset++, " ");
            }
            textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);

            var res = data.InsertAction(textArea, key);
            var fdoComp = (FdoCompletionData)data;
            if (fdoComp.ImageIndex == 0 && fdoComp.AppendText.Length > 2) //Function and not an empty function call
            {
                //Rewind caret so it is at the start of the function call (at first parameter)
                var offset = textArea.Caret.Offset;
                offset -= (fdoComp.AppendText.Length - 1);
                textArea.Caret.Position = textArea.Document.OffsetToPosition(offset);
                textArea.SelectionManager.ClearSelection();
                textArea.SelectionManager.SetSelection(textArea.Caret.Position, textArea.Document.OffsetToPosition(offset + (fdoComp.HighlightLength - 1)));
            }
            return res;
        }
예제 #22
0
 /// <summary>
 /// Called when entry should be inserted. Forward to the insertion action of the completion data.
 /// </summary>
 public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
 {
     textArea.Caret.Position = textArea.Document.OffsetToPosition(CtrlEnter ? insertionOffset - 1 : insertionOffset);
     return(data.InsertAction(textArea, key));
 }
 /// <summary>
 /// Called when entry should be inserted. Forward to the insertion action of the completion data.
 /// </summary>
 public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
 {
     textArea.SelectionManager.SetSelection(textArea.Document.OffsetToPosition(
         Math.Min(insertionOffset - ((AEGISCompletionData)data).Expression.Length, textArea.Document.TextLength)
         ), textArea.Caret.Position);
     return data.InsertAction(textArea, key);
 }
예제 #24
0
 public override bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
 {
     return(data.InsertAction(textArea, key));
 }
예제 #25
0
 /// <summary>
 /// 文字列を挿入する
 /// </summary>
 /// <param name="data"></param>
 /// <param name="textArea"></param>
 /// <param name="insertionOffset"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public bool InsertAction(ICompletionData data, ICSharpCode.TextEditor.TextArea textArea, int insertionOffset, char key)
 {
     textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);
     return(data.InsertAction(textArea, key));
 }