2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2002-01-21 23:30:43 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2002-01-21 23:30:43 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2016-04-29 16:40:20 +03:00
|
|
|
#include "cmCursesMainForm.h"
|
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2001-11-05 02:05:21 +03:00
|
|
|
#include "cmCursesCacheEntryComposite.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCursesDummyWidget.h"
|
2016-09-01 22:55:09 +03:00
|
|
|
#include "cmCursesForm.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCursesLabelWidget.h"
|
2001-11-30 00:44:22 +03:00
|
|
|
#include "cmCursesLongMessageForm.h"
|
2016-09-01 22:55:09 +03:00
|
|
|
#include "cmCursesStandardIncludes.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCursesStringWidget.h"
|
2016-09-01 22:55:09 +03:00
|
|
|
#include "cmCursesWidget.h"
|
2015-04-06 11:52:45 +03:00
|
|
|
#include "cmState.h"
|
2016-09-01 22:55:09 +03:00
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmVersion.h"
|
|
|
|
#include "cmake.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2001-11-06 06:10:52 +03:00
|
|
|
inline int ctrl(int z)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return (z & 037);
|
2011-10-13 21:51:18 +04:00
|
|
|
}
|
2001-11-06 06:10:52 +03:00
|
|
|
|
2002-05-01 19:34:27 +04:00
|
|
|
cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
|
2016-05-16 17:34:04 +03:00
|
|
|
int initWidth)
|
|
|
|
: Args(args)
|
|
|
|
, InitialWidth(initWidth)
|
2001-11-05 02:05:21 +03:00
|
|
|
{
|
2006-03-16 18:44:55 +03:00
|
|
|
this->NumberOfPages = 0;
|
2016-06-27 23:44:16 +03:00
|
|
|
this->Fields = CM_NULLPTR;
|
|
|
|
this->Entries = CM_NULLPTR;
|
2006-03-16 18:44:55 +03:00
|
|
|
this->AdvancedMode = false;
|
|
|
|
this->NumberOfVisibleEntries = 0;
|
|
|
|
this->OkToGenerate = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->HelpMessage.push_back(
|
|
|
|
"Welcome to ccmake, curses based user interface for CMake.");
|
2006-03-16 18:44:55 +03:00
|
|
|
this->HelpMessage.push_back("");
|
|
|
|
this->HelpMessage.push_back(s_ConstHelpMessage);
|
|
|
|
this->CMakeInstance = new cmake;
|
2013-11-08 00:30:59 +04:00
|
|
|
this->CMakeInstance->SetCMakeEditCommand(
|
|
|
|
cmSystemTools::GetCMakeCursesCommand());
|
2002-09-06 21:00:12 +04:00
|
|
|
|
|
|
|
// create the arguments for the cmake object
|
2014-11-23 13:05:50 +03:00
|
|
|
std::string whereCMake = cmSystemTools::GetProgramPath(this->Args[0]);
|
2002-09-06 21:00:12 +04:00
|
|
|
whereCMake += "/cmake";
|
2006-03-16 18:44:55 +03:00
|
|
|
this->Args[0] = whereCMake;
|
|
|
|
this->CMakeInstance->SetArgs(this->Args);
|
|
|
|
this->SearchString = "";
|
|
|
|
this->OldSearchString = "";
|
|
|
|
this->SearchMode = false;
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cmCursesMainForm::~cmCursesMainForm()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Form) {
|
2006-03-16 18:44:55 +03:00
|
|
|
unpost_form(this->Form);
|
|
|
|
free_form(this->Form);
|
2016-06-27 23:44:16 +03:00
|
|
|
this->Form = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-16 18:44:55 +03:00
|
|
|
delete[] this->Fields;
|
2001-11-05 02:05:21 +03:00
|
|
|
|
|
|
|
// Clean-up composites
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Entries) {
|
2015-01-04 15:33:16 +03:00
|
|
|
cmDeleteAll(*this->Entries);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-16 18:44:55 +03:00
|
|
|
delete this->Entries;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CMakeInstance) {
|
2006-03-16 18:44:55 +03:00
|
|
|
delete this->CMakeInstance;
|
2016-06-27 23:44:16 +03:00
|
|
|
this->CMakeInstance = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
// See if a cache entry is in the list of entries in the ui.
|
2014-02-05 01:06:56 +04:00
|
|
|
bool cmCursesMainForm::LookForCacheEntry(const std::string& key)
|
2001-11-05 02:05:21 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Entries) {
|
2001-11-05 02:05:21 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
|
|
|
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
|
|
|
|
if (key == (*it)->Key) {
|
2001-11-05 02:05:21 +03:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2001-11-05 02:05:21 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
// Create new cmCursesCacheEntryComposite entries from the cache
|
2001-11-30 00:44:22 +03:00
|
|
|
void cmCursesMainForm::InitializeUI()
|
2001-11-05 02:05:21 +03:00
|
|
|
{
|
2001-12-13 21:28:41 +03:00
|
|
|
// Create a vector of cmCursesCacheEntryComposite's
|
|
|
|
// which contain labels, entries and new entry markers
|
2001-11-05 02:05:21 +03:00
|
|
|
std::vector<cmCursesCacheEntryComposite*>* newEntries =
|
|
|
|
new std::vector<cmCursesCacheEntryComposite*>;
|
2015-04-06 11:52:45 +03:00
|
|
|
std::vector<std::string> cacheKeys =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryKeys();
|
2015-04-06 11:52:45 +03:00
|
|
|
newEntries->reserve(cacheKeys.size());
|
2001-11-05 02:05:21 +03:00
|
|
|
|
|
|
|
// Count non-internal and non-static entries
|
2016-05-16 17:34:04 +03:00
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
|
|
|
|
it != cacheKeys.end(); ++it) {
|
|
|
|
cmState::CacheEntryType t =
|
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryType(*it);
|
|
|
|
if (t != cmState::INTERNAL && t != cmState::STATIC &&
|
|
|
|
t != cmState::UNINITIALIZED) {
|
2001-11-05 02:05:21 +03:00
|
|
|
++count;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2006-03-16 18:44:55 +03:00
|
|
|
int entrywidth = this->InitialWidth - 35;
|
2002-05-01 19:34:27 +04:00
|
|
|
|
2001-11-05 02:05:21 +03:00
|
|
|
cmCursesCacheEntryComposite* comp;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (count == 0) {
|
2001-11-05 02:05:21 +03:00
|
|
|
// If cache is empty, display a label saying so and a
|
|
|
|
// dummy entry widget (does not respond to input)
|
2002-05-01 19:34:27 +04:00
|
|
|
comp = new cmCursesCacheEntryComposite("EMPTY CACHE", 30, 30);
|
2006-03-16 18:44:55 +03:00
|
|
|
comp->Entry = new cmCursesDummyWidget(1, 1, 1, 1);
|
2001-11-05 02:05:21 +03:00
|
|
|
newEntries->push_back(comp);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2001-11-05 02:05:21 +03:00
|
|
|
// Create the composites.
|
|
|
|
|
|
|
|
// First add entries which are new
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
|
|
|
|
it != cacheKeys.end(); ++it) {
|
2015-04-06 13:01:35 +03:00
|
|
|
std::string key = *it;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::CacheEntryType t =
|
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryType(*it);
|
|
|
|
if (t == cmState::INTERNAL || t == cmState::STATIC ||
|
|
|
|
t == cmState::UNINITIALIZED) {
|
2002-10-17 18:51:23 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->LookForCacheEntry(key)) {
|
|
|
|
newEntries->push_back(new cmCursesCacheEntryComposite(
|
|
|
|
key, this->CMakeInstance, true, 30, entrywidth));
|
2006-03-16 18:44:55 +03:00
|
|
|
this->OkToGenerate = false;
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
|
|
|
// then add entries which are old
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
|
|
|
|
it != cacheKeys.end(); ++it) {
|
2015-04-06 13:01:35 +03:00
|
|
|
std::string key = *it;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::CacheEntryType t =
|
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryType(*it);
|
|
|
|
if (t == cmState::INTERNAL || t == cmState::STATIC ||
|
|
|
|
t == cmState::UNINITIALIZED) {
|
2002-10-17 18:51:23 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->LookForCacheEntry(key)) {
|
|
|
|
newEntries->push_back(new cmCursesCacheEntryComposite(
|
|
|
|
key, this->CMakeInstance, false, 30, entrywidth));
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
// Clean old entries
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Entries) {
|
2015-01-04 15:33:16 +03:00
|
|
|
cmDeleteAll(*this->Entries);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-16 18:44:55 +03:00
|
|
|
delete this->Entries;
|
|
|
|
this->Entries = newEntries;
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
// Compute fields from composites
|
2001-11-30 00:44:22 +03:00
|
|
|
this->RePost();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmCursesMainForm::RePost()
|
|
|
|
{
|
2001-11-05 02:05:21 +03:00
|
|
|
// Create the fields to be passed to the form.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Form) {
|
2006-03-16 18:44:55 +03:00
|
|
|
unpost_form(this->Form);
|
|
|
|
free_form(this->Form);
|
2016-06-27 23:44:16 +03:00
|
|
|
this->Form = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-16 18:44:55 +03:00
|
|
|
delete[] this->Fields;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->AdvancedMode) {
|
2006-03-16 18:44:55 +03:00
|
|
|
this->NumberOfVisibleEntries = this->Entries->size();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2001-12-13 21:28:41 +03:00
|
|
|
// If normal mode, count only non-advanced entries
|
2006-03-16 18:44:55 +03:00
|
|
|
this->NumberOfVisibleEntries = 0;
|
2001-11-30 00:44:22 +03:00
|
|
|
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
|
2015-04-06 13:01:35 +03:00
|
|
|
const char* existingValue =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
|
2015-04-06 13:01:35 +03:00
|
|
|
bool advanced =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
|
|
|
|
(*it)->GetValue(), "ADVANCED");
|
|
|
|
if (!existingValue || (!this->AdvancedMode && advanced)) {
|
2002-10-17 18:51:23 +04:00
|
|
|
continue;
|
2001-11-30 00:44:22 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->NumberOfVisibleEntries++;
|
2001-11-30 00:44:22 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-08 00:32:09 +03:00
|
|
|
// there is always one even if it is the dummy one
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->NumberOfVisibleEntries == 0) {
|
2008-03-08 00:32:09 +03:00
|
|
|
this->NumberOfVisibleEntries = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-12-13 21:28:41 +03:00
|
|
|
// Assign the fields: 3 for each entry: label, new entry marker
|
|
|
|
// ('*' or ' ') and entry widget
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Fields = new FIELD*[3 * this->NumberOfVisibleEntries + 1];
|
2010-06-29 19:09:36 +04:00
|
|
|
size_t cc;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cc = 0; cc < 3 * this->NumberOfVisibleEntries + 1; cc++) {
|
2016-06-27 23:44:16 +03:00
|
|
|
this->Fields[cc] = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
// Assign fields
|
2016-05-16 17:34:04 +03:00
|
|
|
int j = 0;
|
2001-11-30 00:44:22 +03:00
|
|
|
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
|
2015-04-06 13:01:35 +03:00
|
|
|
const char* existingValue =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
|
2015-04-06 13:01:35 +03:00
|
|
|
bool advanced =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
|
|
|
|
(*it)->GetValue(), "ADVANCED");
|
|
|
|
if (!existingValue || (!this->AdvancedMode && advanced)) {
|
2001-11-30 00:44:22 +03:00
|
|
|
continue;
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Fields[3 * j] = (*it)->Label->Field;
|
|
|
|
this->Fields[3 * j + 1] = (*it)->IsNewLabel->Field;
|
|
|
|
this->Fields[3 * j + 2] = (*it)->Entry->Field;
|
|
|
|
j++;
|
|
|
|
}
|
2008-03-08 00:32:09 +03:00
|
|
|
// if no cache entries there should still be one dummy field
|
2016-05-16 17:34:04 +03:00
|
|
|
if (j == 0) {
|
2008-03-08 00:32:09 +03:00
|
|
|
it = this->Entries->begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Fields[0] = (*it)->Label->Field;
|
|
|
|
this->Fields[1] = (*it)->IsNewLabel->Field;
|
|
|
|
this->Fields[2] = (*it)->Entry->Field;
|
2008-03-08 00:32:09 +03:00
|
|
|
this->NumberOfVisibleEntries = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
// Has to be null terminated.
|
2016-06-27 23:44:16 +03:00
|
|
|
this->Fields[3 * this->NumberOfVisibleEntries] = CM_NULLPTR;
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmCursesMainForm::Render(int left, int top, int width, int height)
|
|
|
|
{
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Form) {
|
2006-03-16 18:44:55 +03:00
|
|
|
FIELD* currentField = current_field(this->Form);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCursesWidget* cw =
|
|
|
|
reinterpret_cast<cmCursesWidget*>(field_userptr(currentField));
|
2001-12-13 21:28:41 +03:00
|
|
|
// If in edit mode, get out of it
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cw->GetType() == cmState::STRING || cw->GetType() == cmState::PATH ||
|
|
|
|
cw->GetType() == cmState::FILEPATH) {
|
2001-11-05 02:05:21 +03:00
|
|
|
cmCursesStringWidget* sw = static_cast<cmCursesStringWidget*>(cw);
|
|
|
|
sw->SetInEdit(false);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-12-13 21:28:41 +03:00
|
|
|
// Delete the previous form
|
2006-03-16 18:44:55 +03:00
|
|
|
unpost_form(this->Form);
|
|
|
|
free_form(this->Form);
|
2016-06-27 23:44:16 +03:00
|
|
|
this->Form = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-12-13 21:28:41 +03:00
|
|
|
|
|
|
|
// Wrong window size
|
2016-05-16 17:34:04 +03:00
|
|
|
if (width < cmCursesMainForm::MIN_WIDTH || width < this->InitialWidth ||
|
|
|
|
height < cmCursesMainForm::MIN_HEIGHT) {
|
2001-11-05 02:05:21 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
// Leave room for toolbar
|
|
|
|
height -= 7;
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->AdvancedMode) {
|
2006-03-16 18:44:55 +03:00
|
|
|
this->NumberOfVisibleEntries = this->Entries->size();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2001-12-13 21:28:41 +03:00
|
|
|
// If normal, display only non-advanced entries
|
2006-03-16 18:44:55 +03:00
|
|
|
this->NumberOfVisibleEntries = 0;
|
2001-11-30 00:44:22 +03:00
|
|
|
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
|
2015-04-06 13:01:35 +03:00
|
|
|
const char* existingValue =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
|
2015-04-06 13:01:35 +03:00
|
|
|
bool advanced =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
|
|
|
|
(*it)->GetValue(), "ADVANCED");
|
|
|
|
if (!existingValue || (!this->AdvancedMode && advanced)) {
|
2002-10-17 18:51:23 +04:00
|
|
|
continue;
|
2001-11-30 00:44:22 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->NumberOfVisibleEntries++;
|
2001-11-30 00:44:22 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
// Re-adjust the fields according to their place
|
2006-03-16 18:44:55 +03:00
|
|
|
this->NumberOfPages = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (height > 0) {
|
2011-01-19 19:11:19 +03:00
|
|
|
bool isNewPage;
|
2016-05-16 17:34:04 +03:00
|
|
|
int i = 0;
|
2011-01-19 19:11:19 +03:00
|
|
|
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
|
2015-04-06 13:01:35 +03:00
|
|
|
const char* existingValue =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
|
2015-04-06 13:01:35 +03:00
|
|
|
bool advanced =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
|
|
|
|
(*it)->GetValue(), "ADVANCED");
|
|
|
|
if (!existingValue || (!this->AdvancedMode && advanced)) {
|
2011-01-19 19:11:19 +03:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-01-19 19:11:19 +03:00
|
|
|
int row = (i % height) + 1;
|
|
|
|
int page = (i / height) + 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
isNewPage = (page > 1) && (row == 1);
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (isNewPage) {
|
2011-01-19 19:11:19 +03:00
|
|
|
this->NumberOfPages++;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
(*it)->Label->Move(left, top + row - 1, isNewPage);
|
|
|
|
(*it)->IsNewLabel->Move(left + 32, top + row - 1, false);
|
|
|
|
(*it)->Entry->Move(left + 33, top + row - 1, false);
|
2011-01-19 19:11:19 +03:00
|
|
|
(*it)->Entry->SetPage(this->NumberOfPages);
|
|
|
|
i++;
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
// Post the form
|
2006-03-16 18:44:55 +03:00
|
|
|
this->Form = new_form(this->Fields);
|
|
|
|
post_form(this->Form);
|
2001-12-13 21:28:41 +03:00
|
|
|
// Update toolbar
|
2001-11-06 06:10:52 +03:00
|
|
|
this->UpdateStatusBar();
|
2002-01-14 22:49:05 +03:00
|
|
|
this->PrintKeys();
|
|
|
|
|
2011-10-13 21:51:18 +04:00
|
|
|
touchwin(stdscr);
|
2001-11-05 02:05:21 +03:00
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
2002-11-19 21:09:16 +03:00
|
|
|
void cmCursesMainForm::PrintKeys(int process /* = 0 */)
|
2001-11-05 02:05:21 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
int x, y;
|
2001-11-30 00:44:22 +03:00
|
|
|
getmaxyx(stdscr, y, x);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth ||
|
|
|
|
y < cmCursesMainForm::MIN_HEIGHT) {
|
2001-11-06 06:10:52 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-12-13 21:28:41 +03:00
|
|
|
|
|
|
|
// Give the current widget (if it exists), a chance to print keys
|
2016-06-27 23:44:16 +03:00
|
|
|
cmCursesWidget* cw = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Form) {
|
2006-03-16 18:44:55 +03:00
|
|
|
FIELD* currentField = current_field(this->Form);
|
2001-12-13 21:28:41 +03:00
|
|
|
cw = reinterpret_cast<cmCursesWidget*>(field_userptr(currentField));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-12-13 21:28:41 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cw) {
|
2002-09-06 21:00:12 +04:00
|
|
|
cw->PrintKeys();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// {
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
char firstLine[512] = "";
|
|
|
|
char secondLine[512] = "";
|
|
|
|
char thirdLine[512] = "";
|
|
|
|
if (process) {
|
2012-02-05 18:09:37 +04:00
|
|
|
const char* clearLine =
|
2012-02-05 19:56:47 +04:00
|
|
|
" ";
|
2012-02-05 18:09:37 +04:00
|
|
|
strcpy(firstLine, clearLine);
|
|
|
|
strcpy(secondLine, clearLine);
|
|
|
|
strcpy(thirdLine, clearLine);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
if (this->OkToGenerate) {
|
2011-10-13 21:51:18 +04:00
|
|
|
sprintf(firstLine,
|
2011-01-07 16:48:35 +03:00
|
|
|
"Press [c] to configure Press [g] to generate and exit");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
sprintf(firstLine,
|
|
|
|
"Press [c] to configure ");
|
|
|
|
}
|
2011-01-07 16:57:46 +03:00
|
|
|
{
|
|
|
|
const char* toggleKeyInstruction =
|
|
|
|
"Press [t] to toggle advanced mode (Currently %s)";
|
2016-05-16 17:34:04 +03:00
|
|
|
sprintf(thirdLine, toggleKeyInstruction,
|
2011-01-07 16:57:46 +03:00
|
|
|
this->AdvancedMode ? "On" : "Off");
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
sprintf(secondLine, "Press [h] for help "
|
|
|
|
"Press [q] to quit without generating");
|
|
|
|
}
|
2001-12-13 21:28:41 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
curses_move(y - 4, 0);
|
2015-09-12 17:35:36 +03:00
|
|
|
char fmt_s[] = "%s";
|
2016-07-21 22:29:18 +03:00
|
|
|
char fmt[512] = "Press [enter] to edit option Press [d] to delete an entry";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (process) {
|
2002-11-21 18:03:36 +03:00
|
|
|
strcpy(fmt, " ");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-12 17:35:36 +03:00
|
|
|
printw(fmt_s, fmt);
|
2016-05-16 17:34:04 +03:00
|
|
|
curses_move(y - 3, 0);
|
2015-09-12 17:35:36 +03:00
|
|
|
printw(fmt_s, firstLine);
|
2016-05-16 17:34:04 +03:00
|
|
|
curses_move(y - 2, 0);
|
2015-09-12 17:35:36 +03:00
|
|
|
printw(fmt_s, secondLine);
|
2016-05-16 17:34:04 +03:00
|
|
|
curses_move(y - 1, 0);
|
2015-09-12 17:35:36 +03:00
|
|
|
printw(fmt_s, thirdLine);
|
2001-12-13 21:28:41 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cw) {
|
2006-03-16 18:44:55 +03:00
|
|
|
sprintf(firstLine, "Page %d of %d", cw->GetPage(), this->NumberOfPages);
|
2016-05-16 17:34:04 +03:00
|
|
|
curses_move(0, 65 - static_cast<unsigned int>(strlen(firstLine)) - 1);
|
2015-09-12 17:35:36 +03:00
|
|
|
printw(fmt_s, firstLine);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
// }
|
2001-11-06 06:10:52 +03:00
|
|
|
|
2006-03-16 18:44:55 +03:00
|
|
|
pos_form_cursor(this->Form);
|
2001-11-06 06:10:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Print the key of the current entry and the CMake version
|
|
|
|
// on the status bar. Designed for a width of 80 chars.
|
2002-11-19 21:09:16 +03:00
|
|
|
void cmCursesMainForm::UpdateStatusBar(const char* message)
|
2001-11-06 06:10:52 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
int x, y;
|
2001-11-30 00:44:22 +03:00
|
|
|
getmaxyx(stdscr, y, x);
|
2001-12-13 21:28:41 +03:00
|
|
|
// If window size is too small, display error and return
|
2016-05-16 17:34:04 +03:00
|
|
|
if (x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth ||
|
|
|
|
y < cmCursesMainForm::MIN_HEIGHT) {
|
2001-11-30 19:34:13 +03:00
|
|
|
curses_clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
curses_move(0, 0);
|
2002-06-11 17:14:19 +04:00
|
|
|
char fmt[] = "Window is too small. A size of at least %dx%d is required.";
|
2016-05-16 17:34:04 +03:00
|
|
|
printw(fmt, (cmCursesMainForm::MIN_WIDTH < this->InitialWidth
|
|
|
|
? this->InitialWidth
|
|
|
|
: cmCursesMainForm::MIN_WIDTH),
|
2002-10-17 18:51:23 +04:00
|
|
|
cmCursesMainForm::MIN_HEIGHT);
|
2011-10-13 21:51:18 +04:00
|
|
|
touchwin(stdscr);
|
|
|
|
wrefresh(stdscr);
|
2001-11-06 06:10:52 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-06 06:10:52 +03:00
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
// Get the key of the current entry
|
2006-03-16 18:44:55 +03:00
|
|
|
FIELD* cur = current_field(this->Form);
|
2002-10-17 18:51:23 +04:00
|
|
|
int findex = field_index(cur);
|
2016-06-27 23:44:16 +03:00
|
|
|
cmCursesWidget* lbl = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (findex >= 0) {
|
|
|
|
lbl = reinterpret_cast<cmCursesWidget*>(
|
|
|
|
field_userptr(this->Fields[findex - 2]));
|
|
|
|
}
|
2002-09-11 23:04:50 +04:00
|
|
|
char help[128] = "";
|
|
|
|
const char* curField = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (lbl) {
|
2002-09-11 23:04:50 +04:00
|
|
|
curField = lbl->GetValue();
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2002-09-11 23:04:50 +04:00
|
|
|
// Get the help string of the current entry
|
|
|
|
// and add it to the help string
|
2015-04-06 13:01:35 +03:00
|
|
|
const char* existingValue =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryValue(curField);
|
|
|
|
if (existingValue) {
|
|
|
|
const char* hs = this->CMakeInstance->GetState()->GetCacheEntryProperty(
|
|
|
|
curField, "HELPSTRING");
|
|
|
|
if (hs) {
|
2002-09-11 23:04:50 +04:00
|
|
|
strncpy(help, hs, 127);
|
|
|
|
help[127] = '\0';
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2002-09-11 23:04:50 +04:00
|
|
|
help[0] = 0;
|
2002-09-11 22:05:45 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
sprintf(help, " ");
|
2001-11-30 00:44:22 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
// Join the key, help string and pad with spaces
|
|
|
|
// (or truncate) as necessary
|
2001-11-06 06:10:52 +03:00
|
|
|
char bar[cmCursesMainForm::MAX_WIDTH];
|
2010-06-29 17:52:12 +04:00
|
|
|
size_t i, curFieldLen = strlen(curField);
|
|
|
|
size_t helpLen = strlen(help);
|
2001-11-30 00:44:22 +03:00
|
|
|
|
2010-06-29 19:09:36 +04:00
|
|
|
size_t width;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (x < cmCursesMainForm::MAX_WIDTH) {
|
2001-11-30 00:44:22 +03:00
|
|
|
width = x;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2001-11-30 00:44:22 +03:00
|
|
|
width = cmCursesMainForm::MAX_WIDTH;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-06 06:10:52 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (message) {
|
2002-11-19 21:09:16 +03:00
|
|
|
curField = message;
|
|
|
|
curFieldLen = strlen(message);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (curFieldLen < width) {
|
2002-11-19 21:09:16 +03:00
|
|
|
strcpy(bar, curField);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (i = curFieldLen; i < width; ++i) {
|
2011-10-13 21:51:18 +04:00
|
|
|
bar[i] = ' ';
|
2002-11-19 21:09:16 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2002-11-19 21:09:16 +03:00
|
|
|
strncpy(bar, curField, width);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (curFieldLen >= width) {
|
2002-11-19 21:09:16 +03:00
|
|
|
strncpy(bar, curField, width);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2002-11-19 21:09:16 +03:00
|
|
|
strcpy(bar, curField);
|
|
|
|
bar[curFieldLen] = ':';
|
2016-05-16 17:34:04 +03:00
|
|
|
bar[curFieldLen + 1] = ' ';
|
|
|
|
if (curFieldLen + helpLen + 2 >= width) {
|
|
|
|
strncpy(bar + curFieldLen + 2, help, width - curFieldLen - 2);
|
|
|
|
} else {
|
|
|
|
strcpy(bar + curFieldLen + 2, help);
|
|
|
|
for (i = curFieldLen + helpLen + 2; i < width; ++i) {
|
2011-10-13 21:51:18 +04:00
|
|
|
bar[i] = ' ';
|
2002-09-11 23:04:50 +04:00
|
|
|
}
|
2001-11-06 06:10:52 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-06 06:10:52 +03:00
|
|
|
|
2001-11-30 00:44:22 +03:00
|
|
|
bar[width] = '\0';
|
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
// Display CMake version info on the next line
|
2001-12-05 00:19:33 +03:00
|
|
|
// We want to display this on the right
|
2001-11-30 00:44:22 +03:00
|
|
|
char version[cmCursesMainForm::MAX_WIDTH];
|
|
|
|
char vertmp[128];
|
2016-05-16 17:34:04 +03:00
|
|
|
sprintf(vertmp, "CMake Version %s", cmVersion::GetCMakeVersion());
|
|
|
|
size_t sideSpace = (width - strlen(vertmp));
|
|
|
|
for (i = 0; i < sideSpace; i++) {
|
|
|
|
version[i] = ' ';
|
|
|
|
}
|
|
|
|
sprintf(version + sideSpace, "%s", vertmp);
|
2001-11-30 00:44:22 +03:00
|
|
|
version[width] = '\0';
|
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
// Now print both lines
|
2015-09-12 17:35:36 +03:00
|
|
|
char fmt_s[] = "%s";
|
2016-05-16 17:34:04 +03:00
|
|
|
curses_move(y - 5, 0);
|
2001-11-06 06:10:52 +03:00
|
|
|
attron(A_STANDOUT);
|
2015-09-12 17:35:36 +03:00
|
|
|
printw(fmt_s, bar);
|
2011-10-13 21:51:18 +04:00
|
|
|
attroff(A_STANDOUT);
|
2016-05-16 17:34:04 +03:00
|
|
|
curses_move(y - 4, 0);
|
2015-09-12 17:35:36 +03:00
|
|
|
printw(fmt_s, version);
|
2006-03-16 18:44:55 +03:00
|
|
|
pos_form_cursor(this->Form);
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmCursesMainForm::UpdateProgress(const char* msg, float prog, void* vp)
|
2002-11-19 21:09:16 +03:00
|
|
|
{
|
|
|
|
cmCursesMainForm* cm = static_cast<cmCursesMainForm*>(vp);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cm) {
|
2002-11-19 21:09:16 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-11-19 21:09:16 +03:00
|
|
|
char tmp[1024];
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmsg = tmp;
|
|
|
|
if (prog >= 0) {
|
|
|
|
sprintf(tmp, "%s %i%%", msg, (int)(100 * prog));
|
|
|
|
} else {
|
2002-11-19 21:09:16 +03:00
|
|
|
cmsg = msg;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-11-19 21:09:16 +03:00
|
|
|
cm->UpdateStatusBar(cmsg);
|
|
|
|
cm->PrintKeys(1);
|
2016-05-16 17:34:04 +03:00
|
|
|
curses_move(1, 1);
|
2011-10-13 21:51:18 +04:00
|
|
|
touchwin(stdscr);
|
2002-11-19 21:09:16 +03:00
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
2003-05-29 19:14:48 +04:00
|
|
|
int cmCursesMainForm::Configure(int noconfigure)
|
2001-11-05 02:05:21 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
int xi, yi;
|
2002-10-17 18:51:23 +04:00
|
|
|
getmaxyx(stdscr, yi, xi);
|
2001-11-30 00:44:22 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
curses_move(1, 1);
|
2002-11-19 21:09:16 +03:00
|
|
|
this->UpdateStatusBar("Configuring, please wait...");
|
|
|
|
this->PrintKeys(1);
|
2011-10-13 21:51:18 +04:00
|
|
|
touchwin(stdscr);
|
2001-11-30 00:44:22 +03:00
|
|
|
refresh();
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress,
|
|
|
|
this);
|
2002-08-29 00:35:54 +04:00
|
|
|
|
2001-11-05 02:05:21 +03:00
|
|
|
// always save the current gui values to disk
|
|
|
|
this->FillCacheManagerFromUI();
|
2015-04-05 01:07:04 +03:00
|
|
|
this->CMakeInstance->SaveCache(
|
2006-03-16 18:44:55 +03:00
|
|
|
this->CMakeInstance->GetHomeOutputDirectory());
|
2016-06-27 23:44:16 +03:00
|
|
|
this->LoadCache(CM_NULLPTR);
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2001-11-30 00:44:22 +03:00
|
|
|
// Get rid of previous errors
|
2006-03-16 18:44:55 +03:00
|
|
|
this->Errors = std::vector<std::string>();
|
2001-11-30 00:44:22 +03:00
|
|
|
|
2001-11-05 02:05:21 +03:00
|
|
|
// run the generate process
|
2006-03-16 18:44:55 +03:00
|
|
|
this->OkToGenerate = true;
|
2003-05-29 19:14:48 +04:00
|
|
|
int retVal;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (noconfigure) {
|
2006-03-16 18:44:55 +03:00
|
|
|
retVal = this->CMakeInstance->DoPreConfigureChecks();
|
|
|
|
this->OkToGenerate = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (retVal > 0) {
|
2003-05-29 19:14:48 +04:00
|
|
|
retVal = 0;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-03-16 18:44:55 +03:00
|
|
|
retVal = this->CMakeInstance->Configure();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
this->CMakeInstance->SetProgressCallback(CM_NULLPTR, CM_NULLPTR);
|
2002-01-14 22:49:05 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
keypad(stdscr, TRUE); /* Use key symbols as
|
|
|
|
KEY_DOWN*/
|
2002-01-14 22:49:05 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (retVal != 0 || !this->Errors.empty()) {
|
2002-01-08 00:30:27 +03:00
|
|
|
// see if there was an error
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2006-03-16 18:44:55 +03:00
|
|
|
this->OkToGenerate = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
int xx, yy;
|
2002-10-17 18:51:23 +04:00
|
|
|
getmaxyx(stdscr, yy, xx);
|
2003-03-17 19:21:05 +03:00
|
|
|
cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Errors, cmSystemTools::GetErrorOccuredFlag()
|
|
|
|
? "Errors occurred during the last pass."
|
|
|
|
: "CMake produced the following output.");
|
2008-10-09 20:49:49 +04:00
|
|
|
// reset error condition
|
|
|
|
cmSystemTools::ResetErrorOccuredFlag();
|
2001-11-30 00:44:22 +03:00
|
|
|
CurrentForm = msgs;
|
2016-05-16 17:34:04 +03:00
|
|
|
msgs->Render(1, 1, xx, yy);
|
2001-11-30 00:44:22 +03:00
|
|
|
msgs->HandleInput();
|
2002-04-24 00:16:48 +04:00
|
|
|
// If they typed the wrong source directory, we report
|
|
|
|
// an error and exit
|
2016-05-16 17:34:04 +03:00
|
|
|
if (retVal == -2) {
|
2002-04-24 00:16:48 +04:00
|
|
|
return retVal;
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
CurrentForm = this;
|
|
|
|
this->Render(1, 1, xx, yy);
|
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2001-11-30 00:44:22 +03:00
|
|
|
this->InitializeUI();
|
2002-10-17 18:51:23 +04:00
|
|
|
this->Render(1, 1, xi, yi);
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2002-04-24 00:16:48 +04:00
|
|
|
return 0;
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
|
2002-09-06 21:00:12 +04:00
|
|
|
int cmCursesMainForm::Generate()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
int xi, yi;
|
2002-10-17 18:51:23 +04:00
|
|
|
getmaxyx(stdscr, yi, xi);
|
2002-09-06 21:00:12 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
curses_move(1, 1);
|
2002-11-19 21:09:16 +03:00
|
|
|
this->UpdateStatusBar("Generating, please wait...");
|
|
|
|
this->PrintKeys(1);
|
2002-09-06 21:00:12 +04:00
|
|
|
touchwin(stdscr);
|
|
|
|
refresh();
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress,
|
|
|
|
this);
|
2002-09-06 21:00:12 +04:00
|
|
|
|
|
|
|
// Get rid of previous errors
|
2006-03-16 18:44:55 +03:00
|
|
|
this->Errors = std::vector<std::string>();
|
2002-09-06 21:00:12 +04:00
|
|
|
|
|
|
|
// run the generate process
|
2006-03-16 18:44:55 +03:00
|
|
|
int retVal = this->CMakeInstance->Generate();
|
2002-09-06 21:00:12 +04:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
this->CMakeInstance->SetProgressCallback(CM_NULLPTR, CM_NULLPTR);
|
2016-05-16 17:34:04 +03:00
|
|
|
keypad(stdscr, TRUE); /* Use key symbols as
|
|
|
|
KEY_DOWN*/
|
2002-09-06 21:00:12 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (retVal != 0 || !this->Errors.empty()) {
|
2002-09-06 21:00:12 +04:00
|
|
|
// see if there was an error
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2006-03-16 18:44:55 +03:00
|
|
|
this->OkToGenerate = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-06 21:00:12 +04:00
|
|
|
// reset error condition
|
|
|
|
cmSystemTools::ResetErrorOccuredFlag();
|
2016-05-16 17:34:04 +03:00
|
|
|
int xx, yy;
|
2002-10-17 18:51:23 +04:00
|
|
|
getmaxyx(stdscr, yy, xx);
|
2006-03-16 19:28:13 +03:00
|
|
|
const char* title = "Messages during last pass.";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2006-03-16 19:28:13 +03:00
|
|
|
title = "Errors occurred during the last pass.";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
cmCursesLongMessageForm* msgs =
|
|
|
|
new cmCursesLongMessageForm(this->Errors, title);
|
2002-09-06 21:00:12 +04:00
|
|
|
CurrentForm = msgs;
|
2016-05-16 17:34:04 +03:00
|
|
|
msgs->Render(1, 1, xx, yy);
|
2002-09-06 21:00:12 +04:00
|
|
|
msgs->HandleInput();
|
|
|
|
// If they typed the wrong source directory, we report
|
|
|
|
// an error and exit
|
2016-05-16 17:34:04 +03:00
|
|
|
if (retVal == -2) {
|
2002-09-06 21:00:12 +04:00
|
|
|
return retVal;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
CurrentForm = this;
|
|
|
|
this->Render(1, 1, xx, yy);
|
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2002-09-06 21:00:12 +04:00
|
|
|
this->InitializeUI();
|
2002-10-17 18:51:23 +04:00
|
|
|
this->Render(1, 1, xi, yi);
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2002-09-06 21:00:12 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-08-17 02:49:57 +03:00
|
|
|
void cmCursesMainForm::AddError(const char* message, const char* /*unused*/)
|
2001-11-30 00:44:22 +03:00
|
|
|
{
|
2006-03-16 18:44:55 +03:00
|
|
|
this->Errors.push_back(message);
|
2001-11-30 00:44:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmCursesMainForm::RemoveEntry(const char* value)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!value) {
|
2001-11-30 00:44:22 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
|
|
|
|
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
|
2001-11-30 00:44:22 +03:00
|
|
|
const char* val = (*it)->GetValue();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (val && !strcmp(value, val)) {
|
2011-01-14 01:58:23 +03:00
|
|
|
this->CMakeInstance->UnwatchUnusedCli(value);
|
2006-03-16 18:44:55 +03:00
|
|
|
this->Entries->erase(it);
|
2001-11-30 00:44:22 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
}
|
|
|
|
|
2001-11-05 02:05:21 +03:00
|
|
|
// copy from the list box to the cache manager
|
|
|
|
void cmCursesMainForm::FillCacheManagerFromUI()
|
2011-10-13 21:51:18 +04:00
|
|
|
{
|
2010-06-29 17:52:12 +04:00
|
|
|
size_t size = this->Entries->size();
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t i = 0; i < size; i++) {
|
2015-04-06 13:01:35 +03:00
|
|
|
std::string cacheKey = (*this->Entries)[i]->Key;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* existingValue =
|
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryValue(cacheKey);
|
|
|
|
if (existingValue) {
|
2015-04-06 13:01:35 +03:00
|
|
|
std::string oldValue = existingValue;
|
2006-03-16 18:44:55 +03:00
|
|
|
std::string newValue = (*this->Entries)[i]->Entry->GetValue();
|
2004-06-23 18:13:02 +04:00
|
|
|
std::string fixedOldValue;
|
|
|
|
std::string fixedNewValue;
|
2015-04-07 23:45:54 +03:00
|
|
|
cmState::CacheEntryType t =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryType(cacheKey);
|
2015-04-06 13:01:35 +03:00
|
|
|
this->FixValue(t, oldValue, fixedOldValue);
|
|
|
|
this->FixValue(t, newValue, fixedNewValue);
|
2004-06-23 18:13:02 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!(fixedOldValue == fixedNewValue)) {
|
2004-06-23 18:13:02 +04:00
|
|
|
// The user has changed the value. Mark it as modified.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->SetCacheEntryBoolProperty(
|
|
|
|
cacheKey, "MODIFIED", true);
|
|
|
|
this->CMakeInstance->GetState()->SetCacheEntryValue(cacheKey,
|
|
|
|
fixedNewValue);
|
2004-06-23 18:13:02 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-06-23 18:13:02 +04:00
|
|
|
}
|
|
|
|
|
2015-04-07 23:45:54 +03:00
|
|
|
void cmCursesMainForm::FixValue(cmState::CacheEntryType type,
|
2004-06-23 18:13:02 +04:00
|
|
|
const std::string& in, std::string& out) const
|
|
|
|
{
|
2016-05-24 22:24:10 +03:00
|
|
|
out = in.substr(0, in.find_last_not_of(' ') + 1);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (type == cmState::PATH || type == cmState::FILEPATH) {
|
2004-06-23 18:13:02 +04:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(out);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (type == cmState::BOOL) {
|
|
|
|
if (cmSystemTools::IsOff(out.c_str())) {
|
2004-06-23 18:13:02 +04:00
|
|
|
out = "OFF";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2004-06-23 18:13:02 +04:00
|
|
|
out = "ON";
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmCursesMainForm::HandleInput()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
int x = 0, y = 0;
|
2001-12-13 21:28:41 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Form) {
|
2001-11-05 02:05:21 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
|
|
|
FIELD* currentField;
|
|
|
|
cmCursesWidget* currentWidget;
|
2001-12-04 19:16:04 +03:00
|
|
|
|
|
|
|
char debugMessage[128];
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (;;) {
|
2001-11-06 06:10:52 +03:00
|
|
|
this->UpdateStatusBar();
|
|
|
|
this->PrintKeys();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->SearchMode) {
|
2006-03-16 18:44:55 +03:00
|
|
|
std::string searchstr = "Search: " + this->SearchString;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->UpdateStatusBar(searchstr.c_str());
|
2003-03-07 19:27:28 +03:00
|
|
|
this->PrintKeys(1);
|
2016-05-16 17:34:04 +03:00
|
|
|
curses_move(y - 5, static_cast<unsigned int>(searchstr.size()));
|
|
|
|
// curses_move(1,1);
|
2011-10-13 21:51:18 +04:00
|
|
|
touchwin(stdscr);
|
2003-03-07 19:27:28 +03:00
|
|
|
refresh();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
int key = getch();
|
|
|
|
|
2001-12-13 21:28:41 +03:00
|
|
|
getmaxyx(stdscr, y, x);
|
|
|
|
// If window too small, handle 'q' only
|
2016-05-16 17:34:04 +03:00
|
|
|
if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
|
2001-12-13 21:28:41 +03:00
|
|
|
// quit
|
2016-05-16 17:34:04 +03:00
|
|
|
if (key == 'q') {
|
2002-10-17 18:51:23 +04:00
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2002-10-17 18:51:23 +04:00
|
|
|
continue;
|
2001-12-13 21:28:41 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-12-13 21:28:41 +03:00
|
|
|
|
2006-03-16 18:44:55 +03:00
|
|
|
currentField = current_field(this->Form);
|
2016-05-16 17:34:04 +03:00
|
|
|
currentWidget =
|
|
|
|
reinterpret_cast<cmCursesWidget*>(field_userptr(currentField));
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool widgetHandled = false;
|
2003-03-07 19:27:28 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->SearchMode) {
|
|
|
|
if (key == 10 || key == KEY_ENTER) {
|
2006-03-16 18:44:55 +03:00
|
|
|
this->SearchMode = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->SearchString.empty()) {
|
2010-09-17 01:45:27 +04:00
|
|
|
this->JumpToCacheEntry(this->SearchString.c_str());
|
2006-03-16 18:44:55 +03:00
|
|
|
this->OldSearchString = this->SearchString;
|
2003-03-07 19:27:28 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SearchString = "";
|
|
|
|
}
|
2003-03-07 19:27:28 +03:00
|
|
|
/*
|
|
|
|
else if ( key == KEY_ESCAPE )
|
|
|
|
{
|
2006-03-16 18:44:55 +03:00
|
|
|
this->SearchMode = false;
|
2003-03-07 19:27:28 +03:00
|
|
|
}
|
|
|
|
*/
|
2016-05-16 17:34:04 +03:00
|
|
|
else if ((key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z') ||
|
|
|
|
(key >= '0' && key <= '9') || (key == '_')) {
|
|
|
|
if (this->SearchString.size() <
|
|
|
|
static_cast<std::string::size_type>(x - 10)) {
|
2009-10-02 00:47:08 +04:00
|
|
|
this->SearchString += static_cast<char>(key);
|
2003-03-07 19:27:28 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC) {
|
|
|
|
if (!this->SearchString.empty()) {
|
|
|
|
this->SearchString.resize(this->SearchString.size() - 1);
|
2003-03-07 19:27:28 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (currentWidget && !this->SearchMode) {
|
2003-03-07 19:27:28 +03:00
|
|
|
// Ask the current widget if it wants to handle input
|
2002-09-06 21:00:12 +04:00
|
|
|
widgetHandled = currentWidget->HandleInput(key, this, stdscr);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (widgetHandled) {
|
2006-03-16 18:44:55 +03:00
|
|
|
this->OkToGenerate = false;
|
2002-09-06 21:00:12 +04:00
|
|
|
this->UpdateStatusBar();
|
|
|
|
this->PrintKeys();
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if ((!currentWidget || !widgetHandled) && !this->SearchMode) {
|
2011-10-13 21:51:18 +04:00
|
|
|
// If the current widget does not want to handle input,
|
2001-12-13 21:28:41 +03:00
|
|
|
// we handle it.
|
2001-12-04 19:16:04 +03:00
|
|
|
sprintf(debugMessage, "Main form handling input, key: %d", key);
|
|
|
|
cmCursesForm::LogMessage(debugMessage);
|
2001-11-06 06:10:52 +03:00
|
|
|
// quit
|
2016-05-16 17:34:04 +03:00
|
|
|
if (key == 'q') {
|
2002-10-17 18:51:23 +04:00
|
|
|
break;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-06 06:10:52 +03:00
|
|
|
// if not end of page, next field otherwise next page
|
2001-11-30 00:44:22 +03:00
|
|
|
// each entry consists of fields: label, isnew, value
|
|
|
|
// therefore, the label field for the prev. entry is index-5
|
|
|
|
// and the label field for the next entry is index+1
|
|
|
|
// (index always corresponds to the value field)
|
2016-07-21 22:30:50 +03:00
|
|
|
// scroll down with arrow down, ctrl+n (emacs binding), or j (vim
|
|
|
|
// binding)
|
|
|
|
else if (key == KEY_DOWN || key == ctrl('n') || key == 'j') {
|
2006-03-16 18:44:55 +03:00
|
|
|
FIELD* cur = current_field(this->Form);
|
2010-06-29 19:09:36 +04:00
|
|
|
size_t findex = field_index(cur);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (findex == 3 * this->NumberOfVisibleEntries - 1) {
|
2002-10-17 18:51:23 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (new_page(this->Fields[findex + 1])) {
|
2006-03-16 18:44:55 +03:00
|
|
|
form_driver(this->Form, REQ_NEXT_PAGE);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-03-16 18:44:55 +03:00
|
|
|
form_driver(this->Form, REQ_NEXT_FIELD);
|
2002-10-17 18:51:23 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-06 06:10:52 +03:00
|
|
|
// if not beginning of page, previous field, otherwise previous page
|
2001-11-30 00:44:22 +03:00
|
|
|
// each entry consists of fields: label, isnew, value
|
|
|
|
// therefore, the label field for the prev. entry is index-5
|
|
|
|
// and the label field for the next entry is index+1
|
|
|
|
// (index always corresponds to the value field)
|
2016-07-21 22:30:50 +03:00
|
|
|
// scroll down with arrow up, ctrl+p (emacs binding), or k (vim binding)
|
|
|
|
else if (key == KEY_UP || key == ctrl('p') || key == 'k') {
|
2006-03-16 18:44:55 +03:00
|
|
|
FIELD* cur = current_field(this->Form);
|
2002-10-17 18:51:23 +04:00
|
|
|
int findex = field_index(cur);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (findex == 2) {
|
2002-10-17 18:51:23 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (new_page(this->Fields[findex - 2])) {
|
2006-03-16 18:44:55 +03:00
|
|
|
form_driver(this->Form, REQ_PREV_PAGE);
|
2016-05-16 17:34:04 +03:00
|
|
|
set_current_field(this->Form, this->Fields[findex - 3]);
|
|
|
|
} else {
|
2006-03-16 18:44:55 +03:00
|
|
|
form_driver(this->Form, REQ_PREV_FIELD);
|
2002-10-17 18:51:23 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-06 06:10:52 +03:00
|
|
|
// pg down
|
2016-05-16 17:34:04 +03:00
|
|
|
else if (key == KEY_NPAGE || key == ctrl('d')) {
|
2006-03-16 18:44:55 +03:00
|
|
|
form_driver(this->Form, REQ_NEXT_PAGE);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-06 06:10:52 +03:00
|
|
|
// pg up
|
2016-05-16 17:34:04 +03:00
|
|
|
else if (key == KEY_PPAGE || key == ctrl('u')) {
|
2006-03-16 18:44:55 +03:00
|
|
|
form_driver(this->Form, REQ_PREV_PAGE);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-06 06:10:52 +03:00
|
|
|
// configure
|
2016-05-16 17:34:04 +03:00
|
|
|
else if (key == 'c') {
|
2002-10-17 18:51:23 +04:00
|
|
|
this->Configure();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
// display help
|
2016-05-16 17:34:04 +03:00
|
|
|
else if (key == 'h') {
|
2002-10-17 18:51:23 +04:00
|
|
|
getmaxyx(stdscr, y, x);
|
|
|
|
|
2006-03-16 18:44:55 +03:00
|
|
|
FIELD* cur = current_field(this->Form);
|
2002-10-17 18:51:23 +04:00
|
|
|
int findex = field_index(cur);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(
|
|
|
|
field_userptr(this->Fields[findex - 2]));
|
2002-10-17 18:51:23 +04:00
|
|
|
const char* curField = lbl->GetValue();
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* helpString = CM_NULLPTR;
|
2015-04-06 13:01:35 +03:00
|
|
|
|
|
|
|
const char* existingValue =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CMakeInstance->GetState()->GetCacheEntryValue(curField);
|
|
|
|
if (existingValue) {
|
|
|
|
helpString = this->CMakeInstance->GetState()->GetCacheEntryProperty(
|
|
|
|
curField, "HELPSTRING");
|
|
|
|
}
|
|
|
|
if (helpString) {
|
|
|
|
char* message = new char
|
|
|
|
[strlen(curField) + strlen(helpString) +
|
|
|
|
strlen(
|
|
|
|
"Current option is: \n Help string for this option is: \n") +
|
|
|
|
10];
|
|
|
|
sprintf(
|
|
|
|
message,
|
|
|
|
"Current option is: %s\nHelp string for this option is: %s\n",
|
|
|
|
curField, helpString);
|
2006-03-16 18:44:55 +03:00
|
|
|
this->HelpMessage[1] = message;
|
2002-10-17 18:51:23 +04:00
|
|
|
delete[] message;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-03-16 18:44:55 +03:00
|
|
|
this->HelpMessage[1] = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-10-17 18:51:23 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCursesLongMessageForm* msgs =
|
|
|
|
new cmCursesLongMessageForm(this->HelpMessage, "Help.");
|
2002-10-17 18:51:23 +04:00
|
|
|
CurrentForm = msgs;
|
2016-05-16 17:34:04 +03:00
|
|
|
msgs->Render(1, 1, x, y);
|
2002-10-17 18:51:23 +04:00
|
|
|
msgs->HandleInput();
|
2011-10-13 21:51:18 +04:00
|
|
|
CurrentForm = this;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Render(1, 1, x, y);
|
2006-03-16 18:44:55 +03:00
|
|
|
set_current_field(this->Form, cur);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
// display last errors
|
2016-05-16 17:34:04 +03:00
|
|
|
else if (key == 'l') {
|
2002-10-17 18:51:23 +04:00
|
|
|
getmaxyx(stdscr, y, x);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(
|
|
|
|
this->Errors, "Errors occurred during the last pass.");
|
2002-10-17 18:51:23 +04:00
|
|
|
CurrentForm = msgs;
|
2016-05-16 17:34:04 +03:00
|
|
|
msgs->Render(1, 1, x, y);
|
2002-10-17 18:51:23 +04:00
|
|
|
msgs->HandleInput();
|
|
|
|
CurrentForm = this;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Render(1, 1, x, y);
|
|
|
|
} else if (key == '/') {
|
2006-03-16 18:44:55 +03:00
|
|
|
this->SearchMode = true;
|
2003-03-07 19:27:28 +03:00
|
|
|
this->UpdateStatusBar("Search");
|
|
|
|
this->PrintKeys(1);
|
|
|
|
touchwin(stdscr);
|
|
|
|
refresh();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (key == 'n') {
|
|
|
|
if (!this->OldSearchString.empty()) {
|
2010-09-17 01:45:27 +04:00
|
|
|
this->JumpToCacheEntry(this->OldSearchString.c_str());
|
2003-03-07 19:27:28 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
// switch advanced on/off
|
2016-05-16 17:34:04 +03:00
|
|
|
else if (key == 't') {
|
|
|
|
if (this->AdvancedMode) {
|
2006-03-16 18:44:55 +03:00
|
|
|
this->AdvancedMode = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-03-16 18:44:55 +03:00
|
|
|
this->AdvancedMode = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-10-17 18:51:23 +04:00
|
|
|
getmaxyx(stdscr, y, x);
|
|
|
|
this->RePost();
|
|
|
|
this->Render(1, 1, x, y);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-06 06:10:52 +03:00
|
|
|
// generate and exit
|
2016-05-16 17:34:04 +03:00
|
|
|
else if (key == 'g') {
|
|
|
|
if (this->OkToGenerate) {
|
2002-10-17 18:51:23 +04:00
|
|
|
this->Generate();
|
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-06 06:10:52 +03:00
|
|
|
// delete cache entry
|
2016-05-16 17:34:04 +03:00
|
|
|
else if (key == 'd' && this->NumberOfVisibleEntries) {
|
2006-03-16 18:44:55 +03:00
|
|
|
this->OkToGenerate = false;
|
|
|
|
FIELD* cur = current_field(this->Form);
|
2010-06-29 19:09:36 +04:00
|
|
|
size_t findex = field_index(cur);
|
2002-10-17 18:51:23 +04:00
|
|
|
|
|
|
|
// make the next or prev. current field after deletion
|
|
|
|
// each entry consists of fields: label, isnew, value
|
|
|
|
// therefore, the label field for the prev. entry is findex-5
|
|
|
|
// and the label field for the next entry is findex+1
|
|
|
|
// (findex always corresponds to the value field)
|
|
|
|
FIELD* nextCur;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (findex == 2) {
|
2016-06-27 23:44:16 +03:00
|
|
|
nextCur = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (findex == 3 * this->NumberOfVisibleEntries - 1) {
|
|
|
|
nextCur = this->Fields[findex - 5];
|
|
|
|
} else {
|
|
|
|
nextCur = this->Fields[findex + 1];
|
|
|
|
}
|
2002-10-17 18:51:23 +04:00
|
|
|
|
|
|
|
// Get the label widget
|
|
|
|
// each entry consists of fields: label, isnew, value
|
|
|
|
// therefore, the label field for the is findex-2
|
|
|
|
// (findex always corresponds to the value field)
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(
|
|
|
|
field_userptr(this->Fields[findex - 2]));
|
|
|
|
if (lbl) {
|
2015-04-06 11:52:45 +03:00
|
|
|
this->CMakeInstance->GetState()->RemoveCacheEntry(lbl->GetValue());
|
2002-10-17 18:51:23 +04:00
|
|
|
|
2004-02-23 06:06:33 +03:00
|
|
|
std::string nextVal;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (nextCur) {
|
|
|
|
nextVal =
|
|
|
|
(reinterpret_cast<cmCursesWidget*>(field_userptr(nextCur))
|
|
|
|
->GetValue());
|
|
|
|
}
|
2004-02-23 06:06:33 +03:00
|
|
|
|
|
|
|
getmaxyx(stdscr, y, x);
|
|
|
|
this->RemoveEntry(lbl->GetValue());
|
|
|
|
this->RePost();
|
|
|
|
this->Render(1, 1, x, y);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (nextCur) {
|
2004-02-23 06:06:33 +03:00
|
|
|
// make the next or prev. current field after deletion
|
2016-06-27 23:44:16 +03:00
|
|
|
nextCur = CM_NULLPTR;
|
2004-02-23 06:06:33 +03:00
|
|
|
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->Entries->begin(); it != this->Entries->end();
|
|
|
|
++it) {
|
|
|
|
if (nextVal == (*it)->Key) {
|
2006-03-16 18:44:55 +03:00
|
|
|
nextCur = (*it)->Entry->Field;
|
2004-02-23 06:06:33 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-02-23 06:06:33 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (nextCur) {
|
2006-03-16 18:44:55 +03:00
|
|
|
set_current_field(this->Form, nextCur);
|
2002-10-17 18:51:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2011-10-13 21:51:18 +04:00
|
|
|
touchwin(stdscr);
|
|
|
|
wrefresh(stdscr);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
|
2016-08-17 02:49:57 +03:00
|
|
|
int cmCursesMainForm::LoadCache(const char* /*unused*/)
|
2002-08-29 00:35:54 +04:00
|
|
|
|
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
int r = this->CMakeInstance->LoadCache();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (r < 0) {
|
2003-01-22 18:33:34 +03:00
|
|
|
return r;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-16 18:44:55 +03:00
|
|
|
this->CMakeInstance->SetCacheArgs(this->Args);
|
|
|
|
this->CMakeInstance->PreLoadCMakeFiles();
|
2003-01-22 18:33:34 +03:00
|
|
|
return r;
|
2002-08-29 00:35:54 +04:00
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2010-09-17 01:45:27 +04:00
|
|
|
void cmCursesMainForm::JumpToCacheEntry(const char* astr)
|
2003-03-07 19:27:28 +03:00
|
|
|
{
|
|
|
|
std::string str;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (astr) {
|
2003-03-07 19:27:28 +03:00
|
|
|
str = cmSystemTools::LowerCase(astr);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-03-07 19:27:28 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (str.empty()) {
|
2003-03-07 19:27:28 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-16 18:44:55 +03:00
|
|
|
FIELD* cur = current_field(this->Form);
|
2003-03-07 19:27:28 +03:00
|
|
|
int start_index = field_index(cur);
|
|
|
|
int findex = start_index;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (;;) {
|
|
|
|
if (!str.empty()) {
|
2016-06-27 23:44:16 +03:00
|
|
|
cmCursesWidget* lbl = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (findex >= 0) {
|
|
|
|
lbl = reinterpret_cast<cmCursesWidget*>(
|
|
|
|
field_userptr(this->Fields[findex - 2]));
|
|
|
|
}
|
|
|
|
if (lbl) {
|
2003-03-07 19:27:28 +03:00
|
|
|
const char* curField = lbl->GetValue();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (curField) {
|
2003-03-07 19:27:28 +03:00
|
|
|
std::string cfld = cmSystemTools::LowerCase(curField);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cfld.find(str) != cfld.npos && findex != start_index) {
|
2003-03-07 19:27:28 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (size_t(findex) >= 3 * this->NumberOfVisibleEntries - 1) {
|
2006-03-16 18:44:55 +03:00
|
|
|
set_current_field(this->Form, this->Fields[2]);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (new_page(this->Fields[findex + 1])) {
|
2006-03-16 18:44:55 +03:00
|
|
|
form_driver(this->Form, REQ_NEXT_PAGE);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-03-16 18:44:55 +03:00
|
|
|
form_driver(this->Form, REQ_NEXT_FIELD);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-03-07 19:27:28 +03:00
|
|
|
/*
|
|
|
|
char buffer[1024];
|
2016-05-16 17:34:04 +03:00
|
|
|
sprintf(buffer, "Line: %d != %d / %d\n", findex, idx,
|
|
|
|
this->NumberOfVisibleEntries);
|
2011-10-13 21:51:18 +04:00
|
|
|
touchwin(stdscr);
|
2003-03-07 19:27:28 +03:00
|
|
|
refresh();
|
|
|
|
this->UpdateStatusBar( buffer );
|
|
|
|
usleep(100000);
|
|
|
|
*/
|
2006-03-16 18:44:55 +03:00
|
|
|
cur = current_field(this->Form);
|
2003-03-07 19:27:28 +03:00
|
|
|
findex = field_index(cur);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (findex == start_index) {
|
2003-03-07 19:27:28 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-03-07 19:27:28 +03:00
|
|
|
}
|
2002-08-29 00:35:54 +04:00
|
|
|
|
2011-10-13 21:51:18 +04:00
|
|
|
const char* cmCursesMainForm::s_ConstHelpMessage =
|
2016-05-16 17:34:04 +03:00
|
|
|
"CMake is used to configure and generate build files for software projects. "
|
|
|
|
"The basic steps for configuring a project with ccmake are as follows:\n\n"
|
|
|
|
"1. Run ccmake in the directory where you want the object and executable "
|
|
|
|
"files to be placed (build directory). If the source directory is not the "
|
|
|
|
"same as this build directory, you have to specify it as an argument on the "
|
|
|
|
"command line.\n\n"
|
|
|
|
"2. When ccmake is run, it will read the configuration files and display "
|
|
|
|
"the current build options. "
|
|
|
|
"If you have run CMake before and have updated the configuration files "
|
|
|
|
"since then, any new entries will be displayed on top and will be marked "
|
|
|
|
"with a *. "
|
|
|
|
"On the other hand, the first time you run ccmake, all build options will "
|
|
|
|
"be new and will be marked as such. "
|
|
|
|
"At this point, you can modify any options (see keys below) you want to "
|
|
|
|
"change. "
|
|
|
|
"When you are satisfied with your changes, press 'c' to have CMake process "
|
|
|
|
"the configuration files. "
|
|
|
|
"Please note that changing some options may cause new ones to appear. These "
|
|
|
|
"will be shown on top and will be marked with *. "
|
|
|
|
"Repeat this procedure until you are satisfied with all the options and "
|
|
|
|
"there are no new entries. "
|
|
|
|
"At this point, a new command will appear: G)enerate and Exit. You can now "
|
|
|
|
"hit 'g' to have CMake generate all the build files (i.e. makefiles or "
|
|
|
|
"project files) and exit. "
|
|
|
|
"At any point during the process, you can exit ccmake with 'q'. However, "
|
|
|
|
"this will not generate/change any build files.\n\n"
|
|
|
|
"ccmake KEYS:\n\n"
|
|
|
|
"Navigation: "
|
|
|
|
"You can use the arrow keys and page up, down to navigate the options. "
|
|
|
|
"Alternatively, you can use the following keys: \n"
|
2016-07-21 22:30:50 +03:00
|
|
|
" C-n or j : next option\n"
|
|
|
|
" C-p or k : previous options\n"
|
2016-05-16 17:34:04 +03:00
|
|
|
" C-d : down one page\n"
|
|
|
|
" C-u : up one page\n\n"
|
|
|
|
"Editing options: "
|
|
|
|
"To change an option press enter or return. If the current options is a "
|
2016-08-02 18:41:06 +03:00
|
|
|
"boolean, this will toggle its value. "
|
2016-07-21 22:30:50 +03:00
|
|
|
"Otherwise, ccmake will enter edit mode. Alternatively, you can toggle "
|
|
|
|
"a bool variable by pressing space, and enter edit mode with i."
|
|
|
|
"In this mode you can edit an option using arrow keys and backspace. "
|
|
|
|
"Alternatively, you can use the following keys:\n"
|
2016-05-16 17:34:04 +03:00
|
|
|
" C-b : back one character\n"
|
|
|
|
" C-f : forward one character\n"
|
|
|
|
" C-a : go to the beginning of the field\n"
|
|
|
|
" C-e : go to the end of the field\n"
|
|
|
|
" C-d : delete previous character\n"
|
|
|
|
" C-k : kill the rest of the field\n"
|
|
|
|
" Esc : Restore field (discard last changes)\n"
|
|
|
|
" Enter : Leave edit mode\n"
|
|
|
|
"Commands:\n"
|
|
|
|
" q : quit ccmake without generating build files\n"
|
|
|
|
" h : help, shows this screen\n"
|
|
|
|
" c : process the configuration files with the current options\n"
|
|
|
|
" g : generate build files and exit, only available when there are no "
|
|
|
|
"new options and no errors have been detected during last configuration.\n"
|
|
|
|
" l : shows last errors\n"
|
2016-07-21 22:29:18 +03:00
|
|
|
" d : delete an option\n"
|
2016-05-16 17:34:04 +03:00
|
|
|
" t : toggles advanced mode. In normal mode, only the most important "
|
|
|
|
"options are shown. In advanced mode, all options are shown. We recommend "
|
|
|
|
"using normal mode unless you are an expert.\n"
|
|
|
|
" / : search for a variable name.\n";
|