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

Terminal/Status line resizing issues on Windows #902

Closed
lucdono77 opened this issue Nov 14, 2023 · 2 comments
Closed

Terminal/Status line resizing issues on Windows #902

lucdono77 opened this issue Nov 14, 2023 · 2 comments

Comments

@lucdono77
Copy link

Hello, I am having issues resizing a terminal that provides a status line. The content is messed up and I haven't found any possible way to overcome this issue (Windows).
I have modified the Java example provided, by adding the status line border and another line, as follows:

                   while (true) {
                                try {
                                    Status status = Status.getStatus(reader.getTerminal());
                                    status.setBorder(true);
                                    counter++;
                                    status.update(Arrays.asList(
                                            new AttributedStringBuilder().append("counter: " + counter)
                                                    .toAttributedString(),
                                            new AttributedStringBuilder()
                                                    .append("Some te sdfg sd ewrt sdg sdg ryt rtsy rsty tfhxt")
                                                    .toAttributedString()));
                                    ((LineReaderImpl) reader).redisplay();
                                    Thread.sleep(1000);
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                }
                            }

As you can see from the attached screenshots, all appears ok if I don't resize the terminal:
normal

However, as soon as I maximise or stretch it, the content is messed up:
maximised
Stretch

The same issue appears also if I am using my own instance of the status line (i.e., without the factory method).

Could you please help?

@gnodet
Copy link
Member

gnodet commented Nov 19, 2023

After a resize, you need to redraw the terminal.
If you're reading a line, the line reader should already redisplay the prompt and the line being edited. For the line above, the terminal won't do anything because they are not in control.
If you're using a full-size terminal applications (such as nano, less, etc...), then you can catch the WINCH signal and redraw the terminal.

@lucdono77
Copy link
Author

Thanks for you reply, I'll follow your advice.
Regards,
Luca

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

No branches or pull requests

2 participants