Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParagraphBuilder truncates all text after the first newline #370

Open
nanodeath opened this issue Mar 12, 2021 · 1 comment
Open

ParagraphBuilder truncates all text after the first newline #370

nanodeath opened this issue Mar 12, 2021 · 1 comment

Comments

@nanodeath
Copy link
Contributor

Describe the bug
When adding a paragraph using TextBoxBuilder.addParagraph, it uses a ParagraphBuilder internally. That ParagraphBuilder discards everything after the first newline, which is surprising behavior.

To Reproduce

Code something like this:

Components.textBox(20)
    .addParagraph("foo\nbar")
    .build()

Expected behavior

This is actually an interesting question. I think my preference is that single newlines be replaced with whitespace, and multiple consecutive newlines be replaced with n-1 newlines.

For instance, if I say

.addParagraph("""
    okay this is a really long paragraph where
    I need multiple lines and stuff just to capture
    the spectacle the player sees
    """.trimIndent()

I don't necessarily want my in-editor linebreaks to be reflected exactly in game; just wordwrap it into whatever container it's in.

But if I say

.addParagraph("""
    In the beginning, life was good.

    But at some point, it stopped being good.
""".trimIndent())

I wouldn't expect this to be collapsed into a single sentence. Really I should use multiple addParagraph calls, but maybe it's being loaded from an external translations file or something. I'd be fine with In the beginning, life was good.\nBut at some point, it stopped being good.. If I really want to preserve the linebreak in the source code, I can add another newline.

I'm open to other opinions here, this seems admittedly subjective.

Screenshots

image

Additional context
String.withNewLinesStripped is at the heart of this. It doesn't actually strip newlines; it deletes everything after the first newline.

@nanodeath
Copy link
Contributor Author

I'm also inclined to pick this one up once we decide what the desired behavior is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant