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