def update(self, pos1=None, pos2=None): rect = Rect(pos1, pos2) if rect.c2 == (0, 0): rect.c2 = (self.width, self.height) with self.commands: for y in range(rect.top, rect.bottom): for x in range(rect.left, rect.right): self[x, y] = _REPLAY
def update(self, pos1=None, pos2=None): """Main method to update the display An interactive application or animation should call this once per frame to have th display contents updated on the terminal. It can optionally update just a part of the output screen, if pos1 or pos2 are given. As of pre-0.4.0 development an app should manually provide its "mainloop" and call this on each frame. Later development will probably have an optional higher level loop that will automate calling here. Args: - pos1, pos2: Corners of a rectangle delimitting the area to be updated. (optionally, 'pos1' can be a Rect object) """ tick_forward() if self.interactive and terminedia.input.keyboard.enabled and not self._inkey_called_since_last_update: # Ensure the dispatch of keypress events: terminedia.inkey(consume=False) self._inkey_called_since_last_update = False self.process_events() rect = Rect(pos1, pos2) if rect.c2 == (0, 0) and pos2 is None: rect.c2 = (self.width, self.height) if hasattr(self.commands, "fast_render") and self.root_context.fast_render: target = [ rect ] if pos1 is not None or self.root_context.interactive_mode else self.data.dirty_rects self.commands.fast_render(self.data, target) self.data.dirty_clear() else: with self.commands: for y in range(rect.top, rect.bottom): for x in range(rect.left, rect.right): self[x, y] = _REPLAY if self.root_context.interactive_mode: # move cursor a couple lines from the bottom to avoid scrolling for i in range(3): self.commands.up()
def update(self, pos1=None, pos2=None): rect = Rect(pos1, pos2) if rect.c2 == (0, 0) and pos2 is None: rect.c2 = (self.width, self.height) if hasattr(self.commands, "fast_render") and self.root_context.fast_render: target = [ rect ] if pos1 is not None or self.root_context.interactive_mode else self.data.dirty_rects self.commands.fast_render(self.data, target) self.data.dirty_clear() else: with self.commands: for y in range(rect.top, rect.bottom): for x in range(rect.left, rect.right): self[x, y] = _REPLAY tick_forward() if self.root_context.interactive_mode: # move cursor a couple lines from the bottom to avoid scrolling for i in range(3): self.commands.up()