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
6 #include "cmConfigure.h" // IWYU pragma: keep
13 #include <cm/optional>
15 #include "cmCursesCacheEntryComposite.h"
16 #include "cmCursesForm.h"
17 #include "cmCursesStandardIncludes.h"
18 #include "cmStateTypes.h"
21 class cmCursesLongMessageForm;
23 /** \class cmCursesMainForm
24 * \brief The main page of ccmake
26 * cmCursesMainForm is the main page of ccmake.
28 class cmCursesMainForm : public cmCursesForm
31 cmCursesMainForm(std::vector<std::string> args, int initwidth);
32 ~cmCursesMainForm() override;
34 cmCursesMainForm(cmCursesMainForm const&) = delete;
35 cmCursesMainForm& operator=(cmCursesMainForm const&) = delete;
38 * Set the widgets which represent the cache entries.
45 void HandleInput() override;
48 * Display form. Use a window of size width x height, starting
51 void Render(int left, int top, int width, int height) override;
54 * Returns true if an entry with the given key is in the
55 * list of current composites.
57 bool LookForCacheEntry(const std::string& key);
68 * This method should normally be called only by the form. The only
69 * exception is during a resize. The optional argument specifies the
70 * string to be displayed in the status bar.
72 void UpdateStatusBar() override { this->UpdateStatusBar(cm::nullopt); }
73 void UpdateStatusBar(cm::optional<std::string> message);
76 * Display current commands and their keys on the toolbar. This
77 * method should normally called only by the form. The only
78 * exception is during a resize. If the optional argument process is
79 * specified and is either 1 (configure) or 2 (generate), then keys
80 * will be displayed accordingly.
82 void PrintKeys(int process = 0);
85 * During a CMake run, an error handle should add errors
86 * to be displayed afterwards.
88 void AddError(const std::string& message, const char* title) override;
91 * Used to do a configure. If argument is specified, it does only the check
94 int Configure(int noconfigure = 0);
102 * Used by main program
104 int LoadCache(const char* dir);
109 void UpdateProgress(const std::string& msg, float prog);
112 // Copy the cache values from the user interface to the actual
114 void FillCacheManagerFromUI();
115 // Fix formatting of values to a consistent form.
116 void FixValue(cmStateEnums::CacheEntryType type, const std::string& in,
117 std::string& out) const;
118 // Re-post the existing fields. Used to toggle between
119 // normal and advanced modes. Render() should be called
122 // Remove an entry from the interface and the cache.
123 void RemoveEntry(const char* value);
125 // Jump to the cache entry whose name matches the string.
126 void JumpToCacheEntry(const char* str);
128 // Clear and reset the output log and state
131 // Display the current progress and output
132 void DisplayOutputs();
134 // Copies of cache entries stored in the user interface
135 std::vector<cmCursesCacheEntryComposite> Entries;
137 // The form used to display logs during processing
138 std::unique_ptr<cmCursesLongMessageForm> LogForm;
139 // Output produced by the last pass
140 std::vector<std::string> Outputs;
141 // Did the last pass produced outputs of interest (errors, warnings, ...)
142 bool HasNonStatusOutputs;
144 std::string LastProgress;
146 // Command line arguments to be passed to cmake each time
148 std::vector<std::string> Args;
149 // Message displayed when user presses 'h'
150 // It is: Welcome + info about current entry + common help
151 std::vector<std::string> HelpMessage;
154 static const char* s_ConstHelpMessage;
156 // Fields displayed. Includes labels, new entry markers, entries
157 std::vector<FIELD*> Fields;
158 // Number of entries shown (depends on mode -normal or advanced-)
159 size_t NumberOfVisibleEntries;
161 // Did the iteration converge (no new entries) ?
163 // Number of pages displayed
167 std::unique_ptr<cmake> CMakeInstance;
169 std::string SearchString;
170 std::string OldSearchString;
174 #endif // cmCursesMainForm_h