cmCursesWidget.cxx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmCursesWidget.h"
  4. cmCursesWidget::cmCursesWidget(int width, int height, int left, int top)
  5. {
  6. this->Field = new_field(height, width, top, left, 0, 0);
  7. set_field_userptr(this->Field, reinterpret_cast<char*>(this));
  8. field_opts_off(this->Field, O_AUTOSKIP);
  9. this->Page = 0;
  10. }
  11. cmCursesWidget::~cmCursesWidget()
  12. {
  13. if (this->Field) {
  14. free_field(this->Field);
  15. this->Field = nullptr;
  16. }
  17. }
  18. void cmCursesWidget::Move(int x, int y, bool isNewPage)
  19. {
  20. if (!this->Field) {
  21. return;
  22. }
  23. move_field(this->Field, y, x);
  24. if (isNewPage) {
  25. set_new_page(this->Field, true);
  26. } else {
  27. set_new_page(this->Field, false);
  28. }
  29. }
  30. void cmCursesWidget::SetValue(const std::string& value)
  31. {
  32. this->Value = value;
  33. set_field_buffer(this->Field, 0, const_cast<char*>(value.c_str()));
  34. }
  35. const char* cmCursesWidget::GetValue()
  36. {
  37. return this->Value.c_str();
  38. }