Ejemplo n.º 1
0
    def __init__(self, show_position: bool = False) -> None:
        def get_formatted_text() -> StyleAndTextTuples:
            buff = get_app().current_buffer

            if buff.validation_error:
                row, column = buff.document.translate_index_to_position(
                    buff.validation_error.cursor_position
                )

                if show_position:
                    text = "%s (line=%s column=%s)" % (
                        buff.validation_error.message,
                        row + 1,
                        column + 1,
                    )
                else:
                    text = buff.validation_error.message

                return [("class:validation-toolbar", text)]
            else:
                return []

        self.control = FormattedTextControl(get_formatted_text)

        self.container = ConditionalContainer(
            content=Window(self.control, height=1), filter=has_validation_error
        )
Ejemplo n.º 2
0
 def __init__(self) -> None:
     self.text_control = FormattedTextControl(text=HTML(''))
     self.window = Window(content=self.text_control,
                          always_hide_cursor=True,
                          align=WindowAlign.LEFT)
     super(HelpWindow, self).__init__(content=self.window,
                                      filter=has_focus(self.window))
Ejemplo n.º 3
0
def python_sidebar_help(python_input):
    """
    Create the `Layout` for the help text for the current item in the sidebar.
    """
    token = "class:sidebar.helptext"

    def get_current_description():
        """
        Return the description of the selected option.
        """
        i = 0
        for category in python_input.options:
            for option in category.options:
                if i == python_input.selected_option_index:
                    return option.description
                i += 1
        return ""

    def get_help_text():
        return [(token, get_current_description())]

    return ConditionalContainer(
        content=Window(FormattedTextControl(get_help_text),
                       style=token,
                       height=Dimension(min=3)),
        filter=ShowSidebar(python_input)
        & Condition(lambda: python_input.show_sidebar_help)
        & ~is_done,
    )
Ejemplo n.º 4
0
    def __init__(self,
                 text: str,
                 handler: Optional[Callable[[], None]] = None,
                 width: int = 12) -> None:

        self.text = text
        self.handler = handler
        self.width = width
        self.control = FormattedTextControl(
            self._get_text_fragments,
            key_bindings=self._get_key_bindings(),
            focusable=True)

        def get_style() -> str:
            if get_app().layout.has_focus(self):
                return 'class:button.focused'
            else:
                return 'class:button'

        self.window = Window(self.control,
                             align=WindowAlign.CENTER,
                             height=1,
                             width=width,
                             style=get_style,
                             dont_extend_width=True,
                             dont_extend_height=True)
Ejemplo n.º 5
0
    def __init__(self, text, handler=None, width=12):
        assert isinstance(text, six.text_type)
        assert handler is None or callable(handler)
        assert isinstance(width, int)

        self.text = text
        self.handler = handler
        self.width = width
        self.control = FormattedTextControl(
            self._get_text_fragments,
            key_bindings=self._get_key_bindings(),
            focusable=True)

        def get_style():
            if get_app().layout.has_focus(self):
                return 'class:button.focused'
            else:
                return 'class:button'

        self.window = Window(self.control,
                             align=WindowAlign.CENTER,
                             height=1,
                             width=width,
                             style=get_style,
                             dont_extend_width=True,
                             dont_extend_height=True)
Ejemplo n.º 6
0
    def updateScreen(self):
        """
        Update the UI after a change
        """
        # generate the tab bar
        self.tabbar = []
        for veh in self.tabs:
            if veh.active:
                self.tabbar.append(
                    ('class:tabbar.tab.active', ' {0} '.format(veh.name)))
            else:
                self.tabbar.append(
                    ('class:tabbar.tab', ' {0} '.format(veh.name)))
            self.tabbar.append(('class:tabbar', ' '))
        self.hscreen[0].content = FormattedTextControl(
            self.tabbar, style='class:tabbar')

        for veh in self.tabs:
            if veh.active:
                self.hscreen[2].content = BufferControl(buffer=veh.output,
                                                        focusable=False)
                self.hscreen[4].content = BufferControl(buffer=veh.input,
                                                        focusable=True,
                                                        input_processors=[veh.prompt])
                return
