Example #1
0
 def _init(self):
     changed_cols, _ = self._update_lines_cols()
     if not self.holders:
         return
     ansi.clear()
     self._update_holders(changed_cols=changed_cols)
     self._update_view()
     ansi.flush()
Example #2
0
 def _init(self):
     self._update_lines_cols()
     if not self.holders:
         return
     ansi.clear()
     self._update_holders()
     self._update_view()
     ansi.flush()
Example #3
0
    async def _handle_event(self, obj, output):
        if obj is REDRAW:
            self._init()
            return
        if obj is RECALC:
            self._update_holders(output)
            return
        if obj is QUIT:
            raise EndViewer

        if obj is SAVE:
            await commands.save(self)
            self._update_status_bar()
        elif obj is OUTPUT_SAVED:
            await asyncio.sleep(0.1)
            self.output_saved = False
            self._update_status_bar()
        elif obj is ALL_DOWN:
            commands.all_down(self)
            ansi.clear()
            self._update_view()
        elif isinstance(obj, str):
            holder = self.stream_id_to_holder[obj]
            self._update_box(holder.index, output)
            if isinstance(
                    output,
                    BoxAction) or callable(output) or output is STREAM_DONE:
                ansi.clear()
                self._update_view()
            if self.is_input_mode:
                self._update_cursor()
        else:
            key_changed = False
            boxes_changed = set()
            full_refresh = False
            for fn in output:
                current_key_changed = await self._process_key_handler(fn)
                if current_key_changed is ansi.FULL_REFRESH:
                    full_refresh = True
                    key_changed = True
                elif type(current_key_changed) == int:
                    boxes_changed.add(current_key_changed)
                else:
                    key_changed = key_changed or current_key_changed
            if full_refresh:
                ansi.clear()
            if key_changed:
                self._update_view()
            elif boxes_changed:
                self._update_status_bar()
                for index in boxes_changed:
                    self._update_box(index, data=None)
            elif not self.is_input_mode:
                self._update_status_bar()
        ansi.flush()