DioxusLabs/blitz

TUI: Overflow is not working

George-Miao opened this issue · 1 comments

Problem

Long text is not hidden or trimmed properly according to overflow attribute, which will cause out-of-boundry panic.

Steps To Reproduce

Code:

fn main() {
    dioxus_tui::launch(|cx| {
        cx.render(rsx!{
            div {
                "overflow": "hidden",
                "------------------------------------------------------------------------------------------------------------------"
            }
        })
    });
}

Expected behavior

Text should be trimmed or wrapped when length is greater than container's width.

Screenshots

image

Environment:

  • Dioxus version: [0.2.3]
  • Rust version: [rustc 1.61.0-nightly (8d60bf427 2022-03-19)]
  • OS info: [Linux]
  • Terminal: [Alacritty]
  • App platform: [tui]

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later

Good catch. It looks like the text rendering in https://github.com/DioxusLabs/dioxus/blob/master/packages/tui/src/render.rs#L66 ignores the size of the layout right now. We have code that parses overflow for stretch2 in the attributes file, but stretch2 never uses it. We can add a field for it in the TuiNode for overflow and use it in the renderer.
Edit: stretch allows specifying a measure function we might be able to use for wrapping to allow the changes to effect the rest of the layout