[ https://issues.apache.org/jira/browse/SSHD-1235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17465571#comment-17465571 ]
Thomas Wolf commented on SSHD-1235: ----------------------------------- Not sure this is a bug in Jediterm or Apache MINA sshd. Shouldn't your code restore the terminal characteristics it changed when closing? > Terminal resizing: with jediterm, when quit from vim, terminal don't > resizing any more > --------------------------------------------------------------------------------------- > > Key: SSHD-1235 > URL: https://issues.apache.org/jira/browse/SSHD-1235 > Project: MINA SSHD > Issue Type: Bug > Affects Versions: 2.8.0 > Environment: IDEA > Reporter: g3g4x5x6 > Priority: Major > > h1. Create widget > > {code:java} > ...... > private ClientSession getSession(SshClient client){ > ClientSession session; > try { > session = client.connect(this.user, this.host, > this.port).verify(5000, TimeUnit.MILLISECONDS).getSession(); > session.addPasswordIdentity(this.pass); > session.auth().verify(15, TimeUnit.SECONDS); > > session.setSessionHeartbeat(SessionHeartbeatController.HeartbeatType.IGNORE, > Duration.ofMinutes(3)); > return session; > } catch (IOException e) { > e.printStackTrace(); > DialogUtil.error(e.getMessage()); > return null; > } > } > ...... > private @NotNull JediTermWidget createTerminalWidget() { > SshSettingsProvider sshSettingsProvider = new SshSettingsProvider(); > JediTermWidget widget = new JediTermWidget(sshSettingsProvider); > widget.setTtyConnector(new DefaultTtyConnector(session)); > widget.start(); > return widget; > } {code} > > > h1. DefaultTtyConnector > {code:java} > package com.g3g4x5x6.ui.panels.ssh; > import com.jediterm.terminal.Questioner; > import com.jediterm.terminal.TtyConnector; > import lombok.SneakyThrows; > import lombok.extern.slf4j.Slf4j; > import org.apache.sshd.client.channel.ChannelShell; > import org.apache.sshd.client.session.ClientSession; > import org.jetbrains.annotations.NotNull; > import java.awt.*; > import java.io.*; > import java.nio.charset.StandardCharsets; > import java.util.concurrent.TimeUnit; > @Slf4j > public class DefaultTtyConnector implements TtyConnector { > private ClientSession session; > private ChannelShell channel; > private Dimension myPendingTermSize; > private PipedOutputStream channelOut; > private InputStream channelIn; > private OutputStream outputStream; > private BufferedReader reader; > private BufferedWriter writer; > public DefaultTtyConnector(ClientSession clientSession) { > this.session = clientSession; > } > @Override > public boolean init(Questioner questioner) { > try { > PipedOutputStream out = new PipedOutputStream(); > channelIn = new PipedInputStream(out); > channelOut = new PipedOutputStream(); > PipedInputStream in = new PipedInputStream(channelOut); > reader = new BufferedReader(new InputStreamReader(in, > StandardCharsets.UTF_8)); > writer = new BufferedWriter(new OutputStreamWriter(out)); > channel = initClientChannel(session, channelIn, channelOut); > outputStream = channel.getInvertedIn(); > } catch (IOException e) { > e.printStackTrace(); > } > return true; > } > private ChannelShell initClientChannel(ClientSession session, InputStream > input, OutputStream output) throws IOException { > ChannelShell channel = session.createShellChannel(); > String lang = (String) System.getenv().get("LANG"); > channel.setEnv("LANG", lang != null ? lang : "zh_CN.UTF-8"); > channel.setPtyType("xterm"); > channel.setUsePty(true); > channel.setIn(input); > channel.setOut(output); > channel.setErr(output); > channel.open().verify(3000, TimeUnit.MILLISECONDS); > return channel; > } > @SneakyThrows > @Override > public void close() { > channel.close(); > } > @Override > public String getName() { > return "SSH"; > } > @Override > public int read(char[] chars, int i, int i1) throws IOException { > return reader.read(chars, i, i1); > } > @Override > public void write(byte[] bytes) throws IOException { > outputStream.write(bytes); > outputStream.flush(); > } > @Override > public boolean isConnected() { > return channel.isOpen(); > } > @Override > public void write(String s) throws IOException { > log.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>" + s); > this.write(s.getBytes(StandardCharsets.UTF_8)); > } > @Override > public int waitFor() throws InterruptedException { > return channel.getExitStatus(); > } > @Override > public boolean ready() throws IOException { > return true; > } > @Override > public void resize(@NotNull Dimension termWinSize) { > channel.setPtyWidth(termWinSize.width); > channel.setPtyHeight(termWinSize.height); > channel.setPtyColumns(termWinSize.width); > channel.setPtyLines(termWinSize.height); > } > private void resizeImmediately() { > if (this.myPendingTermSize != null) { > this.setPtySize(this.channel, > this.myPendingTermSize.width, > this.myPendingTermSize.height, > this.myPendingTermSize.width, > this.myPendingTermSize.height); > this.myPendingTermSize = null; > } > } > private void setPtySize(ChannelShell channel, int col, int row, int wp, > int hp) { > channel.setPtyColumns(col); > channel.setPtyLines(row); > channel.setPtyWidth(wp); > channel.setPtyHeight(hp); > } > } {code} > h1. Problem > [info|https://github.com/JetBrains/jediterm/issues/236] -- This message was sent by Atlassian Jira (v8.20.1#820001) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org For additional commands, e-mail: dev-h...@mina.apache.org