Skip to content

lexilla: Python bindings for Lexilla

CI PyPI License: MIT Python versions

Permissively-licensed Python bindings for Lexilla, the lexer library for Scintilla.

View on PyPI · View on GitHub

Status

See GitHub Issues for what's done and what's next, the project board for the roadmap, and the changelog for releases. lexilla lives in the scintilla-py repo, next to pyside6-scintilla.

Installation

Install from PyPI:

pip install lexilla

Usage

from lexilla import Language, create_lexer
from lexilla.pyside6_scintilla import set_lexer
from pyside6_scintilla import ScintillaEdit

editor = ScintillaEdit()
lexer = create_lexer(Language.CPP)
assert lexer is not None
set_lexer(editor, lexer)

set_lexer() hands a created lexer to a pyside6-scintilla ScintillaEdit via SCI_SETILEXER, transferring ownership to it — see the lexilla_highlighting example for a complete example.

Why this exists

Lexilla creates the lexer objects (ILexer5) that a Scintilla editor widget attaches via SCI_SETILEXER -- since Scintilla 5.0 a separate, Qt-free C++ library. This package exposes it directly to Python; in practice its consumer is pyside6-scintilla, wired up via set_lexer() (see Usage above). It's a separate package so it can follow upstream Lexilla releases independently and stay free of Qt -- see the mission and the design decisions.

More