如何使用 Open Tools API 折叠插入的区域?

发布于 2024-09-12 18:59:05 字数 575 浏览 1 评论 0原文

我想在编辑视图中插入一个区域,然后折叠该区域。

// 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;

此代码片段将在代码编辑器中插入一个区域。但是 IDE 需要执行一些操作才能在代码编辑器中生成这样的区域。

有没有办法强制 IDE 执行此操作,然后我可以使用它

(fEditView as IOTAElideActions).ElideNearestBlock;

来折叠它?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲念泪 2024-09-19 18:59:05

由 grubby 反复试验发现:-)

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

EnableElisions() 似乎实际上切换省略功能。

关闭并重新打开省略似乎达到了预期的效果。正在进行一些不太漂亮的屏幕更新。能不能压制住我就不知道了。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文