How instruct to the Delphi IDE refresh the modified syntax highlight colors using OTA (Open Tools API)?
Asked Answered
O

2

12

I'm writting a plugin to integrate the Delphi IDE Theme Editor with the Rad Studio IDE (the current version of this tool run as an external application) so far everything is working fine (see the below image), except the fact which I can't figure out how refresh the selected syntax highlight colors in the Delphi IDE

enter image description here

Let me explain, in the standard option to change the syntax highlight colors (Editor Options-> Color) you can customize any element and assign a new foreground and background color, then if you press the . OK . button the IDE apply the changes and the IDE editor windows are updated with new settings.

Currently i can modify and store the new values, but I can't instruct to the Delphi IDE to apply the the new configuration, the changes are only visible if the IDE is restarted.

I searched the ToolsAPI unit and i found the IOTAEditOptions, IOTAHighlighter and IOTAHighlightServices interfaces but none it seems include an option to refresh (reload) the modified setting.

Also I tried unmangle (using tdump) and calling the functions of the coreide1XX.bpl file directly, but this did not work too.

00420B94 17411 1F39 Editcolorpage::TEditorColor::
00422188 17400 1F3A __fastcall Editcolorpage::TEditorColor::ColorClick(System::TObject *)
0042174C 17407 1F3B __fastcall Editcolorpage::TEditorColor::ColorSpeedSettingClick(System::TObject *)
004224BC 17396 1F3C __fastcall Editcolorpage::TEditorColor::DefaultClick(System::TObject *)
00422414 17397 1F3D __fastcall Editcolorpage::TEditorColor::EditorColorBroadcast(System::TObject *, Winapi::Messages::TMessage&)
00421584 17409 1F3E __fastcall Editcolorpage::TEditorColor::EditorColorCreate(System::TObject *)
00421730 17408 1F3F __fastcall Editcolorpage::TEditorColor::EditorColorDestroy(System::TObject *)
004217B0 17406 1F40 __fastcall Editcolorpage::TEditorColor::ElementListClick(System::TObject *)
004222E8 17399 1F41 __fastcall Editcolorpage::TEditorColor::FontClick(System::TObject *)
004225DC 17395 1F42 __fastcall Editcolorpage::TEditorColor::HelpClick(System::TObject *)
00421AE8 17404 1F43 __fastcall Editcolorpage::TEditorColor::InitLineFlags(const System::DelphiInterface<Toolsapi::IOTAHighlighterPreview>)
004219B8 17405 1F44 __fastcall Editcolorpage::TEditorColor::InitSamplePane()
00421BC8 17403 1F45 __fastcall Editcolorpage::TEditorColor::InitSyntaxEditView(const System::DelphiInterface<Toolsapi::IOTAHighlighterPreview>)
0042262C 17393 1F46 __fastcall Editcolorpage::TEditorColor::LoadHighlightPreviews()
004225F4 17394 1F47 __fastcall Editcolorpage::TEditorColor::MarkDirty()
004220E4 17401 1F48 __fastcall Editcolorpage::TEditorColor::SampleClick(System::TObject *)
00422080 17402 1F49 __fastcall Editcolorpage::TEditorColor::SetColorSpeedSetting(Vedopts::TColorSpeedSetting)
0042238C 17398 1F4A __fastcall Editcolorpage::TEditorColor::UpdateSamplePane()
00422814 17392 1F4B __fastcall Editcolorpage::TEditorColor::tbsetPreviewsChange(System::TObject *, int, bool&)
004AA8D4 17390 1F4C __fastcall Editcolorpage::initialization()
00423C38 17413 1F4D __fastcall Editdisplaypage::Finalization()

How I can instruct to the Delphi IDE refresh the modified syntax highlight colors using OTA (Open Tools API)?

Let me know if you need more info or if the question is not clear.

