Recent

Author Topic: SynEdit theme  (Read 433 times)

LemonParty

  • Hero Member
  • *****
  • Posts: 557
SynEdit theme
« on: June 12, 2026, 06:59:04 pm »
I have a SynEdit component on the form.
Can I setup a syntax highlight colors like this theme from Lazarus?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12517
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit theme
« Reply #1 on: June 12, 2026, 07:35:26 pm »
Yes, well depends on the exact part you want to know.

1) Drop a highlighter (e.g. TSynPasSyn for Pascal) onto the form and set the SynEdit to use it. Property SynEdit.Highlighter
2) Set each color in the Highlighter.

Ok, that is a bit to simplified.

1 => The colors are not all in the HL, but some are in various TSynMarkup components. (e.g. begin/end pairs). If that is your question => then please indicate.

2 => You can set the colors in the Highlighter via the Object inspector. That is you set them once, and you do it manual. Or maybe your question is, how can you set them up from a config file? And maybe also how to offer configuration to your users? (the latter means you need your own configuration tool)
But in short, you can iterate all attributes of a HL (AttribCount / Attribute[n]) and access names ("StorageName") and the colors of each.

The Lazarus themes are stored in xml (see folder ide), added to the application as resources (see RC file, and {$r ...} directive), and the parsed by an xml parser, and applied via the above Attribute[n].



Since I don't know exactly which part you are interested in, I'll wait for you to specify more exactly what you want to do.

LemonParty

  • Hero Member
  • *****
  • Posts: 557
Re: SynEdit theme
« Reply #2 on: June 13, 2026, 07:40:18 am »
Understood.
I only need to setup colors like in this theme. Don't need to read an XML file.
Thank you.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12517
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit theme
« Reply #3 on: June 13, 2026, 08:15:21 am »
Understood.
I only need to setup colors like in this theme. Don't need to read an XML file.
Thank you.

Ok, then start with the Highlighter and set it via object inspector.

If then there are some colors you need, but do not find (like begin/end par matching) ask, and I can point you to the markup modules for it. Markup modules must be done in source code, they don't come for the OI.

Code: Pascal  [Select][+][-]
  1. WordPairs := TSynEditMarkupWordGroup.create;
  2. SynEdit.MarkupManager.AddMarkup(WordPairs); // WordPairs will be freed by SynEdit.
  3. WordPairs.Markup.FrameColor:=clRed;

LemonParty

  • Hero Member
  • *****
  • Posts: 557
Re: SynEdit theme
« Reply #4 on: June 13, 2026, 05:03:00 pm »
I manage to change the color of some elements of code.
But how to change the background color of the left panel with line numbers?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12517
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit theme
« Reply #5 on: June 13, 2026, 05:15:34 pm »
Those are directly in SynEdit itself. (look for color and MarkupInfo)

Like in almost every control:
SynEdit.Color   => Background color
SynEdit.Font.Color  => Foreground, if no highlighter.

Search for properties with color or markup in the name. (OI has a filter)


Then
   SynEdit.Gutter
   SynEdit.RightGutter
- Both have .Color (default background color, but most parts override the default
- Both have a list of "Parts" (click the "..." button.
  Each part has color settings "MarkupInfo"
  Setting  SynEdit.Gutter.Parts[n].MarkupInfo.Background := clNone; will make it take the default.

Most parts also have  MarkupInfoCurrentLine for a special color on the current line (where the caret is).





MarkupInfo combines colors for Foreground, Background, Frame, fontstyle, and frame sides.
Depending on the element, not all apply. E.g. gutterpart that don't have text, don't have a frame.
Except:
  For the "changes" gutter part, frame is the "unsaved change" / and not sure folding may also use it for some setting...





Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12517
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit theme
« Reply #6 on: June 13, 2026, 05:17:43 pm »
The pas highlighter can draw lines after each function (and other dividers). That only works in code.
See: SynPasSyn.DividerDrawConfig (use codetools to look it up)

LemonParty

  • Hero Member
  • *****
  • Posts: 557
Re: SynEdit theme
« Reply #7 on: June 14, 2026, 02:01:33 pm »
Code: Pascal  [Select][+][-]
  1. SynEdit.Gutter.Parts[n].MarkupInfo.Background := clNone;
That working.
Thank you.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

 

TinyPortal © 2005-2018