How to fold an inserted region with Open Tools API?
Asked Answered
B

1

12

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?

Byzantine answered 3/8, 2010 at 10:12 Comment(2)
Just an idea: Did you try releasing the writer?Parishioner
I noticed this and set the writer to nil before other actions.Byzantine
P
2

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.

Pietra answered 6/3, 2011 at 9:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.