Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def render(self, size, focus=False):
canv = self.__super.render(size, focus)
if self._pop_up_widget:
canv = CompositeCanvas(canv)
canv.set_pop_up(self._pop_up_widget, **self.get_pop_up_parameters())
return canv
def render(self, size, focus=False):
(maxcol,) = size
canv = self._original_widget.render((maxcol, self.height), focus)
canv = CompositeCanvas(canv)
return canv
ai = ak = 0
o = []
rows = self.font.height
attrib = self.attrib + [(None, len(self.text))]
for ch in self.text:
if not ak:
a, ak = attrib[ai]
ai += 1
ak -= 1
width = self.font.char_width(ch)
if not width:
# ignore invalid characters
continue
c = self.font.render(ch)
if a is not None:
c = CompositeCanvas(c)
c.fill_attr(a)
o.append((c, None, False, width))
if o:
canv = CanvasJoin(o)
else:
canv = TextCanvas([""] * rows, maxcol=0,
check_width=False)
canv = CompositeCanvas(canv)
canv.set_depends([])
return canv
ak -= 1
width = self.font.char_width(ch)
if not width:
# ignore invalid characters
continue
c = self.font.render(ch)
if a is not None:
c = CompositeCanvas(c)
c.fill_attr(a)
o.append((c, None, False, width))
if o:
canv = CanvasJoin(o)
else:
canv = TextCanvas([""] * rows, maxcol=0,
check_width=False)
canv = CompositeCanvas(canv)
canv.set_depends([])
return canv
def render(self, size, focus=False):
"""
Render the divider as a canvas and return it.
>>> Divider().render((10,)).text # ... = b in Python 3
[...' ']
>>> Divider(u'-', top=1).render((10,)).text
[...' ', ...'----------']
>>> Divider(u'x', bottom=2).render((5,)).text
[...'xxxxx', ...' ', ...' ']
"""
(maxcol,) = size
canv = SolidCanvas(self.div_char, maxcol, 1)
canv = CompositeCanvas(canv)
if self.top or self.bottom:
canv.pad_trim_top_bottom(self.top, self.bottom)
return canv
focus_item = 0
maxrow = 0
n = 0
for canv, pos, focus, cols in l:
rows = canv.rows()
pad_right = cols - canv.cols()
if focus:
focus_item = n
if rows > maxrow:
maxrow = rows
l2.append((canv, pos, pad_right, rows))
n += 1
shard_lists = []
children = []
joined_canvas = CompositeCanvas()
col = 0
for canv, pos, pad_right, rows in l2:
canv = CompositeCanvas(canv)
if pad_right:
canv.pad_trim_left_right(0, pad_right)
if rows < maxrow:
canv.pad_trim_top_bottom(0, maxrow - rows)
joined_canvas.coords.update(canv.translate_coords(col, 0))
for shortcut in canv.shortcuts.keys():
joined_canvas.shortcuts[shortcut] = pos
shard_lists.append(canv.shards)
children.append((col, 0, canv, pos))
col += canv.cols()
if focus_item:
children = [children[focus_item]] + children[:focus_item] + \
def render(self, size, focus=False):
left, right = self.padding_values(size, focus)
maxcol = size[0]
maxcol -= left+right
if self._width_type == CLIP:
canv = self._original_widget.render((), focus)
else:
canv = self._original_widget.render((maxcol,)+size[1:], focus)
if canv.cols() == 0:
canv = SolidCanvas(' ', size[0], canv.rows())
canv = CompositeCanvas(canv)
canv.set_depends([self._original_widget])
return canv
canv = CompositeCanvas(canv)
canv.set_depends([self._original_widget])
if left != 0 or right != 0:
canv.pad_trim_left_right(left, right)
return canv
"""
(maxcol, maxrow) = size
pl = scale_bar_values(self.pos, self.top, maxrow)
combinelist = []
rows = 0
for p, t in zip(pl, self.txt):
p -= 1
if p >= maxrow:
break
if p < rows:
continue
c = t.render((maxcol,))
if p > rows:
run = p - rows
c = CompositeCanvas(c)
c.pad_trim_top_bottom(run, 0)
rows += c.rows()
combinelist.append((c, None, False))
if not combinelist:
return SolidCanvas(" ", size[0], size[1])
c = CanvasCombine(combinelist)
if maxrow - rows:
c.pad_trim_top_bottom(0, maxrow - rows)
return c
def render(self, size, focus=False):
"""Render top_w overlayed on bottom_w."""
left, right, top, bottom = self.calculate_padding_filler(size,
focus)
bottom_c = self.bottom_w.render(size)
if not bottom_c.cols() or not bottom_c.rows():
return CompositeCanvas(bottom_c)
top_c = self.top_w.render(
self.top_w_size(size, left, right, top, bottom), focus)
top_c = CompositeCanvas(top_c)
if left < 0 or right < 0:
top_c.pad_trim_left_right(min(0, left), min(0, right))
if top < 0 or bottom < 0:
top_c.pad_trim_top_bottom(min(0, top), min(0, bottom))
return CanvasOverlay(top_c, bottom_c, left, top)
def finalize_render(self, size, focus=False):
canv = fn(self, size, focus=focus)
if canv.widget_info:
canv = CompositeCanvas(canv)
validate_size(self, size, canv)
canv.finalize(self, size, focus)
return canv
finalize_render.original_fn = fn