Gedit 高亮显示(gtksourceview):如何用颜色高亮显示[大括号]内的块
我需要突出显示大括号内的每个完整代码块,因此我创建了一个规则:
<context id="action-body" style-ref="action-body" extend-parent="true">
<start>{</start>
<end>}</end>
<include>
<context ref="builtin-vars" />
<context ref="keywords" />
</include>
</context>
它正确突出显示内部的代码、关键字和变量,但如果内部有另一个右大括号,它当然会停止。我知道正则表达式检查递归级别并不简单,但 gtkSourceView 语法对于此类情况可能有一些特殊之处?
这是一件严肃的事情,因为我正在突出显示的语言(实际上是 PegJS)只能在大括号内包含 JavaScript 代码,而不能在大括号外包含 JavaScript 代码。我想用一种颜色来突出显示它们:)
相关:
I need to highlight every whole block of code that is inside curly braces, so I created a rule:
<context id="action-body" style-ref="action-body" extend-parent="true">
<start>{</start>
<end>}</end>
<include>
<context ref="builtin-vars" />
<context ref="keywords" />
</include>
</context>
It highlights code, keywords and vars inside correctly, but it of course stops if there is another closing curly bracket inside. I know that it is not trivial for regular expressions to check level of recursion, but may be gtkSourceView
syntax has something special for cases like these?
It is a serious thing, because a language (PegJS, in fact) I am making highlighting for can contain JavaScript code only inside curly braces, not outside. And I want to highlight them with one color exluding :)
Related:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样(来自)突出显示好的(当光标在大括号中时,gedit 会有点慢)当在单行上使用此类语法时,但不适用于多行:(
并且它不允许我使用包含的上下文,但 spec 说我可以:( )
This way (from) highlights ok (gedit goes a little slow when cursor in braces) when such syntax is used on a single line, but not for multi-line:
(and it do not allows me to use included contexts, but the spec says I can :( )