Gedit syntax-highlighting with gtksourceview for backreferencing sub-patterns?

十年热恋 提交于 2019-12-24 10:41:29

问题


The following will highlight "timeout" on the second line but will not highlight it ever again. Does gtksourceview support some sort of backreference on the "sub-pattern" that will match all instances throughout the file ?

gtksourceview website manual

/usr/share/gtksourceview-2.0/language-specs/c.lang

<context id="struct" style-ref="struct">
     <match>\bstruct\b\s\w+\s(\w+)</match>
          <include>
               <context sub-pattern="1" style-ref="structname"/>
          </include>
</context>
int ns;
struct timeval timeout;
timeout.tv_sec = 1;
timeout.tv_usec = 0;

setsockopt(ns, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout));
setsockopt(ns, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));

回答1:


I think you can only do stateless highlighting in GtkSourceView. Perhaps you can do something with recursive contexts? Capture everything after the second line in your struct context, then highlight your struct name, plus call the main context recursively. I'm not sure whether this would work though.




回答2:


Apparently, the requested functionality is not supported at the moment.



来源:https://stackoverflow.com/questions/9592805/gedit-syntax-highlighting-with-gtksourceview-for-backreferencing-sub-patterns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!