base class for canvases
value1, value2, value3 – if not None, raise a helpful error: the old Canvas class is now called TextCanvas.
Mark this canvas as finalized (should not be any future changes to its content). This is required before caching the canvas. This happens automatically after a widget’s ‘render call returns the canvas thanks to some metaclass magic.
widget – widget that rendered this canvas size – size parameter passed to widget’s render method focus – focus parameter passed to widget’s render method
This method adds pop-up information to the canvas. This information is intercepted by a PopUpTarget widget higher in the chain to display a pop-up at the given (left, top) position relative to the current canvas.
Parameters: |
|
---|
Return the text content of the canvas as a list of strings, one for each row.
Return coords shifted by (dx, dy).
class for storing rendered text and attributes
text – list of strings, one for each line attr – list of run length encoded attributes for text cs – list of run length encoded character set for text cursor – (x,y) of cursor or None maxcol – screen columns taken by this canvas check_width – check and fix width of all lines in text
Return the screen column width of this canvas.
Return the canvas content as a list of rows where each row is a list of (attr, cs, text) tuples.
trim_left, trim_top, cols, rows may be set by CompositeCanvas when rendering a partially obscured canvas.
Return the differences between other and this canvas.
If other is the same object as self this will return no differences, otherwise this is the same as calling content().
Return the number of rows in this canvas.
Return cursor coords shifted by (dx, dy), or None if there is no cursor.
a canvas with nothing on it, only works as part of a composite canvas since it doesn’t know its own size
return (cols, rows) of spaces with default attributes.
A canvas filled completely with a single character.
Return the differences between other and this canvas.
class for storing a combination of canvases
canv – a Canvas object to wrap this CompositeCanvas around.
if canv is a CompositeCanvas, make a copy of its contents
Return the canvas content as a list of rows where each row is a list of (attr, cs, text) tuples.
Return the differences between other and this canvas.
Apply attribute a to all areas of this canvas with default attribute currently set to None, leaving other attributes intact.
Apply an attribute-mapping dictionary to the canvas.
mapping – dictionary of original-attribute:new-attribute items
Overlay other onto this canvas.
Pad or trim this canvas on the left and right
values > 0 indicate screen columns to pad values < 0 indicate screen columns to trim
Pad or trim this canvas on the top and bottom.
Explicitly specify the list of widgets that this canvas depends on. If any of these widgets change this canvas will have to be updated.
Trim lines from the top and/or bottom of canvas.
top – number of lines to remove from top count – number of lines to keep, or None for all the rest
Trim lines from the bottom of the canvas.
end – number of lines to remove from the end
Stack canvases in l vertically and return resulting canvas.
Parameters: | l – list of (canvas, position, focus) tuples:
|
---|
Join canvases in l horizontally. Return result.
Parameters: | l – list of (canvas, position, focus, cols) tuples:
|
---|
Overlay canvas top_c onto bottom_c at position (left, top).
Cache for rendered canvases. Automatically populated and accessed by Widget render() MetaClass magic, cleared by Widget._invalidate().
Stores weakrefs to the canvas objects, so an external class must maintain a reference for this cache to be effective. At present the Screen classes store the last topmost canvas after redrawing the screen, keeping the canvases from being garbage collected.
_widgets[widget] = {(wcls, size, focus): weakref.ref(canvas), ...} _refs[weakref.ref(canvas)] = (widget, wcls, size, focus) _deps[widget} = [dependent_widget, ...]
x.__init__(...) initializes x; see help(type(x)) for signature
Empty the cache.
Return the cached canvas or None.
widget – widget object requested wcls – widget class that contains render() function size, focus – render() parameters
Remove all canvases cached for widget.
Store a weakref to canvas in the cache.
wcls – widget class that contains render() function canvas – rendered canvas with widget_info (widget, size, focus)