bim: syntax highlighter for /etc/issue files
This commit is contained in:
parent
9d6ed3feb5
commit
df6739c85e
72
base/usr/share/bim/syntax/issue.krk
Normal file
72
base/usr/share/bim/syntax/issue.krk
Normal file
@ -0,0 +1,72 @@
|
||||
from syntax import Highlighter, bind
|
||||
|
||||
class EtcIssueHighlighter(Highlighter):
|
||||
name = "issue"
|
||||
extensions = ('/etc/issue',)
|
||||
spaces = True
|
||||
e_types = [
|
||||
('bold', Highlighter.FLAG_BOLD),
|
||||
('reset', Highlighter.FLAG_NONE),
|
||||
('blue', Highlighter.FLAG_KEYWORD),
|
||||
('red', Highlighter.FLAG_DIFFMINUS),
|
||||
('black', Highlighter.FLAG_COMMENT),
|
||||
('brown', Highlighter.FLAG_TYPE),
|
||||
('cyan', Highlighter.FLAG_KEYWORD),
|
||||
('darkgray', Highlighter.FLAG_COMMENT),
|
||||
('gray', Highlighter.FLAG_COMMENT),
|
||||
('green', Highlighter.FLAG_DIFFPLUS),
|
||||
('lightblue', Highlighter.FLAG_KEYWORD),
|
||||
('lightcyan', Highlighter.FLAG_KEYWORD),
|
||||
('lightgray', Highlighter.FLAG_COMMENT),
|
||||
('lightgreen', Highlighter.FLAG_DIFFPLUS),
|
||||
('lightmagenta', Highlighter.FLAG_NUMERAL),
|
||||
('lightred', Highlighter.FLAG_DIFFMINUS),
|
||||
('magenta', Highlighter.FLAG_NUMERAL),
|
||||
('reverse', Highlighter.FLAG_UNDERLINE),
|
||||
('yellow', Highlighter.FLAG_NOTICE),
|
||||
]
|
||||
|
||||
def calculate(self):
|
||||
if self[0] == '\\':
|
||||
if self[1] in ('\\','n','s','r','m','v','l','d','t'):
|
||||
self.paint(2, self.FLAG_ESCAPE)
|
||||
return 0
|
||||
else if not self[1]:
|
||||
self.paint(1, self.FLAG_ESCAPE)
|
||||
return None
|
||||
else if self[1] == 'e':
|
||||
if self[2] == '{':
|
||||
self.paint(3, self.FLAG_ESCAPE)
|
||||
for tname, tcolor in self.e_types:
|
||||
if self.matchAndPaint(tname, tcolor, self.cKeywordQualifier):
|
||||
break
|
||||
if not self[0] == '}':
|
||||
self.paint(1, self.FLAG_ERROR)
|
||||
else:
|
||||
self.paint(1, self.FLAG_ESCAPE)
|
||||
return 0
|
||||
else:
|
||||
self.paint(2, self.FLAG_ESCAPE)
|
||||
return 0
|
||||
else if self[1] == '4':
|
||||
if self[2] == '{':
|
||||
self.paint(3, self.FLAG_ESCAPE)
|
||||
while self[0] and self[0] != '}':
|
||||
self.paint(1, self.FLAG_KEYWORD)
|
||||
if self[0] == '}':
|
||||
self.paint(1, self.FLAG_ESCAPE)
|
||||
return 0
|
||||
else:
|
||||
self.paint(2, self.FLAG_ESCAPE)
|
||||
return 0
|
||||
else:
|
||||
self.skip()
|
||||
return 0
|
||||
else if self[0]:
|
||||
self.skip()
|
||||
return 0
|
||||
else:
|
||||
return None
|
||||
|
||||
bind(EtcIssueHighlighter)
|
||||
|
Loading…
Reference in New Issue
Block a user