【发布时间】:2017-02-18 21:06:00
【问题描述】:
我目前正在使用 SSH.NET 进行终端仿真。使用当前列/行创建 SshClient 和 ShellStream 可以正常工作。
但是当我更改终端尺寸(如 Putty)的大小时,我找不到将新列/行发送到服务器的方法。
我看到的唯一方法是关闭 shellstream 并创建一个新的。有没有更好的方法将新的“布局”发送到服务器?
提前致谢:-)
【问题讨论】:
我目前正在使用 SSH.NET 进行终端仿真。使用当前列/行创建 SshClient 和 ShellStream 可以正常工作。
但是当我更改终端尺寸(如 Putty)的大小时,我找不到将新列/行发送到服务器的方法。
我看到的唯一方法是关闭 shellstream 并创建一个新的。有没有更好的方法将新的“布局”发送到服务器?
提前致谢:-)
【问题讨论】:
经过几天的调查,我最终在 ShellStream.cs 中实现了一个新方法:
/// <summary>
/// Sends a "window-change" request.
/// </summary>
/// <param name="columns">The terminal width in columns.</param>
/// <param name="rows">The terminal width in rows.</param>
/// <param name="width">The terminal height in pixels.</param>
/// <param name="height">The terminal height in pixels.</param>
public void SendWindowChangeRequest(uint columns, uint rows, uint width, uint height)
{
if (_channel == null)
{
throw new ObjectDisposedException("ShellStream");
}
_channel.SendWindowChangeRequest(columns, rows, width, height);
}
这解决了问题。现在我可以调用“SendWindowChangeRequest(...)”并且服务器端的 shell 窗口是最新的 :-)
不确定,为什么 Renci 的实现中缺少此功能。或许还有另一种方式……
【讨论】: