Language#

class Language(**properties: Any)#

Superclasses: Object

Represents a syntax highlighted language.

A GtkSourceLanguage represents a programming or markup language, affecting syntax highlighting and context classes.

Use LanguageManager to obtain a GtkSourceLanguage instance, and set_language to apply it to a Buffer.

Methods#

class Language
get_globs() list[str] | None#

Returns the globs associated to this language.

This is just an utility wrapper around get_metadata to retrieve the “globs” metadata property and split it into an array.

get_hidden() bool#

Returns whether the language should be hidden from the user.

get_id() str#

Returns the ID of the language.

The ID is not locale-dependent.The returned string is owned by language and should not be freed or modified.

get_metadata(name: str) str | None#
Parameters:

name – metadata property name.

get_mime_types() list[str] | None#

Returns the mime types associated to this language.

This is just an utility wrapper around get_metadata to retrieve the “mimetypes” metadata property and split it into an array.

get_name() str#

Returns the localized name of the language.

The returned string is owned by language and should not be freed or modified.

get_section() str#

Returns the localized section of the language.

Each language belong to a section (ex. HTML belongs to the Markup section). The returned string is owned by language and should not be freed or modified.

get_style_fallback(style_id: str) str | None#

Returns the ID of the style to use if the specified style_id is not present in the current style scheme.

Parameters:

style_id – a style ID.

get_style_ids() list[str] | None#

Returns the ids of the styles defined by this language.

get_style_name(style_id: str) str | None#

Returns the name of the style with ID style_id defined by this language.

Parameters:

style_id – a style ID.

Properties#

class Language
props.hidden: bool#

The type of the None singleton.

props.id: str#

The type of the None singleton.

props.name: str#

The type of the None singleton.

props.section: str#

The type of the None singleton.