コード例 #1
0
ファイル: ScreenSnapshot.cs プロジェクト: Whitecaribou/KOS
 /// <summary>
 /// A factory that constructs an empty screen buffer of a correct size for the fromScreen
 /// </summary>
 /// <param name="fromScreen">The screen - only used to determine the needed width/height</param>
 /// <returns>An empty snapshot buffer</returns>
 public static ScreenSnapShot EmptyScreen(IScreenBuffer fromScreen)
 {
     ScreenSnapShot newThing = new ScreenSnapShot();
     newThing.TopRow = fromScreen.TopRow;
     newThing.CursorColumn = fromScreen.CursorColumnShow;
     newThing.CursorRow = fromScreen.CursorRowShow;
     newThing.RowCount = fromScreen.RowCount;
     newThing.Buffer = new List<IScreenBufferLine>();
     for (int i = 0; i < newThing.RowCount ; ++i)
         newThing.Buffer.Add(new ScreenBufferLine(fromScreen.ColumnCount));
     return newThing;
 }
コード例 #2
0
        /// <summary>
        /// A factory that constructs an empty screen buffer of a correct size for the fromScreen
        /// </summary>
        /// <param name="fromScreen">The screen - only used to determine the needed width/height</param>
        /// <returns>An empty snapshot buffer</returns>
        public static ScreenSnapShot EmptyScreen(IScreenBuffer fromScreen)
        {
            ScreenSnapShot newThing = new ScreenSnapShot();

            newThing.TopRow       = fromScreen.TopRow;
            newThing.CursorColumn = fromScreen.CursorColumnShow;
            newThing.CursorRow    = fromScreen.CursorRowShow;
            newThing.RowCount     = fromScreen.RowCount;
            newThing.Buffer       = new List <IScreenBufferLine>();
            for (int i = 0; i < newThing.RowCount; ++i)
            {
                newThing.Buffer.Add(new ScreenBufferLine(fromScreen.ColumnCount));
            }
            return(newThing);
        }
コード例 #3
0
ファイル: ScreenSnapshot.cs プロジェクト: Whitecaribou/KOS
        /// <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;
        }
コード例 #4
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);
        }