Skip to content

repl: No color_depth for show_result and OutputPrinter #596

@vallsv

Description

@vallsv

Hi,

I use another version of ptpython and have noticed that the result of PythonRepl does not take care of the color_depth.

    def print_formatted_text(
        self, formatted_text: StyleAndTextTuples, end: str = "\n"
    ) -> None:
        print_formatted_text(
            FormattedText(formatted_text),
            style=self._current_style,
            style_transformation=self.style_transformation,
            include_default_pygments_style=False,
            output=self.app.output,
            end=end,
        )

Looking at your main code code, now not it use a OutputPrinter but the result is the same.

Is there a reason not to use color_depth for printing the result (while the min/max intensity are propagated through self.style_transformation)?

It's particularly weird when the color_depth = 1bit.

The fix was easy, but have to be done in a different way in your main branch.

    def print_formatted_text(
        self, formatted_text: StyleAndTextTuples, end: str = "\n"
    ) -> None:
        print_formatted_text(
            FormattedText(formatted_text),
            style=self._current_style,
            style_transformation=self.style_transformation,
+           color_depth=self.color_depth,
            include_default_pygments_style=False,
            output=self.app.output,
            end=end,
        )

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions