/// <inheritdoc/>
 public override void Insert(InsertionContext context)
 {
     int start = context.InsertionPosition;
     base.Insert(context);
     int end = context.InsertionPosition;
     context.RegisterActiveElement(this, new ReplaceableActiveElement(context, start, end));
 }
 internal static void SetCaret(InsertionContext context)
 {
     TextAnchor pos = context.Document.CreateAnchor(context.InsertionPosition);
     pos.MovementType = AnchorMovementType.BeforeInsertion;
     pos.SurviveDeletion = true;
     context.Deactivated += (sender, e) => {
         if (e.Reason == DeactivateReason.ReturnPressed || e.Reason == DeactivateReason.NoActiveElements) {
             context.TextArea.Caret.Offset = pos.Offset;
         }
     };
 }
 /// <inheritdoc/>
 public override void Insert(InsertionContext context)
 {
     if (targetElement != null) {
         TextAnchor start = context.Document.CreateAnchor(context.InsertionPosition);
         start.MovementType = AnchorMovementType.BeforeInsertion;
         start.SurviveDeletion = true;
         string inputText = targetElement.Text;
         if (inputText != null) {
             context.InsertText(ConvertText(inputText));
         }
         TextAnchor end = context.Document.CreateAnchor(context.InsertionPosition);
         end.MovementType = AnchorMovementType.BeforeInsertion;
         end.SurviveDeletion = true;
         AnchorSegment segment = new AnchorSegment(start, end);
         context.RegisterActiveElement(this, new BoundActiveElement(context, targetElement, this, segment));
     }
 }
        /// <inheritdoc/>
        public override void Insert(InsertionContext context)
        {
            StringBuilder tabString = new StringBuilder();

            for (int i = 0; i < Indentation; i++) {
                tabString.Append(context.Tab);
            }

            string indent = tabString.ToString();

            string text = context.SelectedText.TrimStart(' ', '\t');

            text = text.Replace(context.LineTerminator,
                                         context.LineTerminator + indent);

            context.Document.Insert(context.InsertionPosition, text);
            context.InsertionPosition += text.Length;

            if (string.IsNullOrEmpty(context.SelectedText))
                SnippetCaretElement.SetCaret(context);
        }
Esempio n. 5
0
		/// <summary>
		/// Performs insertion of the snippet.
		/// </summary>
		public abstract void Insert(InsertionContext context);
 public ReplaceableActiveElement(InsertionContext context, int startOffset, int endOffset)
 {
     this.context = context;
     this.startOffset = startOffset;
     this.endOffset = endOffset;
 }
 public SnippetInputHandler(InsertionContext context)
     : base(context.TextArea)
 {
     this.context = context;
 }
 /// <inheritdoc/>
 public override void Insert(InsertionContext context)
 {
     foreach (SnippetElement e in this.Elements) {
         e.Insert(context);
     }
 }
 public BoundActiveElement(InsertionContext context, SnippetReplaceableTextElement targetSnippetElement, SnippetBoundElement boundElement, AnchorSegment segment)
 {
     this.context = context;
     this.targetSnippetElement = targetSnippetElement;
     this.boundElement = boundElement;
     this.segment = segment;
 }
Esempio n. 10
0
 /// <summary>
 /// Creates a new AnchorElement.
 /// </summary>
 public AnchorElement(AnchorSegment segment, string name, InsertionContext context)
 {
     this.segment = segment;
     this.context = context;
     this.Name = name;
 }
Esempio n. 11
0
 /// <inheritdoc />
 public override void Insert(InsertionContext context)
 {
     TextAnchor start = context.Document.CreateAnchor(context.InsertionPosition);
     start.MovementType = AnchorMovementType.BeforeInsertion;
     start.SurviveDeletion = true;
     AnchorSegment segment = new AnchorSegment(start, start);
     context.RegisterActiveElement(this, new AnchorElement(segment, Name, context));
 }
Esempio n. 12
0
		/// <inheritdoc/>
		public override void Insert(InsertionContext context)
		{
			if (text != null)
				context.InsertText(text);
		}
Esempio n. 13
0
 /// <inheritdoc/>
 public override void Insert(InsertionContext context)
 {
     if (!setCaretOnlyIfTextIsSelected || !string.IsNullOrEmpty(context.SelectedText))
         SetCaret(context);
 }