Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fold an inserted region with Open Tools API?

I wanna insert a region in an edit view and then fold this region.

// fEditView: IOTAEditView;

var
  writer: IOTAEditWriter;
begin
  writer := fEditView.Buffer.CreateUndoableWriter;
  //...
  writer.Insert('{$REGION ''Documentation''}'#13#10'{$ENDREGION}');
  writer := nil;  // Flush the buffer
  fEditView.Position.GotoLine(lineNo); // go to the line number of the region
  fEditView.Paint;
end;

This code snippet will insert a region in the code editor. But the IDE needs some action to generate such a region in the code editor.

Is there any way to force the IDE do this action and then I can use

(fEditView as IOTAElideActions).ElideNearestBlock;

to fold it?

like image 866
Baoquan Zuo Avatar asked Aug 03 '10 10:08

Baoquan Zuo


1 Answers

Found by grubby trial-and-error :-)

(fEditView as IOTAElideActions).EnableElisions;
(fEditView as IOTAElideActions).EnableElisions;
(fEditView as IOTAElideActions).ElideNearestBlock;

EnableElisions() appears to actually toggle the elisions feature.

Turning elisions off and back on again seems to have the desired effect. There is some not very pretty screen updating going on. Whether it is possible to suppress that I don't know.

like image 196
Alistair Ward Avatar answered Oct 30 '22 04:10

Alistair Ward