|
|
|
|
@ -49,10 +49,17 @@ class TTkCanvas:
|
|
|
|
|
in w = the width of the new canvas |
|
|
|
|
in h = the height of the new canvas |
|
|
|
|
''' |
|
|
|
|
__slots__ = ('_widget', '_width', '_height', '_newWidth', '_newHeight','_theme', '_data', '_colors', '_visible') |
|
|
|
|
__slots__ = ( |
|
|
|
|
'_widget', |
|
|
|
|
'_width', '_height', '_newWidth', '_newHeight', |
|
|
|
|
'_theme', |
|
|
|
|
'_data', '_colors', |
|
|
|
|
'_bufferedData', '_bufferedColors', |
|
|
|
|
'_visible', '_doubleBuffer') |
|
|
|
|
def __init__(self, *args, **kwargs): |
|
|
|
|
self._widget = kwargs.get('widget', None) |
|
|
|
|
self._visible = True |
|
|
|
|
self._doubleBuffer = False |
|
|
|
|
self._width = 0 |
|
|
|
|
self._height = 0 |
|
|
|
|
self._data = [[0]] |
|
|
|
|
@ -65,6 +72,10 @@ class TTkCanvas:
|
|
|
|
|
|
|
|
|
|
def getWidget(self): return self._widget |
|
|
|
|
|
|
|
|
|
def enableDoubleBuffer(self): |
|
|
|
|
self._doubleBuffer = True |
|
|
|
|
self._bufferedData, self._bufferedColors = self.copy() |
|
|
|
|
|
|
|
|
|
def updateSize(self): |
|
|
|
|
if not self._visible: return |
|
|
|
|
w,h = self._newWidth, self._newHeight |
|
|
|
|
@ -77,6 +88,8 @@ class TTkCanvas:
|
|
|
|
|
self._colors[i] = [TTkColor.RST]*w |
|
|
|
|
self._width = w |
|
|
|
|
self._height = h |
|
|
|
|
if self._doubleBuffer: |
|
|
|
|
self._bufferedData, self._bufferedColors = self.copy() |
|
|
|
|
|
|
|
|
|
def resize(self, w, h): |
|
|
|
|
self._newWidth = w |
|
|
|
|
@ -90,7 +103,7 @@ class TTkCanvas:
|
|
|
|
|
for ix in range(x,x+w): |
|
|
|
|
self._data[iy][ix] = ' ' |
|
|
|
|
self._colors[iy][ix] = TTkColor.RST |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def copy(self): |
|
|
|
|
w,h = self._width, self._height |
|
|
|
|
retData = [[]]*h |
|
|
|
|
@ -520,8 +533,9 @@ class TTkCanvas:
|
|
|
|
|
ansi+=ch |
|
|
|
|
lbt.Term.push(ansi) |
|
|
|
|
|
|
|
|
|
def pushToTerminalBuffered(self, x, y, w, h, oldData, oldColors): |
|
|
|
|
def pushToTerminalBuffered(self, x, y, w, h): |
|
|
|
|
# TTkLog.debug("pushToTerminal") |
|
|
|
|
oldData, oldColors = self._bufferedData, self._bufferedColors |
|
|
|
|
lastcolor = TTkColor.RST |
|
|
|
|
empty = True |
|
|
|
|
for y in range(0, self._height): |
|
|
|
|
@ -545,3 +559,6 @@ class TTkCanvas:
|
|
|
|
|
if not empty: |
|
|
|
|
lbt.Term.push(ansi) |
|
|
|
|
empty=True |
|
|
|
|
# Switch the buffer |
|
|
|
|
self._bufferedData, self._bufferedColors = self._data, self._colors |
|
|
|
|
self._data, self._colors = oldData, oldColors |
|
|
|
|
|