Ejemplo n.º 7
0
    def __init__(
        self,
        text: AnyFormattedText,
        style: str = "",
        width: AnyDimension = None,
        dont_extend_height: bool = True,
        dont_extend_width: bool = False,
        align: Union[WindowAlign, Callable[[], WindowAlign]] = WindowAlign.LEFT,
    ) -> None:

        self.text = text

        def get_width() -> AnyDimension:
            if width is None:
                text_fragments = to_formatted_text(self.text)
                text = fragment_list_to_text(text_fragments)
                if text:
                    longest_line = max(get_cwidth(line) for line in text.splitlines())
                else:
                    return D(preferred=0)
                return D(preferred=longest_line)
            else:
                return width

        self.formatted_text_control = FormattedTextControl(text=lambda: self.text)

        self.window = Window(
            content=self.formatted_text_control,
            width=get_width,
            height=D(min=1),
            style="class:label " + style,
            dont_extend_height=dont_extend_height,
            dont_extend_width=dont_extend_width,
            align=align,
        )
Ejemplo n.º 8
0
    def __init__(self,
                 title: str = "DLNest Output",
                 routineTask=None,
                 freq: int = 1,
                 style: str = "class_analyzer_output"):
        super(AnalyzeOutput, self).__init__(title, routineTask, freq, style)

        self.infoText = FormattedTextControl(
            [("", "           No analyze task is running           ")],
            focusable=False,
            show_cursor=False)

        self.infoWindow = Window(content=self.infoText)

        self.infoLabel = Box(
            body=self.infoWindow,
            height=3,
            padding_top=1,
            padding_bottom=1,
            # padding_left=3,
            # padding_right=3,
            style="class:analyzer_info_label")

        self.window = Frame(HSplit([self.infoLabel, self.shower]),
                            title=self.title,
                            style=self.style,
                            modal=True,
                            key_bindings=self.kb)
Ejemplo n.º 9
0
def status_bar(my_app: "sqlApp") -> Container:
    """
    Create the `Layout` for the status bar.
    """
    TB = "class:status-toolbar"

    def get_text_fragments() -> StyleAndTextTuples:

        result: StyleAndTextTuples = []
        append = result.append

        append((TB, " "))
        result.extend(get_inputmode_fragments(my_app))
        append((TB, " "))
        result.extend(get_connection_fragments(my_app))

        return result

    return ConditionalContainer(
        content=Window(content=FormattedTextControl(get_text_fragments),
                       style=TB),
        filter=~is_done
        & renderer_height_is_known
        & Condition(lambda: not my_app.show_exit_confirmation),
    )
Ejemplo n.º 10
0
    def create(self, sort_by=None, order=None):

        self.servers = servers.refresh(sort_by=sort_by, order=order)

        servers_output = VSplit([
            self.servers,
            Window(width=1, char='│', style='class:line'),
            response_box.create(),
        ])

        body = HSplit([
            servers_output,
            Window(height=1, char='─', style='class:line'),
            summary_box()
        ])

        title_bar = [
            ('class:title', ' Freud {}'.format(__version__)),
            ('class:title',
             ' (Press [Ctrl-C] to quit. Press [Ctrl-F] for info.)'),
        ]

        self.container = HSplit([
            search_toolbar,
            Window(height=1,
                   content=FormattedTextControl(title_bar),
                   align=WindowAlign.CENTER),
            Window(height=1, char='─', style='class:line'),
            body,
        ])

        return self.container
    def __init__(self,
                 text: str,
                 handler: Optional[Callable[[], None]] = None,
                 width: int = None) -> None:
        self.text = text
        self.handler = handler
        self.width = width

        if width is None:
            self.width = max(12, len(text) + 2)

        self.control = FormattedTextControl(
            self._get_text_fragments,
            key_bindings=self._get_key_bindings(),
            focusable=True,
        )

        def get_style() -> str:
            if get_app().layout.has_focus(self):
                return "class:button.focused"
            else:
                return "class:button"

        self.window = Window(
            self.control,
            align=WindowAlign.CENTER,
            height=1,
            width=Dimension(preferred=self.width, max=self.width),
            style=get_style,
            dont_extend_width=True,
            dont_extend_height=True,
            always_hide_cursor=True  # Stops curser from showing when selected
        )
