Files
ingoadmin 63e84b08d7 README.md aktualisiert
removed explicit version number from the README.md
2026-10-07 07:11:55 +00:00

4.5 KiB
Raw Permalink Blame History

Textual TCSS Support for PyCharm

This project is a PyCharm plugin for Textual CSS. It associates files with the .tcss extension with a dedicated language and also treats string values ​​assigned to CSS and DEFAULT_CSS in Python files as TCSS. Both variants support syntax highlighting, structural validation, code completion, and documentation.

Features

  • Syntax highlighting for selectors, property names, values, variables, numbers, comments, and brackets.
  • Validation of rules and declarations. Errors such as missing {, }, :, or ; are highlighted in the editor.
  • Warnings for property names not found in the built-in Textual styles reference.
  • Code completion for documented Textual styles and common values.
  • Quick documentation for style properties, with descriptions in the selected language. Depending on PyCharm settings, this appears on hover or via View | Quick Documentation (Ctrl+Q, or F1 on macOS).
  • Color scheme entries under Settings | Editor | Color Scheme | Textual CSS.
  • TCSS support within Python strings assigned to CSS or DEFAULT_CSS; other Python strings remain unaffected.
  • Dedicated syntax highlighting for property names, values, and units of measurement such as fr or %.
  • Support for TCSS variable declarations (e.g., $border: wide green;), including warnings for duplicate variable declarations.
  • Variables within margin and padding values ​​are resolved for validation against allowed limits.
  • Dedicated syntax highlighting for !important.
  • Configurable language for parser and validation messages: English (default) or German. The Textual TCSS setting can be found within the PyCharm settings. - Validation against the properties, valid values, and allowed value counts listed in the Textual 8.2.8 source code reference. Built-in variables and those defined in TCSS are accepted as values.

The validation covers the 93 style properties from textual_8_2_8_tcss_style_reference_source.md, as well as margin-top, margin-right, margin-bottom, margin-left and the corresponding four padding-* properties, which Textual's parser also supports. Property values ​​and value counts are validated against the reference.

Prerequisites

  • PyCharm 2024.3 or newer (Community features are sufficient).
  • For building the plugin: JDK 21 and internet access for the initial Gradle build.
  • For installing the finished plugin: no separate Python or Textual installation required.

The plugin requires neither a running Textual process nor the Python plugin. It validates TCSS rules locally based on the editor syntax and the built-in property list.

Building the plugin

Run the following in the project folder:

./gradlew buildPlugin

On Windows:

.\gradlew.bat buildPlugin

The installable plugin ZIP file is created here:

build/distributions/textual-tcss-x.y.z.zip

During the first build, Gradle downloads the necessary Gradle and PyCharm components. The build process may take a few minutes. For a local development run, ./gradlew runIde (or .gradlew.bat runIde) is also available.

Installing the plugin in PyCharm

  1. Build the plugin as described above or obtain the textual-tcss-x.y.z.zip file from build/distributions/.
  2. Open PyCharm. 3. Open Settings (Windows/Linux: File | Settings, macOS: PyCharm | Settings).
  3. Select Plugins.
  4. Open the gear icon menu and select Install Plugin from Disk….
  5. Select textual-tcss-x.y.z.zip. Do not unzip the file beforehand.
  6. Confirm the installation and restart PyCharm if prompted.
  7. Open a .tcss file or a Python file containing a CSS or DEFAULT_CSS assignment. PyCharm should display the relevant TCSS content with Textual CSS support.

Alternatively, the ZIP file can be selected on the plugins page under Plugins | Installed | ⚙ | Install Plugin from Disk…. Menu labels may vary slightly depending on the PyCharm language setting.

Brief Example

#dialog .button:hover {
width: 1fr; 
height: 3; 
color: $text; 
border: round cyan;
}

In Python, TCSS can be embedded as follows:

class MyApp:
CSS = """
Screen { align: center middle; }
"""

DEFAULT_CSS = """
Button { color: $text; }
"""

Development

  • Main source code: src/main/java/de/textualtcss/intellij/
  • Plugin registration: src/main/resources/META-INF/plugin.xml
  • Plugin ID: de.textualtcss.intellij
  • Version: x.y.z
  • TCSS property catalog: Textual 8.2.8

The IntelliJ Platform Gradle Plugin tasks (buildPlugin, runIde) manage packaging and the local IDE sandbox.