Class Grammar
Represents a TextMate grammar for tokenizing source code
Implements
Inherited Members
Namespace: Unity.AppUI.TextMateLib
Assembly: Unity.AppUI.TextMateLib.dll
Syntax
public class Grammar : IDisposable
Properties
ScopeName
Gets the scope name of the grammar (e.g., "source.js")
Declaration
public string ScopeName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
Dispose()
Releases the managed handle reference. The underlying native Grammar is owned and disposed by the Registry.
Declaration
public void Dispose()
~Grammar()
Finalizer to ensure resources are released
Declaration
protected ~Grammar()
TokenizeLine(string, IntPtr)
Tokenizes a line of text
Declaration
public TokenizeResult TokenizeLine(string lineText, IntPtr prevState)
Parameters
| Type | Name | Description |
|---|---|---|
| string | lineText | The line to tokenize |
| IntPtr | prevState | Previous state stack (use IntPtr.Zero for initial state) |
Returns
| Type | Description |
|---|---|
| TokenizeResult | Tokenization result with tokens and state |
TokenizeLine2(string, IntPtr)
Tokenizes a line of text with binary/themed output (encoded tokens). Requires a theme to be set on the registry via SetThemeFromJson.
Declaration
public TokenizeResult2 TokenizeLine2(string lineText, IntPtr prevState)
Parameters
| Type | Name | Description |
|---|---|---|
| string | lineText | The line to tokenize. |
| IntPtr | prevState | Previous state stack (use IntPtr.Zero for the initial state). |
Returns
| Type | Description |
|---|---|
| TokenizeResult2 | The themed tokenization result with encoded tokens and end-of-line state. |
TokenizeLines(string[])
Tokenizes multiple lines sequentially
Declaration
public TokenizeResult[] TokenizeLines(string[] lines)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | lines | Array of lines to tokenize |
Returns
| Type | Description |
|---|---|
| TokenizeResult[] | Array of tokenization results, one per line |
TokenizeLines2(string[])
Tokenizes multiple lines with encoded/themed output in a single batch call. Requires a theme to be set on the registry via SetThemeFromJson.
Declaration
public TokenizeResult2[] TokenizeLines2(string[] lines)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | lines | The lines to tokenize. |
Returns
| Type | Description |
|---|---|
| TokenizeResult2[] | An array of themed tokenization results, one per input line. |