Is it possible to highlight a specific line in active editor window just like Delphi IDE does when highlighting compiler errors?
How to highlight a specific line in source editor using OpenToolsAPI
Do you want to also add a message to th message window? –
Whelk
My guess is it's not possible with the OTAPI directly, since there's nothing about controlling painting of the code editor. Plugins like Castalia do low-level hacks to intercept the control painting, and I don't know specifically what they are - an example of that would be a very useful answer here. Note it's also complicated because of code folding etc to be sure exactly where a specific line is. –
Insolation
@UliGerhardt No, I don't. The only thing I want is to pay user attention to a selected line of code. –
Mariahmariam
You don't mean highlight. You mean move the cursor to. Right?> –
Archbishop
@DavidHeffernan Moving cursor is an option for me (I know how to move cursor :). But I'd rather highlight a line background, just like IDE does on compiler errors, if it is possible. If it is not possible or if it is too complicated, I'll move cursor and forget about that. –
Mariahmariam
@DavidM I took a look at CnPack sources, they use some undocumented functions for custom syntax highlighting. But my task is much easier, there could be a documented way to do that... –
Mariahmariam
No, OTA does not provide such services, you have to interact with code editor control directly. –
Wellgroomed
If it's OK to just go to a certain line in the topmost editor then try this:
procedure GotoLine(LineNumber: Integer);
var
EditorServices: IOTAEditorServices;
Buffer: IOTAEditBuffer;
Position: IOTAEditPosition;
begin
if not Supports(BorlandIDEServices, IOTAEditorServices, EditorServices) then
Exit;
Buffer := EditorServices.TopBuffer;
if not Assigned(Buffer) then
Exit;
Position := Buffer.EditPosition;
if not Assigned(Position) then
Exit;
Position.GotoLine(LineNumber);
Buffer.TopView.Paint;
end;
© 2022 - 2024 — McMap. All rights reserved.