【问题标题】:Renci SSH NET: Reflect width/height when resizing terminalRenci SSH NET:调整终端大小时反映宽度/高度
【发布时间】:2017-02-18 21:06:00
【问题描述】:

我目前正在使用 SSH.NET 进行终端仿真。使用当前列/行创建 SshClient 和 ShellStream 可以正常工作。

但是当我更改终端尺寸(如 Putty)的大小时,我找不到将新列/行发送到服务器的方法。

我看到的唯一方法是关闭 shellstream 并创建一个新的。有没有更好的方法将新的“布局”发送到服务器?

提前致谢:-)

【问题讨论】:

    标签: c# terminal ssh.net


    【解决方案1】:

    经过几天的调查,我最终在 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 的实现中缺少此功能。或许还有另一种方式……

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-21
      • 1970-01-01
      • 2013-04-28
      • 1970-01-01
      • 2017-12-08
      • 2013-05-18
      • 2021-12-28
      • 2013-08-23
      相关资源
      最近更新 更多