💡 Hint: Check out our demo with a more extended version which covers whitespaces and comments!
Blog
All Blog Posts | Next Post | Previous Post
Enhance Your Delphi Apps with TTMSFNCMemo Custom Languages & Themes
Wednesday, August 27, 2025

TMS FNC UI Pack 6.8
Intro
TMS FNC UI Pack 6.8 brings a series of significant improvements and fixes as well as some major new features for the TTMSFNCMemo. With the introduction of two brand-new components, TTMSFNCMemo now offers more flexibility and customization possibilities than ever before.
Whether you need support for a domain-specific language, want to fine-tune syntax colors, or simply align the editor with your applications look and feel, these new tools enable a wide range of customization scenarios while keeping everything familiar and convenient inside the Delphi IDE!
TTMSFNCMemoCustomLanguage
With TTMSFNCMemoCustomLanguage, you can now define custom languages for syntax highlighting. This feature is powered by Monarch, the same flexible tokenization engine used in the Monaco Editor.
- Full integration: Instead of working with JavaScript objects, you define everything natively in Object Pascal. You can configure your custom language at design-time via the Object Inspector or programmatically with straightforward Delphi code.
- Works seamlessly with existing memo features: Your custom language definitions integrate directly with existing TTMSFNCMemo features such as code folding, auto-completion, and theming, ensuring a consistent editor experience out of the box.
This makes TTMSFNCMemo a powerful editor not only for well-known programming languages but also for your domain-specific languages, scripts, or configuration files.
In the example below we are going to define our own keywords, type keywords operators and the logic for strings:
procedure TForm1.ApplyLanguageSettings; begin TMSFNCMemoCustomLanguage1.LanguageID := 'mylang'; // Define keywords, types and operators TMSFNCMemoCustomLanguage1.ExtraKeys.Add('keywords', ['class', 'if', 'else', 'while', 'for', 'return', 'true', 'false']); TMSFNCMemoCustomLanguage1.ExtraKeys.Add('typeKeywords', ['int', 'string', 'boolean', 'void']); TMSFNCMemoCustomLanguage1.ExtraKeys.Add('operators', ['=', '+', '-', '*', '/', '==', '!=', '<', '>', '++']); // Root tokenizer: identifiers, numbers root := TMSFNCMemoCustomLanguage1.Tokenizer.Add('root'); root.Rules.Add('\d+', 'number'); root.Rules.Add('[A-Z][\w\$]*', 'type.identifier'); r := root.Rules.Add; r.Regex := '[a-z_$][\w$]*'; //keywords r.Action.Cases.Add('@typeKeywords', 'keyword'); r.Action.Cases.Add('@keywords', 'keyword'); r.Action.Cases.Add('@default', 'identifier'); r := root.Rules.Add; //operators r.Regex := '[=><!~?:&|+\-*\/\^%]+'; r.Action.Cases.Add('@operators', 'operator'); r.Action.Cases.Add('@default', ''); // String tokenizer str := TMSFNCMemoCustomLanguage1.Tokenizer.Add('string'); str.Rules.Add('[^\\"]+', 'string'); str.Rules.Add('"', 'string.quote', lbkClose, '@pop'); root.Rules.Add('"', 'string.quote', lbkOpen, '@string'); end; procedure TForm1.LanguageButtonClick(Sender: TObject); begin ApplyLanguageSettings; TMSFNCMemo1.CustomLanguages.Add.Language := TMSFNCMemoCustomLanguage1; TMSFNCMemo1.Language := mlCustom; end;

TTMSFNCMemoCustomTheme
Equally exciting is TTMSFNCMemoCustomTheme. This component opens up opportunities for tailoring the memo editors look and feel to match your application style, or even offering user-selectable themes. You can:
- Customize colors for syntax elements.
- Define editor related color settings, such as backgrounds, caret, and selection colors.
Let's apply a custom theme to the previously defined custom language:
procedure TForm1.ApplyThemeSettings; begin TMSFNCMemoCustomTheme1.ThemeName := 'mytheme'; TMSFNCMemoCustomTheme1.Inherit := False; TMSFNCMemoCustomTheme1.Colors.EditorBackground := $FAFAFA; TMSFNCMemoCustomTheme1.Colors.EditorForeground := $383A42; TMSFNCMemoCustomTheme1.Colors.EditorLineNumberForeground := $3291AD; TMSFNCMemoCustomTheme1.Colors.EditorLineNumberActiveForeground := $3291AD; TMSFNCMemoCustomTheme1.Colors.EditorLineHighlightBackground := $F2F2F2; TMSFNCMemoCustomTheme1.Rules.Add('keyword', $A42EA2); TMSFNCMemoCustomTheme1.Rules.Add('operator', $1485BA); TMSFNCMemoCustomTheme1.Rules.Add('type.identifier', $447BEF); TMSFNCMemoCustomTheme1.Rules.Add('number', $976715); TMSFNCMemoCustomTheme1.Rules.Add('string', $53A053); end; procedure TForm1.ThemeButtonClick(Sender: TObject); begin ApplyThemeSettings; TMSFNCMemo1.CustomThemes.Add.Theme := TMSFNCMemoCustomTheme1; TMSFNCMemo1.Theme := mtCustom; end;

Of course languages and themes configured at design-time are automatically available at runtime without the need for further configuration.
Save & Load with TTMSFNCPersistence
Customization wouldnt be complete without persistence. Thanks to TTMSFNCPersistence, you can save and load your custom language or theme definitions to and from JSON files.
- Save your carefully crafted language or theme for reuse.
- Share configurations between projects.
- Distribute themes or languages as part of your application.
This makes customization not only powerful but also portable and easy to manage.
Conclusion
The new TTMSFNCMemoCustomLanguage and TTMSFNCMemoCustomTheme components in TMS FNC UI Pack v6.8.0.0 bring flexibility, extensibility, and ease of use to developers who want to go beyond standard syntax highlighting and editor styling. Combined with the persistence features, this release transforms TTMSFNCMemo into a highly customizable editing solution that can adapt to virtually any scenario.
Tunde Keller

This blog post has not received any comments yet.
All Blog Posts | Next Post | Previous Post