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

status line issue with strings with attributes #302

Closed
stefanofornari opened this issue Aug 14, 2018 · 5 comments
Closed

status line issue with strings with attributes #302

stefanofornari opened this issue Aug 14, 2018 · 5 comments

Comments

@stefanofornari
Copy link

Hello,
I am quite happy to work with the new status functionality, but I may have incurred into a bug. This is the code I use:

String statusLine = msg + "\t| ";

        for(Future f: tasks) {
            if (!f.isDone()) {
                statusLine +=
                    new AttributedString(
                        " T" + f.hashCode() + " ",
                        AttributedStyle.INVERSE.foreground(2).background(AttributedStyle.WHITE)
                    ).toAnsi();
            }
        }

Fundamentally I am creating the final string with attributes and then:

lines.add(new AttributedString(statusLine));
status.update(lines);
status.redraw();

The problem is that when the string growth the output breaks like in the attached screenshot. Is it a bug, or am I doing anything wrong?
strange

@gnodet
Copy link
Member

gnodet commented Aug 27, 2018

At this point, the Status helper does not cut strings to ensure the length is less than the terminal width.
You need to ensure the strings are not too long using:

        lines = lines.stream().map(l -> l.columnSubSequence(0, terminal.getWidth())).collect(Collectors.toList());

@stefanofornari
Copy link
Author

I will give it a try, but this happens far before the end of the terminal. maybe control chars are counted as normal chars?

@gnodet
Copy link
Member

gnodet commented Sep 3, 2018

Did you solve the problem ?

@stefanofornari
Copy link
Author

Hi, thanks for checking, I have still to check. hopefully this week!

@stefanofornari
Copy link
Author

It worked thanks!

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

2 participants