Table of Contents

Property AutoInsertSnippet

Namespace
Alternet.Editor.TextSource
Assembly
Alternet.Editor.v9.dll

AutoInsertSnippet

Gets or sets the current ICodeSnippetRange object.

[Browsable(false)]
public virtual ICodeSnippetRange AutoInsertSnippet { get; set; }

Property Value

ICodeSnippetRange

Examples

Here is how to use a AutoInsertSnippet in the C# code:

using System.Windows.Forms;

using Alternet.Editor;
using Alternet.Editor.TextSource;

public partial class Form1 : Form
{
    private TextSource textSource;
    private void Form1_Load(object sender, EventArgs e)
    {
        var syntaxEdit = new SyntaxEdit(this.components);
        textSource = new TextSource(this.components);
        textSource.LoadFile("myfile.txt");
        syntaxEdit.Source = this.textSource;
        syntaxEdit.SourceStateChanged += SyntaxEdit_SourceStateChanged;
    }

    private void SyntaxEdit_SourceStateChanged(object sender, NotifyEventArgs e)
    {
        if ((e.State & NotifyState.Edit) != 0)
        {
            if (textSource.AutoInsertSnippet != null)
                MessageBox.Show(textSource.AutoInsertSnippet.ID);
        }
    }
}

Here is how to use a AutoInsertSnippet in the Visual Basic code:

Imports System.Windows.Forms
Imports Alternet.Editor
Imports Alternet.Editor.TextSource

Partial Public Class Form1
    Inherits Form

    Private textSource As TextSource

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim syntaxEdit = New SyntaxEdit(Me.components)
        textSource = New TextSource(Me.components)
        textSource.LoadFile("myfile.txt")
        syntaxEdit.Source = Me.textSource
        syntaxEdit.SourceStateChanged += AddressOf SyntaxEdit_SourceStateChanged
    End Sub

    Private Sub SyntaxEdit_SourceStateChanged(ByVal sender As Object, ByVal e As NotifyEventArgs)
        If (e.State And NotifyState.Edit) <> 0 Then
            If textSource.AutoInsertSnippet IsNot Nothing Then MessageBox.Show(textSource.AutoInsertSnippet.ID)
        End If
    End Sub
End Class

Remarks

SyntaxEdit can be configured to complete matching braces quote characters when the user types opening brace, i.e., characters like '{', '[', '"' or '''.

AutoInsertSnippet contains information about the inserted brace or quote character.