cmake/Source/CursesDialog/cmCursesMainForm.h

174 lines
4.8 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2020-02-01 23:06:01 +01:00
#include <cstddef>
#include <memory>
#include <string>
#include <vector>
2020-08-30 11:54:41 +02:00
#include <cm/optional>
2020-02-01 23:06:01 +01:00
#include "cmCursesCacheEntryComposite.h"
2016-07-09 11:21:54 +02:00
#include "cmCursesForm.h"
2016-10-30 18:24:19 +01:00
#include "cmCursesStandardIncludes.h"
2017-04-14 19:02:05 +02:00
#include "cmStateTypes.h"
2016-10-30 18:24:19 +01:00
class cmake;
2020-08-30 11:54:41 +02:00
class cmCursesLongMessageForm;
/** \class cmCursesMainForm
* \brief The main page of ccmake
*
* cmCursesMainForm is the main page of ccmake.
*/
class cmCursesMainForm : public cmCursesForm
{
public:
2019-11-11 23:01:05 +01:00
cmCursesMainForm(std::vector<std::string> args, int initwidth);
2018-01-26 17:06:56 +01:00
~cmCursesMainForm() override;
2013-03-16 19:13:01 +02:00
2019-11-11 23:01:05 +01:00
cmCursesMainForm(cmCursesMainForm const&) = delete;
cmCursesMainForm& operator=(cmCursesMainForm const&) = delete;
/**
* Set the widgets which represent the cache entries.
*/
void InitializeUI();
2013-03-16 19:13:01 +02:00
/**
* Handle user input.
*/
2018-01-26 17:06:56 +01:00
void HandleInput() override;
/**
* Display form. Use a window of size width x height, starting
* at top, left.
*/
2018-01-26 17:06:56 +01:00
void Render(int left, int top, int width, int height) override;
/**
* Returns true if an entry with the given key is in the
* list of current composites.
*/
2015-04-27 22:25:09 +02:00
bool LookForCacheEntry(const std::string& key);
2016-07-09 11:21:54 +02:00
enum
{
MIN_WIDTH = 65,
MIN_HEIGHT = 6,
IDEAL_WIDTH = 80,
MAX_WIDTH = 512
};
/**
* This method should normally be called only by the form. The only
* exception is during a resize. The optional argument specifies the
* string to be displayed in the status bar.
*/
2020-08-30 11:54:41 +02:00
void UpdateStatusBar() override { this->UpdateStatusBar(cm::nullopt); }
void UpdateStatusBar(cm::optional<std::string> message);
/**
* Display current commands and their keys on the toolbar. This
* method should normally called only by the form. The only
* exception is during a resize. If the optional argument process is
* specified and is either 1 (configure) or 2 (generate), then keys
* will be displayed accordingly.
*/
void PrintKeys(int process = 0);
/**
* During a CMake run, an error handle should add errors
* to be displayed afterwards.
*/
2019-11-11 23:01:05 +01:00
void AddError(const std::string& message, const char* title) override;
/**
* Used to do a configure. If argument is specified, it does only the check
* and not configure.
*/
2016-07-09 11:21:54 +02:00
int Configure(int noconfigure = 0);
/**
2013-03-16 19:13:01 +02:00
* Used to generate
*/
int Generate();
/**
* Used by main program
*/
2016-07-09 11:21:54 +02:00
int LoadCache(const char* dir);
2013-03-16 19:13:01 +02:00
/**
* Progress callback
*/
2019-11-11 23:01:05 +01:00
void UpdateProgress(const std::string& msg, float prog);
protected:
// Copy the cache values from the user interface to the actual
// cache.
void FillCacheManagerFromUI();
// Fix formatting of values to a consistent form.
2017-04-14 19:02:05 +02:00
void FixValue(cmStateEnums::CacheEntryType type, const std::string& in,
2016-07-09 11:21:54 +02:00
std::string& out) const;
// Re-post the existing fields. Used to toggle between
// normal and advanced modes. Render() should be called
// afterwards.
void RePost();
// Remove an entry from the interface and the cache.
void RemoveEntry(const char* value);
2010-11-13 01:00:53 +02:00
// Jump to the cache entry whose name matches the string.
void JumpToCacheEntry(const char* str);
2020-08-30 11:54:41 +02:00
// Clear and reset the output log and state
void ResetOutputs();
// Display the current progress and output
void DisplayOutputs(std::string const& newOutput);
// Copies of cache entries stored in the user interface
2020-02-01 23:06:01 +01:00
std::vector<cmCursesCacheEntryComposite> Entries;
2020-08-30 11:54:41 +02:00
// The form used to display logs during processing
std::unique_ptr<cmCursesLongMessageForm> LogForm;
// Output produced by the last pass
std::vector<std::string> Outputs;
// Did the last pass produced outputs of interest (errors, warnings, ...)
2022-05-25 20:56:39 +02:00
bool HasNonStatusOutputs = false;
2020-08-30 11:54:41 +02:00
// Last progress bar
std::string LastProgress;
2018-08-09 18:06:22 +02:00
// Command line arguments to be passed to cmake each time
// it is run
std::vector<std::string> Args;
// Message displayed when user presses 'h'
// It is: Welcome + info about current entry + common help
std::vector<std::string> HelpMessage;
// Common help
static const char* s_ConstHelpMessage;
// Fields displayed. Includes labels, new entry markers, entries
2020-02-01 23:06:01 +01:00
std::vector<FIELD*> Fields;
// Number of entries shown (depends on mode -normal or advanced-)
2022-05-25 20:56:39 +02:00
size_t NumberOfVisibleEntries = 0;
bool AdvancedMode = false;
// Did the iteration converge (no new entries) ?
2022-05-25 20:56:39 +02:00
bool OkToGenerate = false;
// Number of pages displayed
2022-05-25 20:56:39 +02:00
int NumberOfPages = 0;
bool IsEmpty = false;
std::unique_ptr<cmCursesCacheEntryComposite> EmptyCacheEntry;
int InitialWidth;
2020-02-01 23:06:01 +01:00
std::unique_ptr<cmake> CMakeInstance;
std::string SearchString;
std::string OldSearchString;
2022-05-25 20:56:39 +02:00
bool SearchMode = false;
};