Пример #1
0
        /// <summary>Runs the data through our presentation handlers.</summary>
        /// <param name="data">The data to format</param>
        /// <param name="connection">The connection object this data is going to be sent to</param>
        /// <param name="sendAllData">Indicates if all data should be sent.</param>
        /// <returns>A formatted string of data</returns>
        internal static string FormatData(string data, Connection connection, bool sendAllData)
        {
            if (connection.Terminal.UseWordWrap && connection.Terminal.Width > 0)
            {
                data = WordWrapHandler.Parse(data, connection.Terminal.Width);
            }

            if (connection.Terminal.UseBuffer && !sendAllData)
            {
                connection.OutputBuffer.Clear();
                string[] temp = BufferHandler.Parse(data);
                string[] output;
                bool     appendOverflow = false;

                if (temp.Length > connection.PagingRowLimit)
                {
                    appendOverflow = true;
                    connection.OutputBuffer.Append(temp);
                    output = connection.OutputBuffer.GetRows(BufferDirection.Forward, connection.PagingRowLimit);
                }
                else
                {
                    output = temp;
                }

                data = BufferHandler.Format(
                    output,
                    false,
                    appendOverflow,
                    connection.OutputBuffer.CurrentLocation,
                    connection.OutputBuffer.Length);
            }

            if (connection.Terminal.UseANSI)
            {
                data = AnsiHandler.Parse(data);
            }
            else
            {
                // TODO: Remove regex into separate parser.
                var    options     = RegexOptions.None;
                var    regex       = new Regex(@"<%?\w+[^>]*%>", options);
                string input       = data;
                string replacement = string.Empty;
                data = regex.Replace(input, replacement);
            }

            if (!connection.Terminal.UseMXP)
            {
                // TODO: Remove regex into separate parser.
                var    options     = RegexOptions.None;
                var    regex       = new Regex(@"</?\w+[^>]*>", options);
                string input       = data;
                string replacement = string.Empty;
                data = regex.Replace(input, replacement);
            }

            return(data);
        }
Пример #2
0
        /// <summary>Sends data from the output buffer to the client.</summary>
        /// <param name="bufferDirection">Direction to move in the buffer.</param>
        public void ProcessBuffer(BufferDirection bufferDirection)
        {
            if (OutputBuffer.HasMoreData)
            {
                string[] output = OutputBuffer.GetRows(bufferDirection, PagingRowLimit);

                bool   appendOverflow = OutputBuffer.HasMoreData;
                string data           = (AtNewLine ? null : AnsiSequences.NewLine) + BufferHandler.Format(
                    output,
                    appendOverflow,
                    OutputBuffer.CurrentLocation,
                    OutputBuffer.Length);

                Send(data, true);
            }
        }
Пример #3
0
        /// <summary>Sends data from the output buffer to the client.</summary>
        /// <param name="bufferDirection">Direction to move in the buffer.</param>
        public void ProcessBuffer(BufferDirection bufferDirection)
        {
            if (this.OutputBuffer.HasMoreData)
            {
                string[] output = this.OutputBuffer.GetRows(bufferDirection, this.PagingRowLimit);

                bool   appendOverflow = this.OutputBuffer.HasMoreData;
                string data           = BufferHandler.Format(
                    output,
                    false,
                    appendOverflow,
                    this.OutputBuffer.CurrentLocation,
                    this.OutputBuffer.Length);

                this.Send(data, false, true);
            }
        }