bczsalba / pytermgui

Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!
https://ptg.bczsalba.com
MIT License
2.25k stars 56 forks source link

[BUG] Button label truncated due to long markup string #124

Closed landersson closed 1 year ago

landersson commented 1 year ago

Is seems like button text gets truncated and terminated with three dots ("...") based on the total length of the button label string, including markup:

import pytermgui as ptg

with ptg.WindowManager() as manager:
    layout = ptg.Layout()
    layout.add_slot("body")
    manager.layout=layout

    window = (
        ptg.Window(
            ptg.Splitter(
                ptg.Button("Stop Recording"),
                ptg.Button("[bold underline yellow]Start[/bold /underline] [italic lightgreen]Recording")
        )
    ))
    manager.add(window, animate=False)

Unless the terminal is wide enough, it code above produces the following screen for me: image

Expected behaviour would be for the righthand button label not being truncated and correctly styled.

bczsalba commented 1 year ago

Sooooooo it turns out the button slicing was completely and utterly broken when used with a button that has inline markup, so removing it was the better option. Look at the commit comment for more info.

Thanks for the report!

landersson commented 1 year ago

Great, this solves my problem for now. Thanks for the fix!