private void PerformPaint() { // form paint if (ActiveForm.IsInvalidated) { Terminal.HideCursor(); Buffer current_buffer = Terminal.CurrentBuffer; var form_event = new PaintEventArgs(current_buffer.ClipRectangle, current_buffer); ActiveForm.OnPaint(form_event); ActiveForm.IsInvalidated = false; var controls = ActiveForm.Controls.ZOrderList; var node = controls.First; while (node != null) { var control = node.Value; if (control.Visible) { var control_buffer = new Buffer(control.Size); var e = new PaintEventArgs(control_buffer.ClipRectangle, control_buffer); control.OnPaint(e); control.IsInvalidated = false; current_buffer.WriteBuffer(control_buffer, control.Location); } node = node.Next; } Terminal.FlushBuffer(); } if (ActiveForm.FocusedControl != null) { { var c = ActiveForm.FocusedControl; //move cursor to the focused control Terminal.SetCursorPosition(c.Location.X + c.CursorPosition.X, c.Location.Y + c.CursorPosition.Y); Terminal.ShowCursor(); } } else { Terminal.SetCursorPosition(0, 0); Terminal.HideCursor(); } }