cmCursesWidget.cxx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #include <cmConfigure.h>
  5. cmCursesWidget::cmCursesWidget(int width, int height, int left, int top)
  6. {
  7. this->Field = new_field(height, width, top, left, 0, 0);
  8. set_field_userptr(this->Field, reinterpret_cast<char*>(this));
  9. field_opts_off(this->Field, O_AUTOSKIP);
  10. this->Page = 0;
  11. }
  12. cmCursesWidget::~cmCursesWidget()
  13. {
  14. if (this->Field) {
  15. free_field(this->Field);
  16. this->Field = CM_NULLPTR;
  17. }
  18. }
  19. void cmCursesWidget::Move(int x, int y, bool isNewPage)
  20. {
  21. if (!this->Field) {
  22. return;
  23. }
  24. move_field(this->Field, y, x);
  25. if (isNewPage) {
  26. set_new_page(this->Field, true);
  27. } else {
  28. set_new_page(this->Field, false);
  29. }
  30. }
  31. void cmCursesWidget::SetValue(const std::string& value)
  32. {
  33. this->Value = value;
  34. set_field_buffer(this->Field, 0, const_cast<char*>(value.c_str()));
  35. }
  36. const char* cmCursesWidget::GetValue()
  37. {
  38. return this->Value.c_str();
  39. }