Skip to content

Preserve state of the terminal #14

@mvysny

Description

@mvysny

Removing XTerm component from the parent container then adding it back will result in a blank uninitialized terminal: there is no scrollback history, and the settings (such as cursor style or similar) are not preserved.

The code which reproduces the issue:

public class MainView extends VerticalLayout {

    public MainView() {
        final XTerm xterm = new XTerm();
        add(xterm);
        xterm.setWidthFull();
        xterm.setHeight("500px");
        xterm.writeln("Hello!");
        xterm.setCursorStyle(ITerminalOptions.CursorStyle.UNDERLINE);
        xterm.setCursorBlink(true);
        xterm.write("$ ");
        xterm.addLineListener(e -> {
            System.out.println(e.getLine());
            xterm.writeln("You typed: " + e.getLine());
            xterm.write("$ ");
        });

        final Checkbox checkbox = new Checkbox("Add/remove xterm");
        checkbox.setValue(true);
        add(checkbox);
        checkbox.addValueChangeListener(e -> {
            if (e.getValue()) {
                MainView.this.add(xterm);
            } else {
                MainView.this.remove(xterm);
            }
        });
        add(checkbox);
    }
}

Steps to reproduce:

  1. Type in something
  2. Uncheck the checkbox
  3. Check the checkbox back
  4. Observe that the xterm settings are not preserved.

Just a wild suggestion: perhaps the settings and the scrollback buffer could actually be preserved on the Java side and applied every time the component is attached.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions