Refresh the console screen. Parameters: - screen (list): List of strings representing the screen contents. - c_xy (tuple): Cursor position (x, y) on the screen.
(self, screen, c_xy)
| 227 | self.encoding = encoding |
| 228 | |
| 229 | def refresh(self, screen, c_xy): |
| 230 | """ |
| 231 | Refresh the console screen. |
| 232 | |
| 233 | Parameters: |
| 234 | - screen (list): List of strings representing the screen contents. |
| 235 | - c_xy (tuple): Cursor position (x, y) on the screen. |
| 236 | """ |
| 237 | cx, cy = c_xy |
| 238 | if not self.__gone_tall: |
| 239 | while len(self.screen) < min(len(screen), self.height): |
| 240 | self.__hide_cursor() |
| 241 | self.__move(0, len(self.screen) - 1) |
| 242 | self.__write("\n") |
| 243 | self.posxy = 0, len(self.screen) |
| 244 | self.screen.append("") |
| 245 | else: |
| 246 | while len(self.screen) < len(screen): |
| 247 | self.screen.append("") |
| 248 | |
| 249 | if len(screen) > self.height: |
| 250 | self.__gone_tall = 1 |
| 251 | self.__move = self.__move_tall |
| 252 | |
| 253 | px, py = self.posxy |
| 254 | old_offset = offset = self.__offset |
| 255 | height = self.height |
| 256 | |
| 257 | # we make sure the cursor is on the screen, and that we're |
| 258 | # using all of the screen if we can |
| 259 | if cy < offset: |
| 260 | offset = cy |
| 261 | elif cy >= offset + height: |
| 262 | offset = cy - height + 1 |
| 263 | elif offset > 0 and len(screen) < offset + height: |
| 264 | offset = max(len(screen) - height, 0) |
| 265 | screen.append("") |
| 266 | |
| 267 | oldscr = self.screen[old_offset : old_offset + height] |
| 268 | newscr = screen[offset : offset + height] |
| 269 | |
| 270 | # use hardware scrolling if we have it. |
| 271 | if old_offset > offset and self._ri: |
| 272 | self.__hide_cursor() |
| 273 | self.__write_code(self._cup, 0, 0) |
| 274 | self.posxy = 0, old_offset |
| 275 | for i in range(old_offset - offset): |
| 276 | self.__write_code(self._ri) |
| 277 | oldscr.pop(-1) |
| 278 | oldscr.insert(0, "") |
| 279 | elif old_offset < offset and self._ind: |
| 280 | self.__hide_cursor() |
| 281 | self.__write_code(self._cup, self.height - 1, 0) |
| 282 | self.posxy = 0, old_offset + self.height - 1 |
| 283 | for i in range(offset - old_offset): |
| 284 | self.__write_code(self._ind) |
| 285 | oldscr.pop(0) |
| 286 | oldscr.append("") |
nothing calls this directly
no test coverage detected