Term.jl icon indicating copy to clipboard operation
Term.jl copied to clipboard

Style information is dropped on wrapped lines.

Open nathanrboyer opened this issue 2 years ago • 6 comments

julia> Panel("{dim}This is some long text.{/dim}")
╭───────────────────────────╮
│  This is some long text.  │ <-- shown dim
╰───────────────────────────╯

julia> Panel("{dim}This is some long text.{/dim}", width=20, fit=false)
╭──────────────────╮
│  This is some    │ <-- shown dim
│  long text.      │ <-- shown normal
╰──────────────────╯

nathanrboyer avatar Jun 20 '22 19:06 nathanrboyer

Fix for the next release: image

As always, you do such a great job of finding bugs! Thank you!

FedeClaudi avatar Jun 22 '22 07:06 FedeClaudi

Solved in https://github.com/FedeClaudi/Term.jl/pull/124

FedeClaudi avatar Jun 22 '22 08:06 FedeClaudi

I'm still getting the same behavior on version 1.0.4. The white text inside the panels is in error.

image

nathanrboyer avatar Oct 11 '22 18:10 nathanrboyer

I'm actually not sure why the text is wrapping at all. The panel width should be expanding to fit the text. The functions for creating those panels are below:

"""
    tableKM620_options()

Returns a terminal panel with the material information from Table KM-620. Call `print` or `println` on the result to diplay it.
"""
function tableKM620_options()
    option_text = RenderableText(join(tableKM620."Material", "\n"), style = "dim")
    option_numbers = RenderableText(join(string.(collect(1:option_text.measure.h)), "\n"), style = "dim")
    vline = vLine(option_numbers, style = "cyan")
    note_text = RenderableText("Ferritic steel includes carbon, low alloy, and alloy steels,\n" *
                                "and ferritic, martensitic, and iron-based age-hardening stainless steels."
                                , style = "dim")
    note_panel = Panel(note_text,
                        title = "Note",
                        style = "cyan")
    top_text = TextBox(option_numbers * " " * vline * " " * option_text,
                        padding = (2, 0, 0, 0))
    options_panel = Panel(top_text / note_panel,
                        title = "Table KM-620 Material Categories",
                        style = "cyan")
    return options_panel
end

"""
    yield_options()

Returns a terminal panel with the yield strain calculation options. Call `print` or `println` on the result to diplay it.
"""
function yield_options()
    option_text = RenderableText("Use ϵₚ from Table KM-620 as the proportional limit tolerance at yield.\n" *
                                "Use 0.2% engineering offset strain as the proportional limit tolerance at yield.\n" *
                                "Specify my own proportional limit tolerance at yield.",
                                style = "dim")
    option_numbers = RenderableText(join(string.(collect(1:option_text.measure.h)), "\n"), style = "dim")
    vline = vLine(option_numbers, style = "cyan")
    options_panel = Panel(option_numbers * " " * vline * " " * option_text,
                            title = "Yield Point Calculation Options",
                            style = "cyan",
                            padding = (5, 5, 1, 1))
    return options_panel
end

nathanrboyer avatar Oct 11 '22 18:10 nathanrboyer

Hey, the fit argument of Panel is false by default (this might have changed in recent releases, sorry) (see here). Have you tried setting fit=true?

FedeClaudi avatar Oct 12 '22 00:10 FedeClaudi

Ah, okay. I must have missed that. Setting fit=true fixes the issue for me, but you may still be interested in the style being reset on the wrapped lines above. image

nathanrboyer avatar Oct 12 '22 13:10 nathanrboyer