resize.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // EventResize is sent when the window size changes.
  19. type EventResize struct {
  20. t time.Time
  21. w int
  22. h int
  23. }
  24. // NewEventResize creates an EventResize with the new updated window size,
  25. // which is given in character cells.
  26. func NewEventResize(width, height int) *EventResize {
  27. return &EventResize{t: time.Now(), w: width, h: height}
  28. }
  29. // When returns the time when the Event was created.
  30. func (ev *EventResize) When() time.Time {
  31. return ev.t
  32. }
  33. // Size returns the new window size as width, height in character cells.
  34. func (ev *EventResize) Size() (int, int) {
  35. return ev.w, ev.h
  36. }