Download Padre

Syntax Highlighting

Syntax highlighting or syntax coloring

In 0.84 you could switch between styles in View -> Styles ->

Starting from 0.85 the option moved to Tools -> Preferences -> Appearance -> Style ->

You can also create your own style:

To set up a custom syntax highlighting scheme, you create a .yml file that defines a mapping from syntactic elements to colors. The easiest way to create your own scheme is probably to copy an existing style file (for instance, default.yml) from the share/styles/ folder of Padre. Put it in styles subdirectory of your padre configuration directory, and then modify it. Padre checks this folder on start-up and adds any styles in the YAML files there to the list of available styles.

You can find out where is the Padre configuration directory on your computer by looking at Help -> About -> System Info -> Config

=head2 Syntax highlighting

Padre is using L (aka wxPerl), wxWidgets for GUI and Scintilla for the editor. Scintilla provides very good syntax highlighting for many languages but Padre is still bound by the version of Scintilla included.

The F file is the mapping between the Scintilla defined constants for various syntactical elements of each language and the C values of the color to be used to highlight them.

Adding new syntax highlighting

TO DO does this stuff below really belong here?

Need to define constants in Padre::Util to be in the Padre::Constant namespace.

Need to add the color mapping to share/styles/default.yml

Need to implement the Padre::Document::Language class.

Need to define the MIME type mapping in Padre::Document

For examples see Padre::Document::PASM, Padre::Document::PIR and Padre::Document::Perl.

Syntax Highlighting Table draft.

Test

  1. In Tools/Preferences/Files and Colors
    1. Select File Type: Perl 5
    2. Select Highlighter: Scintilla
  2. Using File/Open open the file t/files/no_strict.pl
  3. The status bar at the bottom should now show:
    • the name of the file | Scintilla | Perl 5 | (and some more)
  4. In Tools/Preferences/Files and Colors
    1. Select File Type: Perl 5
    2. Select Highlighter: PPI Experimental
  5. Viewing the already open no_strict.pl file the status bar at the bottom should now show:
    1. the name of the file | PPI Experimental | Perl 5 | (and some more)
    2. The coloring of the code has changed.
  6. In Tools/Preferences/Files and Colors
    1. Select File Type: Perl 5
    2. Select Highlighter: PPI Standard
  7. Viewing the already open no_strict.pl file the status bar at the bottom should now show:
    1. the name of the file | PPI Standard | Perl 5 | (and some more)

TODO

  • add screenshots with default highlighting of the various syntax highlighers
  • other programming languages
  • syntax highlighting (coloring):
    • HTML export #112
    • customizable
    • for many languages