< Summary

Information
Class: Renci.SshNet.Messages.Connection.PseudoTerminalRequestInfo
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelRequest\PseudoTerminalRequestInfo.cs
Line coverage
100%
Covered lines: 42
Uncovered lines: 0
Coverable lines: 42
Total lines: 161
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_RequestName()100%1100%
get_EnvironmentVariable()100%1100%
get_Columns()100%1100%
get_Rows()100%1100%
get_PixelWidth()100%1100%
get_PixelHeight()100%1100%
get_TerminalModeValues()100%1100%
get_BufferCapacity()100%1100%
.ctor()100%1100%
.ctor(...)100%1100%
SaveData()100%6100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelRequest\PseudoTerminalRequestInfo.cs

#LineLine coverage
 1using System.Collections.Generic;
 2
 3using Renci.SshNet.Common;
 4
 5namespace Renci.SshNet.Messages.Connection
 6{
 7    /// <summary>
 8    /// Represents "pty-req" type channel request information.
 9    /// </summary>
 10    internal sealed class PseudoTerminalRequestInfo : RequestInfo
 11    {
 12        /// <summary>
 13        /// Channel request name.
 14        /// </summary>
 15        public const string Name = "pty-req";
 16
 17        /// <summary>
 18        /// Gets the name of the request.
 19        /// </summary>
 20        /// <value>
 21        /// The name of the request.
 22        /// </value>
 23        public override string RequestName
 24        {
 3925            get { return Name; }
 26        }
 27
 28        /// <summary>
 29        /// Gets or sets the value of the TERM environment variable (e.g., vt100).
 30        /// </summary>
 31        /// <value>
 32        /// The value of the TERM environment variable.
 33        /// </value>
 4134        public string EnvironmentVariable { get; set; }
 35
 36        /// <summary>
 37        /// Gets or sets the terminal width in columns (e.g., 80).
 38        /// </summary>
 39        /// <value>
 40        /// The terminal width in columns.
 41        /// </value>
 4142        public uint Columns { get; set; }
 43
 44        /// <summary>
 45        /// Gets or sets the terminal width in rows (e.g., 24).
 46        /// </summary>
 47        /// <value>
 48        /// The terminal width in rows.
 49        /// </value>
 4150        public uint Rows { get; set; }
 51
 52        /// <summary>
 53        /// Gets or sets the terminal width in pixels (e.g., 640).
 54        /// </summary>
 55        /// <value>
 56        /// The terminal width in pixels.
 57        /// </value>
 4158        public uint PixelWidth { get; set; }
 59
 60        /// <summary>
 61        /// Gets or sets the terminal height in pixels (e.g., 480).
 62        /// </summary>
 63        /// <value>
 64        /// The terminal height in pixels.
 65        /// </value>
 4166        public uint PixelHeight { get; set; }
 67
 68        /// <summary>
 69        /// Gets or sets the terminal mode.
 70        /// </summary>
 71        /// <value>
 72        /// The terminal mode.
 73        /// </value>
 5674        public IDictionary<TerminalModes, uint> TerminalModeValues { get; set; }
 75
 76        /// <summary>
 77        /// Gets the size of the message in bytes.
 78        /// </summary>
 79        /// <value>
 80        /// <c>-1</c> to indicate that the size of the message cannot be determined,
 81        /// or is too costly to calculate.
 82        /// </value>
 83        protected override int BufferCapacity
 84        {
 4885            get { return -1; }
 86        }
 87
 88        /// <summary>
 89        /// Initializes a new instance of the <see cref="PseudoTerminalRequestInfo"/> class.
 90        /// </summary>
 282691        public PseudoTerminalRequestInfo()
 282692        {
 282693            WantReply = true;
 282694        }
 95
 96        /// <summary>
 97        /// Initializes a new instance of the <see cref="PseudoTerminalRequestInfo"/> class.
 98        /// </summary>
 99        /// <param name="environmentVariable">The <c>TERM</c> environment variable which a identifier for the text windo
 100        /// <param name="columns">The terminal width in columns.</param>
 101        /// <param name="rows">The terminal width in rows.</param>
 102        /// <param name="width">The terminal width in pixels.</param>
 103        /// <param name="height">The terminal height in pixels.</param>
 104        /// <param name="terminalModeValues">The terminal mode values.</param>
 105        /// <remarks>
 106        /// <para>
 107        /// The <c>TERM</c> environment variable contains an identifier for the text window's capabilities.
 108        /// You can get a detailed list of these cababilities by using the ‘infocmp’ command.
 109        /// </para>
 110        /// <para>
 111        /// The column/row dimensions override the pixel dimensions(when nonzero). Pixel dimensions refer
 112        /// to the drawable area of the window.
 113        /// </para>
 114        /// </remarks>
 115        public PseudoTerminalRequestInfo(string environmentVariable, uint columns, uint rows, uint width, uint height, I
 19116            : this()
 19117        {
 19118            EnvironmentVariable = environmentVariable;
 19119            Columns = columns;
 19120            Rows = rows;
 19121            PixelWidth = width;
 19122            PixelHeight = height;
 19123            TerminalModeValues = terminalModeValues;
 19124        }
 125
 126        /// <summary>
 127        /// Called when type specific data need to be saved.
 128        /// </summary>
 129        protected override void SaveData()
 16130        {
 16131            base.SaveData();
 132
 16133            Write(EnvironmentVariable);
 16134            Write(Columns);
 16135            Write(Rows);
 16136            Write(PixelWidth);
 16137            Write(PixelHeight);
 138
 16139            if (TerminalModeValues != null && TerminalModeValues.Count > 0)
 4140            {
 141                // write total length of encoded terminal modes, which is 1 bytes for the opcode / terminal mode
 142                // and 4 bytes for the uint argument for each entry; the encoded terminal modes are terminated by
 143                // opcode TTY_OP_END (which is 1 byte)
 4144                Write(((uint) TerminalModeValues.Count*(1 + 4)) + 1);
 145
 26146                foreach (var item in TerminalModeValues)
 7147                {
 7148                    Write((byte) item.Key);
 7149                    Write(item.Value);
 7150                }
 151
 4152                Write((byte) TerminalModes.TTY_OP_END);
 4153            }
 154            else
 12155            {
 156                // when there are no terminal mode, the length of the string is zero
 12157                Write(0u);
 12158            }
 16159        }
 160    }
 161}