tui-rs icon indicating copy to clipboard operation
tui-rs copied to clipboard

Line breaks not rendered properly in List and SelectableList

Open MasonAsh opened this issue 5 years ago • 3 comments

When using a List or SelectableList, if an item contain newlines, text after the newline will get overwritten by the next items.

For example:

SelectableList::default()
    .items(&["Hey\nYou",":O:O:O"])
    .render(&mut f, size);

Renders as:

Hey
:O:O:O

When it should be rendered as:

Hey
You
:O:O:O

MasonAsh avatar Oct 13 '18 02:10 MasonAsh

I don't know how I feel about that. The current behavior is what I had in mind, i.e: 1 item = 1 line. Thus, this is more about supporting multi-line items in lists which will imply a bit of rework on the layout computation, styling, indexing, etc. Is that what you had in mind ?

fdehau avatar Nov 04 '18 18:11 fdehau

I understand if you wish to leave it to 1 item = 1 line, but it should at least be newline aware and perhaps truncate the output if there are newlines.

As it is currently text from the previous item can overflow to the next items.

For example:

items(&["Hey\n\nYou",":O:O:O"])

will overflow and get rendered as

Hey
:O:O:O
   You

MasonAsh avatar Nov 16 '18 19:11 MasonAsh

First of all. Tui is an awesome tool and thank you for all of your hard work. I too would like to have the capability for multi-line ListItems

babinc avatar Mar 15 '22 18:03 babinc