Ejemplo n.º 12
0
def create_application_details(yarn_watcher):
    """Create application details window."""
    def get_text(width=DEFAULT_ROW_WIDTH):
        def _row(val, st=''):
            return [(st, Border.VERTICAL),
                    (st, val.ljust(width - 2)[:width - 2]),
                    (st, Border.VERTICAL), (st, '\n')]

        curr = yarn_watcher.current_application
        result = []
        result.append(('', Border.TOP_LEFT))
        result.append(('', Border.HORIZONTAL * (width - 2)))
        result.append(('', Border.TOP_RIGHT))
        result.append(('', '\n'))
        result.extend(_row('Application ID: {}'.format(curr.app_id)))
        result.extend(_row('Name: {}'.format(curr.name)))
        result.extend(_row('Progress: {}%'.format(curr.progress)))
        result.extend(
            _row('Status: {}'.format(curr.status),
                 'class:status.{}'.format(curr.status).lower()))
        result.append(('', Border.BOTTOM_LEFT))
        result.append(('', Border.HORIZONTAL * (width - 2)))
        result.append(('', Border.BOTTOM_RIGHT))
        result.append(('', '\n'))
        return result

    control = FormattedTextControl(get_text, focusable=False)

    return Window(control, width=DEFAULT_ROW_WIDTH, style='class:details')
Ejemplo n.º 13
0
 def show_help(self):
     self.help_mode = True
     self.help_text = rich_print(md)
     self.help_window = Window(content=FormattedTextControl(
         text=ANSI(self.help_text)))
     self.app.layout = Layout(self.help_window)
     self.help_line = 0
Ejemplo n.º 14
0
 def output_hook(self, msg: Dict[str, Any]):
     msg_type = msg["header"]["msg_type"]
     content = msg["content"]
     outputs = self.executing_cells[0].json["outputs"]
     if msg_type == "stream":
         if (not outputs) or (outputs[-1]["name"] != content["name"]):
             outputs.append({
                 "name": content["name"],
                 "output_type": msg_type,
                 "text": []
             })
         outputs[-1]["text"].append(content["text"])
     elif msg_type in ("display_data", "execute_result"):
         outputs.append({
             "data": {
                 "text/plain": [content["data"].get("text/plain", "")]
             },
             "execution_count": self.execution_count,
             "metadata": {},
             "output_type": msg_type,
         })
     elif msg_type == "error":
         outputs.append({
             "ename": content["ename"],
             "evalue": content["evalue"],
             "output_type": "error",
             "traceback": content["traceback"],
         })
     else:
         return
     text, height = get_output_text_and_height(outputs)
     self.executing_cells[0].output.content = FormattedTextControl(
         text=text)
     self.executing_cells[0].output.height = height
     self.app.invalidate()
Ejemplo n.º 15
0
def meta_enter_message(python_input: "PythonInput") -> Container:
    """
    Create the `Layout` for the 'Meta+Enter` message.
    """

    def get_text_fragments() -> StyleAndTextTuples:
        return [("class:accept-message", " [Meta+Enter] Execute ")]

    @Condition
    def extra_condition() -> bool:
        " Only show when... "
        b = python_input.default_buffer

        return (
            python_input.show_meta_enter_message
            and (
                not b.document.is_cursor_at_the_end
                or python_input.accept_input_on_enter is None
            )
            and "\n" in b.text
        )

    visible = ~is_done & has_focus(DEFAULT_BUFFER) & extra_condition

    return ConditionalContainer(
        content=Window(FormattedTextControl(get_text_fragments)), filter=visible
    )
Ejemplo n.º 16
0
    def __init__(
            self, options: Sequence[Tuple[RadioListType,
                                          AnyFormattedText]]) -> None:
        self.options = options
        self.current_option: RadioListType = options[0][0]
        self._selected_index = 0

        # Key bindings.
        kb = KeyBindings()

        kb.add("up")(self._handle_up)
        kb.add("down")(self._handle_down)
        kb.add("enter")(self._handle_enter)
        kb.add("c-d")(self._handle_exit)
        kb.add("c-a")(self._handle_home)
        kb.add("c-e")(self._handle_end)

        # Control and window.
        self.control = FormattedTextControl(self._get_text_fragments,
                                            key_bindings=kb,
                                            focusable=True)

        self.window = Window(
            content=self.control,
            style=self.container_style,
            right_margins=[ScrollbarMargin(display_arrows=True)],
            dont_extend_height=True,
        )
Ejemplo n.º 17
0
    def __init__(self,
                 text: AnyFormattedText,
                 style: str = '',
                 width: AnyDimension = None,
                 dont_extend_height: bool = True,
                 dont_extend_width: bool = False) -> None:

        self.text = text

        def get_width() -> AnyDimension:
            if width is None:
                text_fragments = to_formatted_text(self.text)
                text = fragment_list_to_text(text_fragments)
                if text:
                    longest_line = max(
                        get_cwidth(line) for line in text.splitlines())
                else:
                    return D(preferred=0)
                return D(preferred=longest_line)
            else:
                return width

        self.formatted_text_control = FormattedTextControl(
            text=lambda: self.text)

        self.window = Window(content=self.formatted_text_control,
                             width=get_width,
                             style='class:label ' + style,
                             dont_extend_height=dont_extend_height,
                             dont_extend_width=dont_extend_width)
