Exemplo n.º 1
0
        /// <summary>
        /// Updates this text within it's terminal and returns a delta change size
        /// </summary>
        public int Update()
        {
            if (Disposed == 1)
            {
                return(0);
            }

            bool bUpdatedPos = false;

            if (0 != (Dirt & EDirtFlags.Position))
            {
                /*if (Owner.TryGetTarget(out VirtualScreen Screen))
                 * {
                 *  Position = new CursorPos(Screen.CursorLeft, Screen.CursorTop);
                 *  bUpdatedPos = true;
                 *  Dirt &= ~EDirtFlags.Position;
                 * }*/

                Position    = new CursorPos(Terminal.CursorLeft, Terminal.CursorTop);
                bUpdatedPos = true;
                Dirt       &= ~EDirtFlags.Position;
            }

            if (bUpdatedPos)
            {
                Terminal.Push_Cursor();
                Terminal.Set_Cursor(Position.X, Position.Y);
            }

            if (0 != (Dirt & EDirtFlags.Text) || bUpdatedPos)
            {
                /* Figure out which parts we need to reprint */
                var Commands = DiffEngine.Compile_Transformations(DisplayText, Buffer);
                foreach (TextChunk Command in Commands)
                {
                    /* Translate the commands position (which is relative the this object position) into actual screen buffer coordinates */
                    var X = Position.X + Command.Offset;
                    Terminal.Set_Cursor(X % Terminal.Width, Position.Y + (X / Terminal.Width));
                    Terminal.Output(Command.Text);
                }

                //ANSI.Write(Buffer.AsMemory());
                DisplayText = new string(Buffer.AsMemory().ToArray());
                Dirt       &= ~EDirtFlags.Text;
            }

            if (bUpdatedPos)
            {
                Terminal.Pop_Cursor();
            }

            return(0);
        }
Exemplo n.º 2
0
 public void Set_Position(CursorPos pos)
 {
     Position = pos;
     Dirt    |= EDirtFlags.Position;
     ChangeCallback?.Invoke(this);
 }