Example #1
0
        void WriteOutput(byte c)
        {
            if (c == '\n' && (options.OFlag & PtyConstants.ONLCR) != 0)
            {
                outputStream.WriteByte((byte)'\r');
            }

            outputStream.WriteByte(c);
        }
Example #2
0
        void WriteInput(byte c)
        {
            lock (inputStream)
            {
                if ((options.LFlag & PtyConstants.ICANON) != 0)
                {
                    if (c == options.C_cc[PtyConstants.VERASE])
                    {
                        if (lineBufferPosition > 0)
                        {
                            lineBufferPosition--;
                        }

                        lineBuffer[lineBufferPosition] = 0;

                        WriteOutput((byte)'\b');

                        return;
                    }

                    if (c == options.C_cc[PtyConstants.VINTR])
                    {
                        WriteOutput((byte)'^');
                        WriteOutput((byte)'C');
                        WriteOutput((byte)'\n');

                        Monitor.PulseAll(inputStream);
                        FlushLineBuffer();

                        return;
                    }

                    lineBuffer[lineBufferPosition++] = c;

                    if ((options.LFlag & PtyConstants.ECHO) != 0)
                    {
                        WriteOutput(c);
                    }

                    if (c == (byte)'\n')
                    {
                        Monitor.PulseAll(inputStream);
                        FlushLineBuffer();
                    }

                    return;
                }
                inputStream.WriteByte(c);
            }
        }