Ejemplo n.º 18
0
    def __init__(self, playback, save_location=None, *args, **kwargs):

        self.mainViewCondition = partial(self.mainView, self)
        self.mainViewCondition = Condition(self.mainViewCondition)
        self.disabled_bindings = False
        bindings = KeyBindings()
        self.init_bindings(bindings)

        super().__init__(full_screen=True,
                         key_bindings=bindings,
                         mouse_support=True,
                         *args,
                         **kwargs)

        self.displayingHelpScreen = (
            False)  # used to toggle between help screen on normal

        if save_location:
            self.save_location = save_location
        else:
            self.save_location = SAVE_LOCATION
        self.playback = playback
        self._savedLayout = Layout(Window())
        self.command_cache = deque([], maxlen=5)

        ##########################################
        ### Setting up views
        ##########################################

        self.old_command_window = FormattedTextControl(text="Output goes here",
                                                       focusable=True)
        self.new_command_window = FormattedTextControl(text="Output goes here",
                                                       focusable=True)

        self.body = Frame(
            HSplit([
                Frame(Window(self.old_command_window)),
                Frame(Window(self.new_command_window)),
            ]))
        self.toolbar = Window(
            FormattedTextControl(text=self.toolbar_text),
            height=Dimension(max=1, weight=10000),
            dont_extend_height=True,
        )

        self.main_view = HSplit([self.body, self.toolbar], padding_char="-")
        self.layout = Layout(self.main_view)
Ejemplo n.º 19
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.riitag_info = user.RiitagInfo()  # placeholder

        self.menu_settings_button = Button(
            'Settings', handler=lambda: self._set_state('Settings'))
        self.menu_exit_button = Button('Exit', handler=self.quit_app)
        self.menu_logout_button = Button('Logout', handler=self._logout)

        self.settings_back_button = Button(
            'Back...', width=12, handler=lambda: self._set_state('Menu'))
        self.settings_reset_button = Button('Reset...',
                                            width=12,
                                            handler=self._reset_preferences)
        self.settings_pres_timeout_button = PreferenceButton(
            value=self.app.preferences.presence_timeout,
            increments=10,
            limits=(10, 120))
        self.settings_check_interval_button = PreferenceButton(
            value=self.app.preferences.check_interval,
            increments=10,
            limits=(10, 60))

        self.right_panel_state = 'Menu'
        self.menu_layout = Frame(Box(HSplit([
            self.menu_settings_button,
            Label(''),
            self.menu_exit_button,
            self.menu_logout_button,
        ]),
                                     padding_left=3,
                                     padding_top=2),
                                 title='Menu')
        self.settings_layout = Frame(Box(HSplit([
            Window(FormattedTextControl(
                HTML(
                    'This is where you can modify settings\nregarding the underlying presence\nwatcher.'
                )),
                   wrap_lines=True,
                   width=25),
            Label(''),
            VSplit([
                Label('Presence Timeout (min.):'),
                self.settings_pres_timeout_button
            ],
                   width=15),
            VSplit([
                Label('Refresh Interval (sec.):'),
                self.settings_check_interval_button
            ],
                   padding=3),
            Label(''),
            VSplit([self.settings_back_button, self.settings_reset_button],
                   align=WindowAlign.CENTER)
        ]),
                                         padding_left=3,
                                         padding_top=2),
                                     title='Settings')
Ejemplo n.º 20
0
    def __init__(self, values: Sequence[Tuple[_T, AnyFormattedText]]) -> None:
        assert len(values) > 0

        self.values = values
        # current_values will be used in multiple_selection,
        # current_value will be used otherwise.
        self.current_values: List[_T] = []
        self.current_value: _T = values[0][0]
        self._selected_index = 0

        # Key bindings.
        kb = KeyBindings()

        @kb.add('up')
        def _(event: E) -> None:
            self._selected_index = max(0, self._selected_index - 1)

        @kb.add('down')
        def _(event: E) -> None:
            self._selected_index = min(
                len(self.values) - 1, self._selected_index + 1)

        @kb.add('pageup')
        def _(event: E) -> None:
            w = event.app.layout.current_window
            self._selected_index = max(
                0, self._selected_index - len(w.render_info.displayed_lines))

        @kb.add('pagedown')
        def _(event: E) -> None:
            w = event.app.layout.current_window
            self._selected_index = min(
                len(self.values) - 1,
                self._selected_index + len(w.render_info.displayed_lines))

        @kb.add('enter')
        @kb.add(' ')
        def _(event: E) -> None:
            self._handle_enter()

        @kb.add(Keys.Any)
        def _(event: E) -> None:
            # We first check values after the selected value, then all values.
            for value in self.values[self._selected_index + 1:] + self.values:
                if value[1].startswith(event.data):
                    self._selected_index = self.values.index(value)
                    return

        # Control and window.
        self.control = FormattedTextControl(self._get_text_fragments,
                                            key_bindings=kb,
                                            focusable=True)

        self.window = Window(content=self.control,
                             style=self.container_style,
                             right_margins=[
                                 ScrollbarMargin(display_arrows=True),
                             ],
                             dont_extend_height=True)
