• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Enhance Your Delphi Apps with TTMSFNCMemo Custom Languages & Themes

Sascha Оффлайн

Sascha

Заместитель Администратора
Команда форума
Администратор
Регистрация
9 Май 2015
Сообщения
1,483
Баллы
155
TMS Software Delphi  Components tmsfncuipack-memo

TMS FNC UI Pack 6.8

Intro


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

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

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

, 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;
TMS Software Delphi  Components tmsfncuipack-memo

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;
TMS Software Delphi  Components tmsfncuipack-memo


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

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

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.



Источник:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу