使用 ACE 编辑器隐藏一些行

编程入门 行业动态 更新时间:2024-10-09 20:29:00
本文介绍了使用 ACE 编辑器隐藏一些行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我想知道使用ace编辑器是否可以隐藏编辑器的某些行内容.

I would like to know if using ace editor is possible to hide some lines of the content of the editor.

特别是我有兴趣隐藏一些行,例如:

In particular I am interested in hiding some lines like:

%Some Tag 有助于在编辑器中查找特定代码块

%Some Tag useful to find particular chunk of code in the editor

示例:

BEGIN My theory


%Block:Function id:tick
Myfunction() {}

END

我一直在使用标签(%...)来帮助自己找到Myfunction() {} ,因为我需要修改代码的特定部分.因此,我不会向用户显示该行,但我会将其用作标签,以便将其保留在编辑器的内容中.我不能使用像行数这样的引用,因为它可能会改变.

I have been using The tag ( %...) to help myself to find Myfunction() {} , because I need to modify that particular part of code. So, I wouldn't show that line to the user, but I would use it as tag so keeping it in the content of the editor. I cannot use reference like the number of row because it may change.

谢谢

推荐答案

可以使用 addFold

you can use addFold

var Range=require("ace/range").Range;
editor.session.addFold("", new Range(1,0,2,0))

addFold 的第一个参数是占位符文本,第二个参数是要隐藏的范围

first argument to addFold is the placeholder text and the second one is the range which you want to hide

这篇关于使用 ACE 编辑器隐藏一些行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 10:35:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408631.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:编辑器   ACE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!