Ejemplo n.º 21
0
 def _render_events(self, events):
     event_texts = [self._format_event(event) for event in events]
     event_max_width = max(len(event_text) for event_text in event_texts)
     return Window(
         FormattedTextControl("\n".join(event_texts)),
         width=min(event_max_width, 50),
         height=len(events),
     )
Ejemplo n.º 22
0
 def do_inspect(self, _):
     self.right_buffer.text = "INSPECT:\n" + _.text
     # hide previous command buffer control
     self.command_area.children[0].content = DummyControl()
     self.status_area.content = FormattedTextControl(
         self.get_status_text('inspect file: ' + _.text))
     app = get_app()
     app.layout.focus(self.left_buffer)
Ejemplo n.º 23
0
 def __init__(self, message: str, filter: "FilterOrBool", **kwargs) -> None:
     self._message = message
     super().__init__(
         Window(FormattedTextControl(text=self._get_message),
                dont_extend_height=True,
                **kwargs),
         filter=filter,
     )
Ejemplo n.º 24
0
 def __init__(self, text: AnyFormattedText, style: str = '', **kw) -> None:
     # Note: The style needs to be applied to the toolbar as a whole, not
     #       just the `FormattedTextControl`.
     super().__init__(
         FormattedTextControl(text, **kw),
         style=style,
         dont_extend_height=True,
         height=Dimension(min=1))
Ejemplo n.º 25
0
def generate_layout(input_field: TextArea, output_field: TextArea,
                    log_field: TextArea, search_field: SearchToolbar,
                    timer: TextArea, process_monitor: TextArea,
                    trade_monitor: TextArea):
    root_container = HSplit([
        VSplit(
            [
                Window(FormattedTextControl(get_version), style="class:title"),
                Window(FormattedTextControl(get_paper_trade_status),
                       style="class:title"),
                Window(FormattedTextControl(get_active_strategy),
                       style="class:title"),
                # Window(FormattedTextControl(get_active_markets), style="class:title"),
                # Window(FormattedTextControl(get_script_file), style="class:title"),
                Window(FormattedTextControl(get_strategy_file),
                       style="class:title"),
            ],
            height=1),
        VSplit([
            FloatContainer(
                HSplit([
                    output_field,
                    Window(height=1, char='-', style='class:primary'),
                    input_field,
                ]),
                [
                    # Completion menus.
                    Float(xcursor=True,
                          ycursor=True,
                          transparent=True,
                          content=CompletionsMenu(max_height=16,
                                                  scroll_offset=1)),
                ]),
            Window(width=1, char='|', style='class:primary'),
            HSplit([
                log_field,
                search_field,
            ]),
        ]),
        VSplit([
            trade_monitor,
            process_monitor,
            timer,
        ], height=1),
    ])
    return Layout(root_container, focused_element=input_field)
Ejemplo n.º 26
0
 def get_status(self):
     if self.error_messages:
         return Window(
             FormattedTextControl(
                 FormattedText([('class:error', self.error_messages)]), ),
             height=1,
         )
     return Label('')
Ejemplo n.º 27
0
 def __init__(self, style=""):
     self.message = None
     self.text_control = FormattedTextControl(text="")
     super(MessageToolbar,
           self).__init__(content=Window(style=style,
                                         content=self.text_control,
                                         height=1),
                          filter=Condition(lambda: self.text))
