From b5f2c38b6fc34e49aa4207939ded04fc39f1752b Mon Sep 17 00:00:00 2001 From: Michael Golubev Date: Sun, 4 Aug 2019 20:57:35 +0200 Subject: [PATCH] IDEA-179900 - Docker exec tab does not correctly wrap - TerminalListener: allow to handle tty resize events from terminal + switch to modern condensed copyright comments GitOrigin-RevId: 18e98334d90a4d2c48b26ce272c9f1433c1009a5 --- .../agent/util/log/TerminalListener.java | 26 ++++++++--------- .../util/CloudLoggingHandlerImpl.java | 28 +++++++------------ 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/TerminalListener.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/TerminalListener.java index 30f3be67e29b..b5a5cb4fa9ad 100644 --- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/TerminalListener.java +++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/TerminalListener.java @@ -1,28 +1,24 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.remoteServer.agent.util.log; public interface TerminalListener { void close(); + void setTtyResizeHandler(TtyResizeHandler ttyResizeHandler); + TerminalListener NULL = new TerminalListener() { public void close() { + // + } + public void setTtyResizeHandler(TtyResizeHandler ttyResizeHandler) { + // } }; + + interface TtyResizeHandler { + void onTtyResizeRequest(int ttyWidth, int ttyHeight); + } } diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java index 49e8a2aafea9..c27e71d90d16 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.remoteServer.util; import com.intellij.execution.process.ProcessHandler; @@ -20,6 +6,7 @@ import com.intellij.remoteServer.agent.util.CloudAgentLoggingHandler; import com.intellij.remoteServer.agent.util.log.LogListener; import com.intellij.remoteServer.agent.util.log.TerminalListener; import com.intellij.remoteServer.impl.runtime.log.LoggingHandlerBase; +import com.intellij.remoteServer.impl.runtime.log.TerminalHandlerBase; import com.intellij.remoteServer.runtime.deployment.DeploymentLogManager; import com.intellij.remoteServer.runtime.log.LoggingHandler; import com.intellij.remoteServer.runtime.log.TerminalHandler; @@ -29,9 +16,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; -/** - * @author michael.golubev - */ public class CloudLoggingHandlerImpl implements CloudAgentLoggingHandler { private final HashMap myPipeName2LogListener; @@ -111,6 +95,7 @@ public class CloudLoggingHandlerImpl implements CloudAgentLoggingHandler { InputStream terminalOutput, InputStream stderr) { final TerminalHandler terminalHandler = myLogManager.addTerminal(pipeName, terminalOutput, terminalInput); + return new TerminalListener() { @Override @@ -119,6 +104,13 @@ public class CloudLoggingHandlerImpl implements CloudAgentLoggingHandler { terminalHandler.close(); } } + + @Override + public void setTtyResizeHandler(TtyResizeHandler ttyResizeHandler) { + if (terminalHandler instanceof TerminalHandlerBase && ttyResizeHandler != null) { + ((TerminalHandlerBase)terminalHandler).setResizeHandler(size -> ttyResizeHandler.onTtyResizeRequest(size.width, size.height)); + } + } }; }