示例#1
0
        public void RaiseInsertionCompleted(EventArgs e)
        {
            if (currentStatus != Status.Insertion)
            {
                throw new InvalidOperationException();
            }
            if (e == null)
            {
                e = EventArgs.Empty;
            }

            currentStatus = Status.RaisingInsertionCompleted;
            int endPosition = this.InsertionPosition;

            this.wholeSnippetAnchor = new AnchorSegment(Document, startPosition, endPosition - startPosition);
            TextDocumentWeakEventManager.UpdateFinished.AddListener(Document, this);
            deactivateIfSnippetEmpty = (endPosition != startPosition);

            foreach (IActiveElement element in registeredElements)
            {
                element.OnInsertionCompleted();
            }
            if (InsertionCompleted != null)
            {
                InsertionCompleted(this, e);
            }
            currentStatus = Status.Interactive;
            if (registeredElements.Count == 0)
            {
                // deactivate immediately if there are no interactive elements
                Deactivate(new SnippetEventArgs(DeactivateReason.NoActiveElements));
            }
            else
            {
                myInputHandler = new SnippetInputHandler(this);
                // disable existing snippet input handlers - there can be only 1 active snippet
                foreach (TextAreaStackedInputHandler h in TextArea.StackedInputHandlers)
                {
                    if (h is SnippetInputHandler)
                    {
                        TextArea.PopStackedInputHandler(h);
                    }
                }
                TextArea.PushStackedInputHandler(myInputHandler);
            }
        }
示例#2
0
 public static ISegment GetPreceedingWordSegment(TextDocument document, int endOffset, string line)
 {
     string word = GetPreceedingWord(line);
     var segment = new ICSharpCode.AvalonEdit.Document.AnchorSegment(document,endOffset - word.Length, word.Length);
     return segment;
 }
示例#3
0
		public void RaiseInsertionCompleted(EventArgs e)
		{
			if (currentStatus != Status.Insertion)
				throw new InvalidOperationException();
			if (e == null)
				e = EventArgs.Empty;
			
			currentStatus = Status.RaisingInsertionCompleted;
			int endPosition = this.InsertionPosition;
			this.wholeSnippetAnchor = new AnchorSegment(Document, startPosition, endPosition - startPosition);
			TextDocumentWeakEventManager.UpdateFinished.AddListener(Document, this);
			deactivateIfSnippetEmpty = (endPosition != startPosition);
			
			foreach (IActiveElement element in registeredElements) {
				element.OnInsertionCompleted();
			}
			if (InsertionCompleted != null)
				InsertionCompleted(this, e);
			currentStatus = Status.Interactive;
			if (registeredElements.Count == 0) {
				// deactivate immediately if there are no interactive elements
				Deactivate(new SnippetEventArgs(DeactivateReason.NoActiveElements));
			} else {
				myInputHandler = new SnippetInputHandler(this);
				// disable existing snippet input handlers - there can be only 1 active snippet
				foreach (TextAreaStackedInputHandler h in TextArea.StackedInputHandlers) {
					if (h is SnippetInputHandler)
						TextArea.PopStackedInputHandler(h);
				}
				TextArea.PushStackedInputHandler(myInputHandler);
			}
		}