我正在为一个个人项目编写一个RSL编辑器,我想自定义QScintilla中可用的CPP,因为我所需要的只是一些额外的关键字来突出显示,但我无法真正了解如何添加它们。
有什么帮助吗?干杯
编辑--我一直在玩Ive found片段,ive设法通过和创建一个键集来获得新的关键字,但只有当0覆盖索引1上的现有键集时,它才能工作。
从PyQt4导入Qsci
class RSLLexer(Qsci.QsciLexerCPP):
def __init__(self, parent):
super(RSLLexer, self).__init__()
def keywords(self, keyset):
if keyset == 1:
return b'surface'
return Qsci.QsciLexerCPP.keywords(self, keyset)发布于 2014-04-10 04:28:52
创建QsciLexerCPP的子类并重新实现关键词方法:
class RSLLexer(Qsci.QsciLexerCPP):
def keywords(self, index):
keywords = Qsci.QsciLexerCPP.keywords(self, index) or ''
# primary keywords
if index == 1:
return 'foo ' + keywords
# secondary keywords
if index == 2:
return 'bar ' + keywords
# doc comment keywords
if index == 3:
return keywords
# global classes
if index == 4:
return keywords
return keywords每个关键字集都有一个与其相关联的不同样式,因此它们可以被不同的突出显示。请参阅要使用的样式枚举。
https://stackoverflow.com/questions/22978060
复制相似问题