cmCursesMainForm.h 4.3 KB

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