def __init__(self, **options): Formatter.__init__(self, **options) self.styles = {} for token, style in self.style: self.styles[token] = {} if style["color"]: self.styles[token]["color"] = Colors.rgb(*hex2rgb(style["color"]))
def __init__(self, **options): Formatter.__init__(self, **options) self.styles = {} for token, style in self.style: self.styles[token] = {} if style['color']: self.styles[token]['color'] = Colors.rgb( *hex2rgb(style['color']))
def draw(self, cr, update_rect): cr.fillcolor = Colors.rgb(1, 1, 1) cr.fill_rect(update_rect) d = self.font.descent h = self.font.height w = self.font.width(' ') cr.font = self.font if '\n' in self.text[:self.scursorpos]: scw = self.font.width( self.text[self.text.rindex('\n', 0, self.scursorpos):self. scursorpos]) else: scw = self.font.width(self.text[:self.scursorpos]) if '\n' in self.text[:self.cursorpos]: cw = self.font.width( self.text[self.text.rindex('\n', 0, self.cursorpos):self. cursorpos]) else: cw = self.font.width(self.text[:self.cursorpos]) selines = self.text[:self.scursorpos].count('\n') + 1 elines = self.text[:self.cursorpos].count('\n') + 1 if self.selecting: cr.fillcolor = Colors.rgb(0.5, 0.75, 1) cr.moveto(scw, d + h * selines) cr.lineto(scw, -h + h * selines) if selines != elines: cr.lineto(self.extent[0], -h + h * selines) cr.lineto(self.extent[0], -h + h * elines) cr.lineto(cw, -h + h * elines) cr.lineto(cw, d + h * elines) if selines != elines: cr.lineto(0, d + h * elines) cr.lineto(0, d + h * selines) cr.fill() # cr.fill_rect([scw,d+h*elines,cw,-h+h*elines]) cr.newpath() cr.moveto(0, self.font.height) self.formatter.cr = cr self.formatter.height = self.font.height self.formatter.tabwidth = self.font.width('\t') highlight(self.text, self.lexer, self.formatter) cr.newpath() cr.moveto(cw, d + h * elines) cr.lineto(cw, -h + h * elines) cr.stroke()
def draw(self, cr, update_rect): cr.fillcolor = Colors.rgb(1, 1, 1) cr.fill_rect(update_rect) d = self.font.descent h = self.font.height w = self.font.width(" ") cr.font = self.font if "\n" in self.text[: self.scursorpos]: scw = self.font.width(self.text[self.text.rindex("\n", 0, self.scursorpos) : self.scursorpos]) else: scw = self.font.width(self.text[: self.scursorpos]) if "\n" in self.text[: self.cursorpos]: cw = self.font.width(self.text[self.text.rindex("\n", 0, self.cursorpos) : self.cursorpos]) else: cw = self.font.width(self.text[: self.cursorpos]) selines = self.text[: self.scursorpos].count("\n") + 1 elines = self.text[: self.cursorpos].count("\n") + 1 if self.selecting: cr.fillcolor = Colors.rgb(0.5, 0.75, 1) cr.moveto(scw, d + h * selines) cr.lineto(scw, -h + h * selines) if selines != elines: cr.lineto(self.extent[0], -h + h * selines) cr.lineto(self.extent[0], -h + h * elines) cr.lineto(cw, -h + h * elines) cr.lineto(cw, d + h * elines) if selines != elines: cr.lineto(0, d + h * elines) cr.lineto(0, d + h * selines) cr.fill() # cr.fill_rect([scw,d+h*elines,cw,-h+h*elines]) cr.newpath() cr.moveto(0, self.font.height) self.formatter.cr = cr self.formatter.height = self.font.height self.formatter.tabwidth = self.font.width("\t") highlight(self.text, self.lexer, self.formatter) cr.newpath() cr.moveto(cw, d + h * elines) cr.lineto(cw, -h + h * elines) cr.stroke()