Is it possible to highlight a specific line in active editor window just like Delphi IDE does when highlighting compiler errors?
Asked
Active
Viewed 814 times
5
-
Do you want to also add a message to th message window? – Uli Gerhardt Mar 19 '14 at 07:47
-
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. – David Mar 19 '14 at 08:42
-
@UliGerhardt No, I don't. The only thing I want is to pay user attention to a selected line of code. – Roman Yankovsky Mar 19 '14 at 08:44
-
You don't mean highlight. You mean move the cursor to. Right?> – David Heffernan Mar 19 '14 at 11:01
-
1@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. – Roman Yankovsky Mar 19 '14 at 11:20
-
1@DavidM I took a look at [CnPack sources](http://code.google.com/p/cnpack/source/browse/trunk/cnwizards/Source/Utils/CnEditControlWrapper.pas#481), they use some undocumented functions for custom syntax highlighting. But my task is much easier, there could be a documented way to do that... – Roman Yankovsky Mar 19 '14 at 11:22
-
No, OTA does not provide such services, you have to interact with code editor control directly. – Free Consulting Mar 19 '14 at 12:18
1 Answers
8
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;

Ondrej Kelle
- 36,941
- 2
- 65
- 128