def setUpPalette(self):
def applyPalette(name):
palette = app.prefs.palette[name]
foreground = palette['foregroundIndexes']
background = palette['backgroundIndexes']
for i in range(1, curses.COLORS):
curses.init_pair(i, foreground[i], background[i])
def twoTries(primary, fallback):
try:
applyPalette(primary)
except:
try:
applyPalette(fallback)
except:
pass
if curses.COLORS == 8:
app.prefs.prefs['color'] = app.prefs.color8
app.prefs.color = app.prefs.color8
app.color.colors = 8
twoTries(app.prefs.editor['palette8'], 'default8')
elif curses.COLORS == 256:
app.prefs.prefs['color'] = app.prefs.color256
app.prefs.color = app.prefs.color256
app.color.colors = 256
twoTries(app.prefs.editor['palette'], 'default')
else:
raise Exception('unknown palette color count ' + repr(curses.COLORS))
评论列表
文章目录