interrupt.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2015 The TCell Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use file except in compliance with the License.
  5. // You may obtain a copy of the license at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package tcell
  15. import (
  16. "time"
  17. )
  18. // EventInterrupt is a generic wakeup event. Its can be used to
  19. // to request a redraw. It can carry an arbitrary payload, as well.
  20. type EventInterrupt struct {
  21. t time.Time
  22. v interface{}
  23. }
  24. // When returns the time when this event was created.
  25. func (ev *EventInterrupt) When() time.Time {
  26. return ev.t
  27. }
  28. // Data is used to obtain the opaque event payload.
  29. func (ev *EventInterrupt) Data() interface{} {
  30. return ev.v
  31. }
  32. // NewEventInterrupt creates an EventInterrupt with the given payload.
  33. func NewEventInterrupt(data interface{}) *EventInterrupt {
  34. return &EventInterrupt{t: time.Now(), v: data}
  35. }