add rainbow mode

This commit is contained in:
Tan, Kian-ting 2021-05-31 00:14:18 +08:00
parent b3867b8a9b
commit 3a3c892c0c
2 changed files with 14 additions and 5 deletions

View file

@ -6,3 +6,8 @@ authore are listed here: https://github.com/mozilla/pdf.js/blob/master/AUTHORS
The icons is based on the work from Tango Project (http://tango.freedesktop.org,
download link: http://tango.freedesktop.org/releases/tango-icon-theme-0.8.90.tar.gz under Public Domain.
staff: http://tango.freedesktop.org/The_People). Part of the icons are modified by Yoxem Chen.
some code parts are from Infobiotics Dashboard (for Infobiotics Workbench)
Copyright 2008, 2009, 2010 Jonathan Blakes, jvb@cs.nott.ac.uk
Released under GNU GPL version 3.
url: https://github.com/jvb/infobiotics-dashboard/

14
main.py
View file

@ -216,6 +216,8 @@ class ClochurLexer(QsciLexerCustom):
self.PRIMARY = ['define', 'let' , '#t', '#f', 'lambda', '@', 'cond', 'if', 'docu']
#self.rainbow_state = 0
def language(self):
return "Clochur"
@ -301,9 +303,9 @@ class ClochurLexer(QsciLexerCustom):
i = 0
if index > 0:
pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index - 1)
rainbow_state = SCI(QsciScintilla.SCI_GETSTYLEAT, pos) + 0
print(rainbow_state)
# pos = SCI(QsciScintilla.SCI_GETLINEENDPOSITION, index - 1)
rainbow_state = SCI(QsciScintilla.SCI_GETLINESTATE, index - 1)
# print(rainbow_state)
for item in line_utf8_splitted_len_pair:
@ -320,9 +322,9 @@ class ClochurLexer(QsciLexerCustom):
#parenthesis: rainbow mode
elif item["str"] == "[":
new_state = getattr(self, "Rainbow" + str(rainbow_state))
rainbow_state += 1
rainbow_state = (rainbow_state + 1) % 7
elif item["str"] == "]":
rainbow_state -= 1
rainbow_state = (rainbow_state - 1) % 7
new_state = getattr(self, "Rainbow" + str(rainbow_state))
else:
pass
@ -333,6 +335,8 @@ class ClochurLexer(QsciLexerCustom):
if new_state != self.Comment:
new_state = self.Default
SCI(QsciScintilla.SCI_SETLINESTATE, index, rainbow_state)