Ejemplo n.º 28
0
    def __init__(self, values):
        assert isinstance(values, list)
        assert len(values) > 0
        assert all(isinstance(i, tuple) and len(i) == 2 for i in values)

        self.values = values
        self.current_value = values[0][0]
        self._selected_index = 0

        # Key bindings.
        kb = KeyBindings()

        @kb.add('up')
        def _(event):
            self._selected_index = max(0, self._selected_index - 1)

        @kb.add('down')
        def _(event):
            self._selected_index = min(
                len(self.values) - 1, self._selected_index + 1)

        @kb.add('pageup')
        def _(event):
            w = event.app.layout.current_window
            self._selected_index = max(
                0, self._selected_index - len(w.render_info.displayed_lines))

        @kb.add('pagedown')
        def _(event):
            w = event.app.layout.current_window
            self._selected_index = min(
                len(self.values) - 1,
                self._selected_index + len(w.render_info.displayed_lines))

        @kb.add('enter')
        @kb.add(' ')
        def _(event):
            self.current_value = self.values[self._selected_index][0]

        @kb.add(Keys.Any)
        def _(event):
            # We first check values after the selected value, then all values.
            for value in self.values[self._selected_index + 1:] + self.values:
                if value[1].startswith(event.data):
                    self._selected_index = self.values.index(value)
                    return

        # Control and window.
        self.control = FormattedTextControl(self._get_text_fragments,
                                            key_bindings=kb,
                                            focusable=True)

        self.window = Window(content=self.control,
                             style='class:radio-list',
                             right_margins=[
                                 ScrollbarMargin(display_arrows=True),
                             ],
                             dont_extend_height=True)
Ejemplo n.º 29
0
def prompt(text: Union[str, FormattedText],
           title: str = '',
           actions: List[Action] = [],
           **kwargs: Any) -> None:
    """A simple and extensible prompt helper routine

    :param text: Text to be printed before the prompt, it can be formatted text
    :type  text: str or FormattedText
    :param title: Title to be shown in a bottom bar
    :type  title: str
    :param actions: A list of Actions as defined in `Action`.
    :type  actions: [Action]
    :param kwargs: kwargs to prompt_toolkit application class
    """
    assert (isinstance(actions, list))
    assert (type(title) == str)

    kb = KeyBindings()

    for action in actions:
        kb.add(action.key)(action.action)

    print_formatted_text(FormattedText(text))

    root_container = HSplit([
        Window(wrap_lines=True,
               height=1,
               align=WindowAlign.LEFT,
               always_hide_cursor=True,
               style='bg:ansiblack fg:ansiwhite',
               content=FormattedTextControl(
                   focusable=False,
                   text=HTML(' '.join(
                       "{a.name}<yellow>[{a.key}]</yellow>".format(a=a)
                       for a in actions))))
    ] + ([
        Window(height=1,
               align=WindowAlign.LEFT,
               always_hide_cursor=True,
               style='bold fg:ansipurple bg:ansiwhite',
               content=FormattedTextControl(focusable=False, text=title))
    ] if title else []))

    app = Application(layout=Layout(root_container), key_bindings=kb, **kwargs)
    app.run()
Ejemplo n.º 30
0
 def output_hook(self, msg: Dict[str, Any]):
     msg_id = msg["parent_header"]["msg_id"]
     execution_count = self.msg_id_2_execution_count[msg_id]
     msg_type = msg["header"]["msg_type"]
     content = msg["content"]
     outputs = self.executing_cells[execution_count].json["outputs"]
     if msg_type == "stream":
         if (not outputs) or (outputs[-1]["name"] != content["name"]):
             outputs.append({
                 "name": content["name"],
                 "output_type": msg_type,
                 "text": []
             })
         outputs[-1]["text"].append(content["text"])
     elif msg_type in ("display_data", "execute_result"):
         outputs.append({
             "data": {
                 "text/plain": [content["data"].get("text/plain", "")]
             },
             "execution_count": execution_count,
             "metadata": {},
             "output_type": msg_type,
         })
         text = rich_print(f"Out[{execution_count}]:", style="red", end="")
         self.executing_cells[
             execution_count].output_prefix.content = FormattedTextControl(
                 text=ANSI(text))
     elif msg_type == "error":
         outputs.append({
             "ename": content["ename"],
             "evalue": content["evalue"],
             "output_type": "error",
             "traceback": content["traceback"],
         })
     else:
         return
     text, height = get_output_text_and_height(outputs)
     self.executing_cells[
         execution_count].output.content = FormattedTextControl(text=text)
     height_keep = self.executing_cells[execution_count].output.height
     self.executing_cells[execution_count].output.height = height
     if self.app and height_keep != height:
         # height has changed
         self.focus(self.current_cell_idx, update_layout=True)
         self.app.invalidate()