Skip to content

Blinking when using overwrite_display V3 #265

@GregPlowman

Description

@GregPlowman

When using overwrite_display, I observe blinking between each display.

There was no blinking in PrettyTables version 2 when using overwrite keyword.

Here's some code to test each version:

using PrettyTables

function test_overwrite_v2()
    header = (
        ["Time", "Acceleration", "Velocity", "Distance"],
        [   "s",     "[m / s²]",  "[m / s]",      "[m]"]
    )

    hl_p = Highlighter(
        (data, i, j) -> (j == 4) && (data[i, j] > 9), crayon"blue bold"
    )

    hl_v = Highlighter(
        (data, i, j) -> (j == 3) && (data[i, j] > 9), crayon"red bold"
    )

    hl_10 = Highlighter( 
        (data, i, j) -> (i == 10), crayon"fg:white bold bg:dark_gray"
    )

    for start in 0:10
        t = range(; start, length=21)
        data = hcat(t, ones(length(t)), t, 0.5.*t.^2)

        pretty_table(
            data;
            formatters    = ft_printf("%5.2f", 2:4),
            header        = header,
            header_crayon = crayon"yellow bold",
            highlighters  = (hl_10, hl_p, hl_v),
            tf            = tf_unicode_rounded,
            overwrite     = true
        )
        
        sleep(1)
    end
end

function test_overwrite_v3()
    column_labels = [
        ["Time", "Acceleration", "Velocity", "Distance"],
        [ "[s]",     "[m / s²]",  "[m / s]",      "[m]"]
    ]

    hl_p = TextHighlighter(
        (data, i, j) -> (j == 4) && (data[i, j] > 9), crayon"blue bold"
    )

    hl_v = TextHighlighter(
        (data, i, j) -> (j == 3) && (data[i, j] > 9), crayon"red bold"
    )

    hl_10 = TextHighlighter(
        (data, i, j) -> (i == 10), crayon"fg:white bold bg:dark_gray"
    )

    style = TextTableStyle(first_line_column_label = crayon"yellow bold")

    table_format = TextTableFormat(borders = text_table_borders__unicode_rounded)

    for start in 0:10
        t = range(; start, length=21)
        data = hcat(t, ones(length(t)), t, 0.5.*t.^2);
        
        pretty_table(
            data;
            column_labels     = column_labels,
            style             = style,
            highlighters      = [hl_10, hl_p, hl_v],
            table_format      = table_format_format  = TextTableFormat(borders = text_table_borders__unicode_rounded),
            overwrite_display = true
        )
        
        sleep(1)
    end
end

pkgversion(PrettyTables).major == 2 && test_overwrite_v2()
pkgversion(PrettyTables).major == 3 && test_overwrite_v3()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions