cmCursesMainForm.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmCursesMainForm_h
  4. #define cmCursesMainForm_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include "cmCursesForm.h"
  7. #include "cmCursesStandardIncludes.h"
  8. #include "cmStateTypes.h"
  9. #include <stddef.h>
  10. #include <string>
  11. #include <vector>
  12. class cmCursesCacheEntryComposite;
  13. class cmake;
  14. /** \class cmCursesMainForm
  15. * \brief The main page of ccmake
  16. *
  17. * cmCursesMainForm is the main page of ccmake.
  18. */
  19. class cmCursesMainForm : public cmCursesForm
  20. {
  21. CM_DISABLE_COPY(cmCursesMainForm)
  22. public:
  23. cmCursesMainForm(std::vector<std::string> const& args, int initwidth);
  24. ~cmCursesMainForm() override;
  25. /**
  26. * Set the widgets which represent the cache entries.
  27. */
  28. void InitializeUI();
  29. /**
  30. * Handle user input.
  31. */
  32. void HandleInput() override;
  33. /**
  34. * Display form. Use a window of size width x height, starting
  35. * at top, left.
  36. */
  37. void Render(int left, int top, int width, int height) override;
  38. /**
  39. * Returns true if an entry with the given key is in the
  40. * list of current composites.
  41. */
  42. bool LookForCacheEntry(const std::string& key);
  43. enum
  44. {
  45. MIN_WIDTH = 65,
  46. MIN_HEIGHT = 6,
  47. IDEAL_WIDTH = 80,
  48. MAX_WIDTH = 512
  49. };
  50. /**
  51. * This method should normally be called only by the form. The only
  52. * exception is during a resize. The optional argument specifies the
  53. * string to be displayed in the status bar.
  54. */
  55. void UpdateStatusBar() override { this->UpdateStatusBar(nullptr); }
  56. virtual void UpdateStatusBar(const char* message);
  57. /**
  58. * Display current commands and their keys on the toolbar. This
  59. * method should normally called only by the form. The only
  60. * exception is during a resize. If the optional argument process is
  61. * specified and is either 1 (configure) or 2 (generate), then keys
  62. * will be displayed accordingly.
  63. */
  64. void PrintKeys(int process = 0);
  65. /**
  66. * During a CMake run, an error handle should add errors
  67. * to be displayed afterwards.
  68. */
  69. void AddError(const char* message, const char* title) override;
  70. /**
  71. * Used to do a configure. If argument is specified, it does only the check
  72. * and not configure.
  73. */
  74. int Configure(int noconfigure = 0);
  75. /**
  76. * Used to generate
  77. */
  78. int Generate();
  79. /**
  80. * Used by main program
  81. */
  82. int LoadCache(const char* dir);
  83. /**
  84. * Progress callback
  85. */
  86. static void UpdateProgressOld(const char* msg, float prog, void*);
  87. static void UpdateProgress(const char* msg, float prog, void*);
  88. protected:
  89. // Copy the cache values from the user interface to the actual
  90. // cache.
  91. void FillCacheManagerFromUI();
  92. // Fix formatting of values to a consistent form.
  93. void FixValue(cmStateEnums::CacheEntryType type, const std::string& in,
  94. std::string& out) const;
  95. // Re-post the existing fields. Used to toggle between
  96. // normal and advanced modes. Render() should be called
  97. // afterwards.
  98. void RePost();
  99. // Remove an entry from the interface and the cache.
  100. void RemoveEntry(const char* value);
  101. // Jump to the cache entry whose name matches the string.
  102. void JumpToCacheEntry(const char* str);
  103. // Copies of cache entries stored in the user interface
  104. std::vector<cmCursesCacheEntryComposite*>* Entries;
  105. // Errors produced during last run of cmake
  106. std::vector<std::string> Errors;
  107. // Command line argumens to be passed to cmake each time
  108. // it is run
  109. std::vector<std::string> Args;
  110. // Message displayed when user presses 'h'
  111. // It is: Welcome + info about current entry + common help
  112. std::vector<std::string> HelpMessage;
  113. // Common help
  114. static const char* s_ConstHelpMessage;
  115. // Fields displayed. Includes labels, new entry markers, entries
  116. FIELD** Fields;
  117. // Where is source of current project
  118. std::string WhereSource;
  119. // Where is cmake executable
  120. std::string WhereCMake;
  121. // Number of entries shown (depends on mode -normal or advanced-)
  122. size_t NumberOfVisibleEntries;
  123. bool AdvancedMode;
  124. // Did the iteration converge (no new entries) ?
  125. bool OkToGenerate;
  126. // Number of pages displayed
  127. int NumberOfPages;
  128. int InitialWidth;
  129. cmake* CMakeInstance;
  130. std::string SearchString;
  131. std::string OldSearchString;
  132. bool SearchMode;
  133. };
  134. #endif // cmCursesMainForm_h