Exemple #1
0
        protected void ResizeBuffer()
        {
            // Grow or shrink the width of the buffer lines to match the new
            // value.  Note that this does not (yet) account for preserving lines and wrapping them.
            for (int row = 0; row < buffer.Count; ++row)
            {
                var newRow = new ScreenBufferLine(ColumnCount);
                newRow.ArrayCopyFrom(buffer[row], 0, 0, Math.Min(buffer[row].Length, ColumnCount));
                buffer[row] = newRow;
            }

            // Add more buffer lines if needed to pad out the rest of the screen:
            while (buffer.Count - topRow < RowCount)
            {
                buffer.Add(new ScreenBufferLine(ColumnCount));
            }
        }
Exemple #2
0
        /// <summary>
        /// Make a copy of me for later diffing against.
        /// Almost a deep copy.
        /// </summary>
        /// <returns>The new copy</returns>
        public IScreenSnapShot DeepCopy()
        {
            ScreenSnapShot newCopy = new ScreenSnapShot
            {
                TopRow       = TopRow,
                CursorColumn = CursorColumn,
                CursorRow    = CursorRow,
                RowCount     = RowCount,
                Buffer       = new List <IScreenBufferLine>()
            };

            // This will probably reset the timestamps on the rows, but for our purposes that's actually fine - we call this
            // when we want to get a fully sync'ed copy:
            foreach (IScreenBufferLine line in Buffer)
            {
                ScreenBufferLine newLine = new ScreenBufferLine(line.Length);
                newLine.ArrayCopyFrom(line.ToArray(), 0, 0);
                newCopy.Buffer.Add(newLine);
            }
            return(newCopy);
        }
Exemple #3
0
        /// <summary>
        /// Make a copy of me for later diffing against.
        /// Almost a deep copy.
        /// </summary>
        /// <returns>The new copy</returns>
        public IScreenSnapShot DeepCopy()
        {
            ScreenSnapShot newCopy = new ScreenSnapShot
            {
                TopRow = TopRow,
                CursorColumn = CursorColumn,
                CursorRow = CursorRow,
                RowCount = RowCount,
                Buffer = new List<IScreenBufferLine>()
            };

            // This will probably reset the timestamps on the rows, but for our purposes that's actually fine - we call this
            // when we want to get a fully sync'ed copy:
            foreach (IScreenBufferLine line in Buffer)
            {
                ScreenBufferLine newLine = new ScreenBufferLine(line.Length);
                newLine.ArrayCopyFrom(line.ToArray(), 0, 0);
                newCopy.Buffer.Add(newLine);
            }
            return newCopy;
        }
Exemple #4
0
        protected void ResizeBuffer()
        {
            // Grow or shrink the width of the buffer lines to match the new
            // value.  Note that this does not (yet) account for preserving lines and wrapping them.
            for (int row = 0; row < buffer.Count; ++row)
            {
                var newRow = new ScreenBufferLine(ColumnCount);
                newRow.ArrayCopyFrom(buffer[row], 0, 0, Math.Min(buffer[row].Length, ColumnCount));
                buffer[row] = newRow;
            }

            // Add more buffer lines if needed to pad out the rest of the screen:
            while (buffer.Count - topRow < RowCount)
                buffer.Add(new ScreenBufferLine(ColumnCount));
        }