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

Last line is not displayed when scrolling using Display #737

Closed
Arsou33 opened this issue Nov 7, 2021 · 2 comments
Closed

Last line is not displayed when scrolling using Display #737

Arsou33 opened this issue Nov 7, 2021 · 2 comments
Milestone

Comments

@Arsou33
Copy link

Arsou33 commented Nov 7, 2021

Hi,

I'm using the artifact jline-terminal to build a user interface. ​In some conditions, the last line is not displayed

1 : ​ Display lines on every lines of the terminal :

 ----------- 
| Line 2    |
| Line 3    |
| Line 4    |
| Line 5    |
 ----------- 

2 : Display the same lines but all shift down with a first new lines

 ----------- 
| Line 1    |
| Line 2    |
| Line 3    |
|           | <-- Missing line not displayed
 ----------- 

Below a fonction to reproduce it. I tested it on iTerm2 and in a 'standard' terminal on MacOS.

    public static void main(String[] args) throws InterruptedException, IOException {

        try (Terminal terminal = TerminalBuilder.builder().build()) {
            Attributes savedAttributes = terminal.enterRawMode();
            terminal.puts(enter_ca_mode);
            int height = terminal.getHeight();

            Display display = new Display(terminal, true);
            display.resize(height, terminal.getWidth());

            // Build Strings to displayed
            List<AttributedString> lines1 = new ArrayList<>();
            for (int i = 1; i < height + 1; i++) {
                lines1.add( new AttributedString(String.format("%03d: %s", i, "Chaine de test...")));
            }

            List<AttributedString> lines2 = new ArrayList<>();
            for (int i = 0; i < height; i++) {
                lines2.add(new AttributedString(String.format("%03d: %s", i, "Chaine de test...")));
            }

             // Display with tempo 
            display.update(lines1, 0);
            Thread.sleep(3000);

            display.update(lines2, 0);
            Thread.sleep(3000);

            terminal.setAttributes(savedAttributes);
            terminal.puts(exit_ca_mode);
        }
    }

echo $TERM
xterm-256color

BR

@mattirn
Copy link
Collaborator

mattirn commented Nov 7, 2021

You can either clear the display (display.clear()) before displaying lines2 or add a common footer to your lines to be displayed:

            List<AttributedString> lines1 = new ArrayList<>();
            for (int i = 1; i < height; i++) {
                lines1.add( new AttributedString(String.format("%03d: %s", i, "Chaine de test...")));
            }
            lines1.add(new AttributedString(">>>"));

            List<AttributedString> lines2 = new ArrayList<>();
            for (int i = 0; i < height - 1; i++) {
                lines2.add(new AttributedString(String.format("%03d: %s", i, "Chaine de test...")));
            }
            lines2.add(new AttributedString(">>>"));

@Arsou33
Copy link
Author

Arsou33 commented Nov 7, 2021

Thanks, i already added 'clear' as a workaround, and it's working.

@gnodet gnodet closed this as completed in f89e28a Nov 8, 2021
@mattirn mattirn changed the title Last line is not displayed Last line is not displayed when scrolling using Display Jan 26, 2022
@gnodet gnodet added this to the 3.22.0 milestone Jan 16, 2023
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

3 participants