mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
cmCursesMainForm: cleanup manual allocation
This commit is contained in:

committed by
Brad King

parent
2b16071149
commit
36875ff419
@@ -13,7 +13,6 @@
|
|||||||
#include "cmStateTypes.h"
|
#include "cmStateTypes.h"
|
||||||
#include "cmStringAlgorithms.h"
|
#include "cmStringAlgorithms.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmake.h"
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -26,12 +25,11 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
|
|||||||
{
|
{
|
||||||
this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
|
this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
|
||||||
this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
|
this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
|
||||||
this->Entry = nullptr;
|
|
||||||
this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1);
|
this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
|
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
|
||||||
const std::string& key, cmake* cm, bool isNew, int labelwidth,
|
const std::string& key, cmState* state, bool isNew, int labelwidth,
|
||||||
int entrywidth)
|
int entrywidth)
|
||||||
: Key(key)
|
: Key(key)
|
||||||
, LabelWidth(labelwidth)
|
, LabelWidth(labelwidth)
|
||||||
@@ -45,9 +43,9 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->Entry = nullptr;
|
this->Entry = nullptr;
|
||||||
const char* value = cm->GetState()->GetCacheEntryValue(key);
|
const char* value = state->GetCacheEntryValue(key);
|
||||||
assert(value);
|
assert(value);
|
||||||
switch (cm->GetState()->GetCacheEntryType(key)) {
|
switch (state->GetCacheEntryType(key)) {
|
||||||
case cmStateEnums::BOOL:
|
case cmStateEnums::BOOL:
|
||||||
this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1);
|
this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1);
|
||||||
if (cmIsOn(value)) {
|
if (cmIsOn(value)) {
|
||||||
@@ -65,8 +63,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
|
|||||||
static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString(value);
|
static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString(value);
|
||||||
break;
|
break;
|
||||||
case cmStateEnums::STRING: {
|
case cmStateEnums::STRING: {
|
||||||
const char* stringsProp =
|
const char* stringsProp = state->GetCacheEntryProperty(key, "STRINGS");
|
||||||
cm->GetState()->GetCacheEntryProperty(key, "STRINGS");
|
|
||||||
if (stringsProp) {
|
if (stringsProp) {
|
||||||
cmCursesOptionsWidget* ow =
|
cmCursesOptionsWidget* ow =
|
||||||
new cmCursesOptionsWidget(this->EntryWidth, 1, 1, 1);
|
new cmCursesOptionsWidget(this->EntryWidth, 1, 1, 1);
|
||||||
|
@@ -9,15 +9,15 @@
|
|||||||
|
|
||||||
class cmCursesLabelWidget;
|
class cmCursesLabelWidget;
|
||||||
class cmCursesWidget;
|
class cmCursesWidget;
|
||||||
class cmake;
|
class cmState;
|
||||||
|
|
||||||
class cmCursesCacheEntryComposite
|
class cmCursesCacheEntryComposite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cmCursesCacheEntryComposite(const std::string& key, int labelwidth,
|
cmCursesCacheEntryComposite(const std::string& key, int labelwidth,
|
||||||
int entrywidth);
|
int entrywidth);
|
||||||
cmCursesCacheEntryComposite(const std::string& key, cmake* cm, bool isNew,
|
cmCursesCacheEntryComposite(const std::string& key, cmState* state,
|
||||||
int labelwidth, int entrywidth);
|
bool isNew, int labelwidth, int entrywidth);
|
||||||
~cmCursesCacheEntryComposite();
|
~cmCursesCacheEntryComposite();
|
||||||
|
|
||||||
cmCursesCacheEntryComposite(cmCursesCacheEntryComposite const&) = delete;
|
cmCursesCacheEntryComposite(cmCursesCacheEntryComposite const&) = delete;
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
#include "cmCursesMainForm.h"
|
#include "cmCursesMainForm.h"
|
||||||
|
|
||||||
#include "cmAlgorithms.h"
|
|
||||||
#include "cmCursesCacheEntryComposite.h"
|
#include "cmCursesCacheEntryComposite.h"
|
||||||
#include "cmCursesDummyWidget.h"
|
#include "cmCursesDummyWidget.h"
|
||||||
#include "cmCursesForm.h"
|
#include "cmCursesForm.h"
|
||||||
@@ -18,6 +17,8 @@
|
|||||||
#include "cmVersion.h"
|
#include "cmVersion.h"
|
||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
|
|
||||||
|
#include <cm/memory>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -34,8 +35,6 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args,
|
|||||||
, InitialWidth(initWidth)
|
, InitialWidth(initWidth)
|
||||||
{
|
{
|
||||||
this->NumberOfPages = 0;
|
this->NumberOfPages = 0;
|
||||||
this->Fields = nullptr;
|
|
||||||
this->Entries = nullptr;
|
|
||||||
this->AdvancedMode = false;
|
this->AdvancedMode = false;
|
||||||
this->NumberOfVisibleEntries = 0;
|
this->NumberOfVisibleEntries = 0;
|
||||||
this->OkToGenerate = false;
|
this->OkToGenerate = false;
|
||||||
@@ -43,7 +42,8 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args,
|
|||||||
"Welcome to ccmake, curses based user interface for CMake.");
|
"Welcome to ccmake, curses based user interface for CMake.");
|
||||||
this->HelpMessage.emplace_back();
|
this->HelpMessage.emplace_back();
|
||||||
this->HelpMessage.emplace_back(s_ConstHelpMessage);
|
this->HelpMessage.emplace_back(s_ConstHelpMessage);
|
||||||
this->CMakeInstance = new cmake(cmake::RoleProject, cmState::Project);
|
this->CMakeInstance =
|
||||||
|
cm::make_unique<cmake>(cmake::RoleProject, cmState::Project);
|
||||||
this->CMakeInstance->SetCMakeEditCommand(
|
this->CMakeInstance->SetCMakeEditCommand(
|
||||||
cmSystemTools::GetCMakeCursesCommand());
|
cmSystemTools::GetCMakeCursesCommand());
|
||||||
|
|
||||||
@@ -52,8 +52,6 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args,
|
|||||||
cmStrCat(cmSystemTools::GetProgramPath(this->Args[0]), "/cmake");
|
cmStrCat(cmSystemTools::GetProgramPath(this->Args[0]), "/cmake");
|
||||||
this->Args[0] = whereCMake;
|
this->Args[0] = whereCMake;
|
||||||
this->CMakeInstance->SetArgs(this->Args);
|
this->CMakeInstance->SetArgs(this->Args);
|
||||||
this->SearchString = "";
|
|
||||||
this->OldSearchString = "";
|
|
||||||
this->SearchMode = false;
|
this->SearchMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,27 +62,16 @@ cmCursesMainForm::~cmCursesMainForm()
|
|||||||
free_form(this->Form);
|
free_form(this->Form);
|
||||||
this->Form = nullptr;
|
this->Form = nullptr;
|
||||||
}
|
}
|
||||||
delete[] this->Fields;
|
|
||||||
|
|
||||||
// Clean-up composites
|
|
||||||
if (this->Entries) {
|
|
||||||
cmDeleteAll(*this->Entries);
|
|
||||||
}
|
|
||||||
delete this->Entries;
|
|
||||||
if (this->CMakeInstance) {
|
|
||||||
delete this->CMakeInstance;
|
|
||||||
this->CMakeInstance = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if a cache entry is in the list of entries in the ui.
|
// See if a cache entry is in the list of entries in the ui.
|
||||||
bool cmCursesMainForm::LookForCacheEntry(const std::string& key)
|
bool cmCursesMainForm::LookForCacheEntry(const std::string& key)
|
||||||
{
|
{
|
||||||
return this->Entries &&
|
return std::any_of(
|
||||||
std::any_of(this->Entries->begin(), this->Entries->end(),
|
this->Entries.begin(), this->Entries.end(),
|
||||||
[&key](cmCursesCacheEntryComposite* entry) {
|
[&key](std::unique_ptr<cmCursesCacheEntryComposite> const& entry) {
|
||||||
return key == entry->Key;
|
return key == entry->Key;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new cmCursesCacheEntryComposite entries from the cache
|
// Create new cmCursesCacheEntryComposite entries from the cache
|
||||||
@@ -92,11 +79,10 @@ void cmCursesMainForm::InitializeUI()
|
|||||||
{
|
{
|
||||||
// Create a vector of cmCursesCacheEntryComposite's
|
// Create a vector of cmCursesCacheEntryComposite's
|
||||||
// which contain labels, entries and new entry markers
|
// which contain labels, entries and new entry markers
|
||||||
std::vector<cmCursesCacheEntryComposite*>* newEntries =
|
std::vector<std::unique_ptr<cmCursesCacheEntryComposite>> newEntries;
|
||||||
new std::vector<cmCursesCacheEntryComposite*>;
|
|
||||||
std::vector<std::string> cacheKeys =
|
std::vector<std::string> cacheKeys =
|
||||||
this->CMakeInstance->GetState()->GetCacheEntryKeys();
|
this->CMakeInstance->GetState()->GetCacheEntryKeys();
|
||||||
newEntries->reserve(cacheKeys.size());
|
newEntries.reserve(cacheKeys.size());
|
||||||
|
|
||||||
// Count non-internal and non-static entries
|
// Count non-internal and non-static entries
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -112,13 +98,13 @@ void cmCursesMainForm::InitializeUI()
|
|||||||
|
|
||||||
int entrywidth = this->InitialWidth - 35;
|
int entrywidth = this->InitialWidth - 35;
|
||||||
|
|
||||||
cmCursesCacheEntryComposite* comp;
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
// If cache is empty, display a label saying so and a
|
// If cache is empty, display a label saying so and a
|
||||||
// dummy entry widget (does not respond to input)
|
// dummy entry widget (does not respond to input)
|
||||||
comp = new cmCursesCacheEntryComposite("EMPTY CACHE", 30, 30);
|
std::unique_ptr<cmCursesCacheEntryComposite> comp =
|
||||||
|
cm::make_unique<cmCursesCacheEntryComposite>("EMPTY CACHE", 30, 30);
|
||||||
comp->Entry = new cmCursesDummyWidget(1, 1, 1, 1);
|
comp->Entry = new cmCursesDummyWidget(1, 1, 1, 1);
|
||||||
newEntries->push_back(comp);
|
newEntries.emplace_back(std::move(comp));
|
||||||
} else {
|
} else {
|
||||||
// Create the composites.
|
// Create the composites.
|
||||||
|
|
||||||
@@ -132,8 +118,8 @@ void cmCursesMainForm::InitializeUI()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this->LookForCacheEntry(key)) {
|
if (!this->LookForCacheEntry(key)) {
|
||||||
newEntries->push_back(new cmCursesCacheEntryComposite(
|
newEntries.emplace_back(cm::make_unique<cmCursesCacheEntryComposite>(
|
||||||
key, this->CMakeInstance, true, 30, entrywidth));
|
key, this->CMakeInstance->GetState(), true, 30, entrywidth));
|
||||||
this->OkToGenerate = false;
|
this->OkToGenerate = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,18 +134,14 @@ void cmCursesMainForm::InitializeUI()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->LookForCacheEntry(key)) {
|
if (this->LookForCacheEntry(key)) {
|
||||||
newEntries->push_back(new cmCursesCacheEntryComposite(
|
newEntries.emplace_back(cm::make_unique<cmCursesCacheEntryComposite>(
|
||||||
key, this->CMakeInstance, false, 30, entrywidth));
|
key, this->CMakeInstance->GetState(), false, 30, entrywidth));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean old entries
|
// Replace old entries
|
||||||
if (this->Entries) {
|
this->Entries = std::move(newEntries);
|
||||||
cmDeleteAll(*this->Entries);
|
|
||||||
}
|
|
||||||
delete this->Entries;
|
|
||||||
this->Entries = newEntries;
|
|
||||||
|
|
||||||
// Compute fields from composites
|
// Compute fields from composites
|
||||||
this->RePost();
|
this->RePost();
|
||||||
@@ -173,13 +155,13 @@ void cmCursesMainForm::RePost()
|
|||||||
free_form(this->Form);
|
free_form(this->Form);
|
||||||
this->Form = nullptr;
|
this->Form = nullptr;
|
||||||
}
|
}
|
||||||
delete[] this->Fields;
|
this->Fields.clear();
|
||||||
if (this->AdvancedMode) {
|
if (this->AdvancedMode) {
|
||||||
this->NumberOfVisibleEntries = this->Entries->size();
|
this->NumberOfVisibleEntries = this->Entries.size();
|
||||||
} else {
|
} else {
|
||||||
// If normal mode, count only non-advanced entries
|
// If normal mode, count only non-advanced entries
|
||||||
this->NumberOfVisibleEntries = 0;
|
this->NumberOfVisibleEntries = 0;
|
||||||
for (cmCursesCacheEntryComposite* entry : *this->Entries) {
|
for (std::unique_ptr<cmCursesCacheEntryComposite>& entry : this->Entries) {
|
||||||
const char* existingValue =
|
const char* existingValue =
|
||||||
this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue());
|
this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue());
|
||||||
bool advanced =
|
bool advanced =
|
||||||
@@ -197,15 +179,10 @@ void cmCursesMainForm::RePost()
|
|||||||
}
|
}
|
||||||
// Assign the fields: 3 for each entry: label, new entry marker
|
// Assign the fields: 3 for each entry: label, new entry marker
|
||||||
// ('*' or ' ') and entry widget
|
// ('*' or ' ') and entry widget
|
||||||
this->Fields = new FIELD*[3 * this->NumberOfVisibleEntries + 1];
|
this->Fields.reserve(3 * this->NumberOfVisibleEntries + 1);
|
||||||
size_t cc;
|
|
||||||
for (cc = 0; cc < 3 * this->NumberOfVisibleEntries + 1; cc++) {
|
|
||||||
this->Fields[cc] = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign fields
|
// Assign fields
|
||||||
int j = 0;
|
for (std::unique_ptr<cmCursesCacheEntryComposite>& entry : this->Entries) {
|
||||||
for (cmCursesCacheEntryComposite* entry : *this->Entries) {
|
|
||||||
const char* existingValue =
|
const char* existingValue =
|
||||||
this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue());
|
this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue());
|
||||||
bool advanced =
|
bool advanced =
|
||||||
@@ -214,21 +191,20 @@ void cmCursesMainForm::RePost()
|
|||||||
if (!existingValue || (!this->AdvancedMode && advanced)) {
|
if (!existingValue || (!this->AdvancedMode && advanced)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this->Fields[3 * j] = entry->Label->Field;
|
this->Fields.push_back(entry->Label->Field);
|
||||||
this->Fields[3 * j + 1] = entry->IsNewLabel->Field;
|
this->Fields.push_back(entry->IsNewLabel->Field);
|
||||||
this->Fields[3 * j + 2] = entry->Entry->Field;
|
this->Fields.push_back(entry->Entry->Field);
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
// if no cache entries there should still be one dummy field
|
// if no cache entries there should still be one dummy field
|
||||||
if (j == 0) {
|
if (this->Fields.empty()) {
|
||||||
const auto& front = *this->Entries->front();
|
const auto& front = *this->Entries.front();
|
||||||
this->Fields[0] = front.Label->Field;
|
this->Fields.push_back(front.Label->Field);
|
||||||
this->Fields[1] = front.IsNewLabel->Field;
|
this->Fields.push_back(front.IsNewLabel->Field);
|
||||||
this->Fields[2] = front.Entry->Field;
|
this->Fields.push_back(front.Entry->Field);
|
||||||
this->NumberOfVisibleEntries = 1;
|
this->NumberOfVisibleEntries = 1;
|
||||||
}
|
}
|
||||||
// Has to be null terminated.
|
// Has to be null terminated.
|
||||||
this->Fields[3 * this->NumberOfVisibleEntries] = nullptr;
|
this->Fields.push_back(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCursesMainForm::Render(int left, int top, int width, int height)
|
void cmCursesMainForm::Render(int left, int top, int width, int height)
|
||||||
@@ -261,11 +237,11 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
|
|||||||
height -= 7;
|
height -= 7;
|
||||||
|
|
||||||
if (this->AdvancedMode) {
|
if (this->AdvancedMode) {
|
||||||
this->NumberOfVisibleEntries = this->Entries->size();
|
this->NumberOfVisibleEntries = this->Entries.size();
|
||||||
} else {
|
} else {
|
||||||
// If normal, display only non-advanced entries
|
// If normal, display only non-advanced entries
|
||||||
this->NumberOfVisibleEntries = 0;
|
this->NumberOfVisibleEntries = 0;
|
||||||
for (cmCursesCacheEntryComposite* entry : *this->Entries) {
|
for (std::unique_ptr<cmCursesCacheEntryComposite>& entry : this->Entries) {
|
||||||
const char* existingValue =
|
const char* existingValue =
|
||||||
this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue());
|
this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue());
|
||||||
bool advanced =
|
bool advanced =
|
||||||
@@ -283,7 +259,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
|
|||||||
if (height > 0) {
|
if (height > 0) {
|
||||||
bool isNewPage;
|
bool isNewPage;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (cmCursesCacheEntryComposite* entry : *this->Entries) {
|
for (std::unique_ptr<cmCursesCacheEntryComposite>& entry : this->Entries) {
|
||||||
const char* existingValue =
|
const char* existingValue =
|
||||||
this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue());
|
this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue());
|
||||||
bool advanced =
|
bool advanced =
|
||||||
@@ -308,7 +284,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Post the form
|
// Post the form
|
||||||
this->Form = new_form(this->Fields);
|
this->Form = new_form(this->Fields.data());
|
||||||
post_form(this->Form);
|
post_form(this->Form);
|
||||||
// Update toolbar
|
// Update toolbar
|
||||||
this->UpdateStatusBar();
|
this->UpdateStatusBar();
|
||||||
@@ -654,23 +630,23 @@ void cmCursesMainForm::RemoveEntry(const char* value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto removeIt =
|
auto removeIt = std::find_if(
|
||||||
std::find_if(this->Entries->begin(), this->Entries->end(),
|
this->Entries.begin(), this->Entries.end(),
|
||||||
[value](cmCursesCacheEntryComposite* entry) -> bool {
|
[value](std::unique_ptr<cmCursesCacheEntryComposite>& entry) -> bool {
|
||||||
const char* val = entry->GetValue();
|
const char* val = entry->GetValue();
|
||||||
return val != nullptr && !strcmp(value, val);
|
return val != nullptr && !strcmp(value, val);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (removeIt != this->Entries->end()) {
|
if (removeIt != this->Entries.end()) {
|
||||||
this->CMakeInstance->UnwatchUnusedCli(value);
|
this->CMakeInstance->UnwatchUnusedCli(value);
|
||||||
this->Entries->erase(removeIt);
|
this->Entries.erase(removeIt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy from the list box to the cache manager
|
// copy from the list box to the cache manager
|
||||||
void cmCursesMainForm::FillCacheManagerFromUI()
|
void cmCursesMainForm::FillCacheManagerFromUI()
|
||||||
{
|
{
|
||||||
for (cmCursesCacheEntryComposite* entry : *this->Entries) {
|
for (std::unique_ptr<cmCursesCacheEntryComposite>& entry : this->Entries) {
|
||||||
const std::string& cacheKey = entry->Key;
|
const std::string& cacheKey = entry->Key;
|
||||||
const char* existingValue =
|
const char* existingValue =
|
||||||
this->CMakeInstance->GetState()->GetCacheEntryValue(cacheKey);
|
this->CMakeInstance->GetState()->GetCacheEntryValue(cacheKey);
|
||||||
@@ -762,7 +738,7 @@ void cmCursesMainForm::HandleInput()
|
|||||||
this->JumpToCacheEntry(this->SearchString.c_str());
|
this->JumpToCacheEntry(this->SearchString.c_str());
|
||||||
this->OldSearchString = this->SearchString;
|
this->OldSearchString = this->SearchString;
|
||||||
}
|
}
|
||||||
this->SearchString = "";
|
this->SearchString.clear();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
else if ( key == KEY_ESCAPE )
|
else if ( key == KEY_ESCAPE )
|
||||||
@@ -778,7 +754,7 @@ void cmCursesMainForm::HandleInput()
|
|||||||
}
|
}
|
||||||
} else if (key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC) {
|
} else if (key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC) {
|
||||||
if (!this->SearchString.empty()) {
|
if (!this->SearchString.empty()) {
|
||||||
this->SearchString.resize(this->SearchString.size() - 1);
|
this->SearchString.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (currentWidget && !this->SearchMode) {
|
} else if (currentWidget && !this->SearchMode) {
|
||||||
@@ -867,17 +843,9 @@ void cmCursesMainForm::HandleInput()
|
|||||||
curField, "HELPSTRING");
|
curField, "HELPSTRING");
|
||||||
}
|
}
|
||||||
if (helpString) {
|
if (helpString) {
|
||||||
char* message = new char
|
this->HelpMessage[1] =
|
||||||
[strlen(curField) + strlen(helpString) +
|
cmStrCat("Current option is: ", curField, '\n',
|
||||||
strlen(
|
"Help string for this option is: ", helpString, '\n');
|
||||||
"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);
|
|
||||||
this->HelpMessage[1] = message;
|
|
||||||
delete[] message;
|
|
||||||
} else {
|
} else {
|
||||||
this->HelpMessage[1] = "";
|
this->HelpMessage[1] = "";
|
||||||
}
|
}
|
||||||
@@ -973,13 +941,13 @@ void cmCursesMainForm::HandleInput()
|
|||||||
|
|
||||||
if (nextCur) {
|
if (nextCur) {
|
||||||
// make the next or prev. current field after deletion
|
// make the next or prev. current field after deletion
|
||||||
auto nextEntryIt =
|
auto nextEntryIt = std::find_if(
|
||||||
std::find_if(this->Entries->begin(), this->Entries->end(),
|
this->Entries.begin(), this->Entries.end(),
|
||||||
[&nextVal](cmCursesCacheEntryComposite* entry) {
|
[&nextVal](std::unique_ptr<cmCursesCacheEntryComposite>& entry) {
|
||||||
return nextVal == entry->Key;
|
return nextVal == entry->Key;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (nextEntryIt != this->Entries->end()) {
|
if (nextEntryIt != this->Entries.end()) {
|
||||||
set_current_field(this->Form, (*nextEntryIt)->Entry->Field);
|
set_current_field(this->Form, (*nextEntryIt)->Entry->Field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include "cmStateTypes.h"
|
#include "cmStateTypes.h"
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ protected:
|
|||||||
void JumpToCacheEntry(const char* str);
|
void JumpToCacheEntry(const char* str);
|
||||||
|
|
||||||
// Copies of cache entries stored in the user interface
|
// Copies of cache entries stored in the user interface
|
||||||
std::vector<cmCursesCacheEntryComposite*>* Entries;
|
std::vector<std::unique_ptr<cmCursesCacheEntryComposite>> Entries;
|
||||||
// Errors produced during last run of cmake
|
// Errors produced during last run of cmake
|
||||||
std::vector<std::string> Errors;
|
std::vector<std::string> Errors;
|
||||||
// Command line arguments to be passed to cmake each time
|
// Command line arguments to be passed to cmake each time
|
||||||
@@ -136,11 +137,7 @@ protected:
|
|||||||
static const char* s_ConstHelpMessage;
|
static const char* s_ConstHelpMessage;
|
||||||
|
|
||||||
// Fields displayed. Includes labels, new entry markers, entries
|
// Fields displayed. Includes labels, new entry markers, entries
|
||||||
FIELD** Fields;
|
std::vector<FIELD*> Fields;
|
||||||
// Where is source of current project
|
|
||||||
std::string WhereSource;
|
|
||||||
// Where is cmake executable
|
|
||||||
std::string WhereCMake;
|
|
||||||
// Number of entries shown (depends on mode -normal or advanced-)
|
// Number of entries shown (depends on mode -normal or advanced-)
|
||||||
size_t NumberOfVisibleEntries;
|
size_t NumberOfVisibleEntries;
|
||||||
bool AdvancedMode;
|
bool AdvancedMode;
|
||||||
@@ -150,7 +147,7 @@ protected:
|
|||||||
int NumberOfPages;
|
int NumberOfPages;
|
||||||
|
|
||||||
int InitialWidth;
|
int InitialWidth;
|
||||||
cmake* CMakeInstance;
|
std::unique_ptr<cmake> CMakeInstance;
|
||||||
|
|
||||||
std::string SearchString;
|
std::string SearchString;
|
||||||
std::string OldSearchString;
|
std::string OldSearchString;
|
||||||
|
Reference in New Issue
Block a user