[Lazarus] How to create hints in the IDE

Martin lazarus at mfriebe.de
Sat Jul 24 22:37:46 CEST 2010


On 24/07/2010 20:52, Bernd Kreuss wrote:
> TCodeHelpManager.GetHTMLHint(
>    Code: TCodeBuffer;
>    X, Y: integer;
>    Options: TCodeHelpHintOptions;
>    out BaseURL, HTMLHint: string;
>    out CacheWasUsed: boolean): TCodeHelpParseResult;
>
> seems to do the interesting things It will look up fpdoc and comments
> and do everything to create a useful hint.
>
> I assume this is the "correct" way of creating the contents of a hint
> window. I was initially hoping there would just be some hint window
> class that i can just instantiate anywhere and just have to give it the
> source code position (or whatever type of data is usually used to denote
> a piece of code) but it seems to work differently. It seems to first
> create the hint contents and then later use them for a hint window to
> fill it.
>
> Would I have any chance to try and use the above method to create the
> hint string in the code browser window? I remember having seen there a
> node variable that has a TCodeBuffer somewhere in it and also X and Y
> seem to be accessible. Would this be possible? From where do I get a
> TCodeHelpManager object? Is there already one around somewhere that I
> can simply access or do I have to instantiate my own?
>    

Despite this not being code familiar to me, I had a quick look through 
the stuff you already found:
I am sure someone with more knowledge will comment on it, but until then:

 From
ide/main.pp line 15060
procedure TMainIDE.OnSrcNotebookShowHintForSource(SrcEdit: 
TSourceEditor; ClientPos: TPoint; CaretPos: TPoint);


     
TIDEHelpManager(HelpBoss).GetHintForSourcePosition(ActiveUnitInfo.Filename,
                                           CaretPos,BaseURL,SmartHintStr);

HelpBoss is a gobal variable in the Unit HeplManager, it seems to be the 
best point to start getting contnet from.
- BaseURL,SmartHintStr are out param
- you don't need ActiveUnitInfo, only the filename.
   you can get a unitinfo, if you have the editor: AnUnitInfo := 
Project1.UnitWithEditorComponent(AEditor);
   // project1, is a global var too in Unit Project
   // project1 is generally a good point to get the unitinfo from

So (full-)filename and caretpos, and you can get content

----

As for creating the hint window, not sure what the easiest, best way is, 
but there is an example here:
ide\sourceeditor.pp line 6200
procedure TSourceNotebook.ActivateHint(const ScreenPos: TPoint; const 
BaseURL, TheHint: string);

It's a few lines only.







More information about the Lazarus mailing list