SyntaxHighlighter QML Type

(BETA) Controls automatic color and font formatting in a TextEdit component. More...

Import Statement: import ArcGIS.AppFramework.Scripting 1.0

Properties

Signals

Methods

Detailed Description

The SyntaxHighlighter component allows color and style of text displayed to be automatically formatted in a TextEdit object. This component supports colorizing C++, JavaScript, Python, SQL, Windows INI and Shell. The syntax highlight is configured by a TextMate grammar file in JSON format.

This component is reponsible for colorizing keywords like 'if' or 'for' in JavaScript differently than strings, numbers, comments and variable names.

The following code sample illustrates a potential way to apply JavaScript syntax highlighting rules to a TextEdit component. In this example, the TextMate grammar file JavaScript.tmLanguage.json must also be included with the app:

Item {
    TextEdit {
        id: textEdit
        text: [
            "// JavaScript code snippet",
            "function sum(a, b) {",
            "    return a + b;",
            "}"
        ].join("\n")
    }

    SyntaxHighlighter {
        textDocument: textEdit.textDocument
        language: "JavaScript.tmLanguage.json"
    }
}

This component is in beta, and implementation is subject to change in future releases.

Property Documentation

[read-only] commentFormat : TextCharFormat

Specifies the color and font style for all detected comments. Defaults to green.


currentBlockState : int

Allows for reading and setting a custom syntax highlighting state. Reserved for JavaScript customization, final implementation is TBA.


[read-only] identifierFormat : TextCharFormat

Specifies the color and format for all detected identifiers. Default is red.


[read-only] keywordFormat : TextCharFormat

Specifies the color and format for all detected keywords. Default is cyan.


language : url

Provide the file URL for the TextMate grammar file in JSON that you're intending to use for syntax highlighting.


[read-only] numberFormat : TextCharFormat

Specifies the color and format for all detected numbers. Default is blue.


[read-only] previousBlockState : int

Contains the custom syntax highlighting state of the previous block. This property is reserved for JavaScript customization, final implementation is TBA.


[read-only] stringFormat : TextCharFormat

Specifies the color and font for all detected strings. Default is blue.


textDocument : object

Set this to the TextEdit.textDocument property to activate syntax highlighting in that TextEdit component.


Signal Documentation

highlightBlockText(string text)

This signal is reserved for JavaScript customization. Final implementation is TBA.

Note: The corresponding handler is onHighlightBlockText.


Method Documentation

rehighlight()

Use this method to retrigger the automatic syntax highlighting. Use this method if the TextEdit document needs to refreshed, or if the syntax highlight options have changed.


setFormat(int start, int count, object format)

Reserved for JavaScript customization. Final implementation is TBA.

The start parameter

The count parameter

The format parameter


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.