Problem with VIM editor from remote server console

Viewed 41

I am developing a remote terminal.
UI: Thymeleaf, xterm.js.
Back: Java, Spring boot, Apache sshd-core.
Connection between front and back - websocket (implement xterm-addon-attach from ui and TextWebSocketHandler from back).
Coonection between back and remote server/console - apache sshd-core.
Code for listen remote server and send output to ui by websocket:

@Async
    public void listenRemoteConsole(String serverId, WebSocketSession session) throws IOException {
        Optional<BaseRemoteConsole> optional = remoteConsoleRegistry.getRemoteConsole(serverId);
        String current = "";
        while (optional.isPresent()) {
            BaseRemoteConsole console = optional.get();
            String next = console.getOutputStream().toString();
            if (!current.equals(next)) {
                current = next;
                TextMessage message = new TextMessage(current);
                session.sendMessage(message);
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
        optional = remoteConsoleRegistry.getRemoteConsole(serverId);
    }

Code for init and config terminal from UI:

    function initTerminal() {
        const protocol = "ws://";
        const host = document.location.host;
        const endpoint = contextPath + "/server/" + getServerId();
        const url = protocol + host + endpoint;
        websocket = new WebSocket(url);
        websocket.onmessage = function (data) {
            terminal.clear();
        };

        terminal = new Terminal(terminalOption);
        const attachAddon = new AttachAddon.AttachAddon(websocket);
        terminal.loadAddon(attachAddon);
        terminal.open(terminalContainer);
        terminal.focus();
    }

Copy, paste, backspace and other command and function work is correct, but if i am run VIM editor, I have many problems.

  1. When I am running VIM editor i have a log message from xterm.js in debug mode. Char in the example may be different. Example: xterm.js: Unknown CSI code: {"identifier": "H", "params": [1,1]}

  2. I have a very stranger output from remote server when i execute exit from VIM editor (use :q!command). Output can be different and depened from TERM env.

TERM=xterm-256colors output: 2RR0;276;0c10;rgb:cccc/cccc/cccc11;rgb:1c1c/2424/31312RR0;276;0c10;rgb:cccc/cccc/cccc11;rgb:1c1c/2424/31312RR0;276;0c10;rgb:cccc/cccc/cccc11;rgb:1c1c/2424/31312RR0;276;0c10;rgb:cccc/cccc/cccc11;rgb:1c1c/2424/31312RR0;276;0c10;rgb:cccc/cccc/cccc11;rgb:1c1c/2424/31312RR0;276;0c10;rgb:cccc/cccc/cccc11;rgb:1c1c/2424/31312RR0;276;0c10;rgb:cccc/cccc/cccc11;rgb:1c1c/2424/31312RR0;...

TERM=vt220 ouput: 2RR2RR2RR2RR2RR2RR2RR2RR2R...

If i use TERM=vt100, output is absent, but I don't have colors and many features like that mouse track control and other.

I want to have all features xterm's type terminal (include colors) work is correct. How i can configure TERM variable, UI or back for it and correct work?

0 Answers
Related