如何使用OpenToolsAPI在源编辑器中突出显示特定行

时间:2014-03-19 06:42:35

标签: delphi toolsapi

是否有可能在活动编辑器窗口中突出显示特定行,就像Delphi IDE在突出显示编译器错误时那样?

1 个答案:

答案 0 :(得分:7)

如果可以在最顶层的编辑器中找到某一行,那么试试这个:

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;