Oligopoly answered 28/3, 2012 at 19:44 Comment(10)
It's a long shot, but maybe call IOTAEditView.Paint for every active module editor?Capper
I don't think that'll work @NGLN, because as I understand it the IDE only loads the colour settings on initalization. I also don't believe there's any interface in OTAPI which allows you to reinitialize those attributes.Assessor
Correction: Those settings appear to be reinitialized when you close the Environment Options dialog. A cheat may be to just have your plugin bring up the Environment Options dialog, and instruct the user to close it manually. Not terribly elegant, but should be effective.Assessor
How do you "modify and store the new values"?Gwendolin
@TOndrej, the values are stored in a internal buffer and when the user press the OK button are flushed to the Windows Registry (HKCU\Software\Embarcadero\BDS\9.0\Editor\Highlight).Oligopoly
@Oligopoly How do you modify the values in the IDE's internal buffer? Or do you mean your own internal buffer?Gwendolin
@TOndrej, Yes I mean my own internal buffer.Oligopoly
I genuinely believe that once you've flushed the values to the Windows Registry, if you display the Options dialog and press OK, the new colourscheme will be applied. Have you tried this yet?Assessor
Yes, Simon I try that, but It seems which the IDE desn't monitor the registry changes, and only read the windows registry to load the values (of the color speedsetting) when a value of the controls of the Editor Options-> Color is modified.Oligopoly
That's a bummer right there! Since I'm in the OTAPI today, I'll dig around and see if I can find anything more promising!Assessor
A
2

A slight hack that should have the desired effect would be to have your plugin bring up the Environment Options dialog, and have the operator close it manually. This causes the IDE to reinitialize its configuration based on the submitted settings.

To do this, obtain a handle onto a Project (IOTAProject object) and call...

AProject.ProjectOptions.EditOptions;

Where AProject is defined as AProject: IOTAProject.

I know this isn't the most elegant of solutions, but if it has the desired effect, at least it's somewhat practical.

Assessor answered 28/3, 2012 at 21:24 Comment(5)
Simon, good suggestion, but if the IDE doesn't detect changes in the "original" controls of the color settings doesn't refresh the IDE. (remember I'm using my own controls for setting the Syntax highlight colors)Oligopoly
@Simon, the ProjectOptions.EditOptions opens a TDelphiProjectOptionsDialog, but the Environment Options dialog is a TDefaultEnvironmentDialog... I don't think it is the same beast.Sticky
It depends how you're saving the settings. If they're in the registry where the IDE saves its own settings, then the changes SHOULD take effect (that's been my experience, anyway)Assessor
+1 I think this would be one way to do it, somehow pop the "Options" dialog and make the user click OK so that the settings will apply OR somehow make a call to the "apply settings" method in memory(this is a bit hardcore...)Blowbyblow
@LaKraven, nope, the editor colors are read from Registry when starting Delphi and never after (not when opening the options dialog). Try this: with Delphi launched, go and change the default text color in the Registry, then back to Delphi pop the Options open and see the new value is not read anew.Sticky
N
2

I'd say your best bet would be to snoop around coreide*.@Envoptions@TEnvironmentOptions@EditorSourceOptionsBeforeSave or coreide*.@Envoptions@TEnvironmentOptions@EditorSourceOptionsAfterSave

These get called when the Ok button gets clicked. I'm not very good at reading assembly but from the looks of it the environment options are loaded from the registery during IDE initialization and any changes made are written back as needed but the IDE depends on the in memory instance of TEnvironmentOptions to be the authoritative representation of all environment options.

coreide*.@Envoptions@TEnvironmentOptions@GetEdColors appears to be where the colors are retrieved from the environment options for editing by TEditorColor

It's unfortunate none of these classes is exposed to the OTA or NTA.

Nedanedda answered 27/3, 2014 at 19:8 Comment(1)
Thanks, I found some of these methods on the last months. I was hoping not to use a low level hack. but it seems the only option.Oligopoly

© 2022 - 2024 — McMap. All rights reserved.