(self)
| 118 | |
| 119 | # Draw the scroller "terminal" text. |
| 120 | def draw_text(self): |
| 121 | # We need to draw the lines backward starting from the last |
| 122 | # row and going backward. This makes handling line wraps simpler, |
| 123 | # as we consume from the end of the last line and so forth. |
| 124 | y = (min(self.rows,self.rows_needed())-1) * self.font_height |
| 125 | lines = self.lines[:] |
| 126 | while y >= 0: |
| 127 | # Handle FCI images |
| 128 | if isinstance(lines[-1],ImageFCI): |
| 129 | img = lines[-1] |
| 130 | lines.pop(-1) |
| 131 | y -= self.get_image_padded_height(img.height) |
| 132 | y += self.font_height |
| 133 | img.draw_into(self.display,0,y) |
| 134 | y -= self.font_height |
| 135 | continue |
| 136 | |
| 137 | # Handle text |
| 138 | if len(lines[-1]) == 0: |
| 139 | # We consumed all the current line. Remove it |
| 140 | # and start again from the top of the loop, since |
| 141 | # the next line could be an image. |
| 142 | lines.pop(-1) |
| 143 | if len(lines) == 0: return # Should not happen |
| 144 | continue |
| 145 | |
| 146 | to_consume = len(lines[-1]) % self.cols |
| 147 | if to_consume == 0: to_consume = self.cols |
| 148 | rowchars = lines[-1][-to_consume:] # Part to display from the end |
| 149 | lines[-1]=lines[-1][:-to_consume] # Remaining part. |
| 150 | self.render_text(rowchars, 0+self.xoff, y+self.yoff, 1) |
| 151 | y -= self.font_height |
| 152 | |
| 153 | # Return the minimum time the caller should refresh the screen |
| 154 | # the next time, in case of no activity. This is useful so that we |
no test coverage detected