ENH: m_ cleanup for curses
This commit is contained in:
parent
4b83a08b37
commit
fb5d92ea37
|
@ -21,10 +21,10 @@ cmCursesBoolWidget::cmCursesBoolWidget(int width, int height,
|
|||
int left, int top) :
|
||||
cmCursesWidget(width, height, left, top)
|
||||
{
|
||||
m_Type = cmCacheManager::BOOL;
|
||||
set_field_fore(m_Field, A_NORMAL);
|
||||
set_field_back(m_Field, A_STANDOUT);
|
||||
field_opts_off(m_Field, O_STATIC);
|
||||
this->Type = cmCacheManager::BOOL;
|
||||
set_field_fore(this->Field, A_NORMAL);
|
||||
set_field_back(this->Field, A_STANDOUT);
|
||||
field_opts_off(this->Field, O_STATIC);
|
||||
this->SetValueAsBool(false);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ void cmCursesBoolWidget::SetValueAsBool(bool value)
|
|||
|
||||
bool cmCursesBoolWidget::GetValueAsBool()
|
||||
{
|
||||
if (m_Value == "ON")
|
||||
if (this->Value == "ON")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -26,55 +26,55 @@
|
|||
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key,
|
||||
int labelwidth,
|
||||
int entrywidth) :
|
||||
m_Key(key), m_LabelWidth(labelwidth), m_EntryWidth(entrywidth)
|
||||
Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
|
||||
{
|
||||
m_Label = new cmCursesLabelWidget(m_LabelWidth, 1, 1, 1, key);
|
||||
m_IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
|
||||
m_Entry = 0;
|
||||
this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
|
||||
this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
|
||||
this->Entry = 0;
|
||||
}
|
||||
|
||||
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
|
||||
const char* key, const cmCacheManager::CacheIterator& it, bool isNew,
|
||||
int labelwidth, int entrywidth)
|
||||
: m_Key(key), m_LabelWidth(labelwidth), m_EntryWidth(entrywidth)
|
||||
: Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
|
||||
{
|
||||
m_Label = new cmCursesLabelWidget(m_LabelWidth, 1, 1, 1, key);
|
||||
this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
|
||||
if (isNew)
|
||||
{
|
||||
m_IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, "*");
|
||||
this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, "*");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
|
||||
this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
|
||||
}
|
||||
|
||||
m_Entry = 0;
|
||||
this->Entry = 0;
|
||||
switch ( it.GetType() )
|
||||
{
|
||||
case cmCacheManager::BOOL:
|
||||
m_Entry = new cmCursesBoolWidget(m_EntryWidth, 1, 1, 1);
|
||||
this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1);
|
||||
if (cmSystemTools::IsOn(it.GetValue()))
|
||||
{
|
||||
static_cast<cmCursesBoolWidget*>(m_Entry)->SetValueAsBool(true);
|
||||
static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
static_cast<cmCursesBoolWidget*>(m_Entry)->SetValueAsBool(false);
|
||||
static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(false);
|
||||
}
|
||||
break;
|
||||
case cmCacheManager::PATH:
|
||||
m_Entry = new cmCursesPathWidget(m_EntryWidth, 1, 1, 1);
|
||||
static_cast<cmCursesPathWidget*>(m_Entry)->SetString(
|
||||
this->Entry = new cmCursesPathWidget(this->EntryWidth, 1, 1, 1);
|
||||
static_cast<cmCursesPathWidget*>(this->Entry)->SetString(
|
||||
it.GetValue());
|
||||
break;
|
||||
case cmCacheManager::FILEPATH:
|
||||
m_Entry = new cmCursesFilePathWidget(m_EntryWidth, 1, 1, 1);
|
||||
static_cast<cmCursesFilePathWidget*>(m_Entry)->SetString(
|
||||
this->Entry = new cmCursesFilePathWidget(this->EntryWidth, 1, 1, 1);
|
||||
static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString(
|
||||
it.GetValue());
|
||||
break;
|
||||
case cmCacheManager::STRING:
|
||||
m_Entry = new cmCursesStringWidget(m_EntryWidth, 1, 1, 1);
|
||||
static_cast<cmCursesStringWidget*>(m_Entry)->SetString(
|
||||
this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1);
|
||||
static_cast<cmCursesStringWidget*>(this->Entry)->SetString(
|
||||
it.GetValue());
|
||||
break;
|
||||
case cmCacheManager::UNINITIALIZED:
|
||||
|
@ -89,16 +89,16 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
|
|||
|
||||
cmCursesCacheEntryComposite::~cmCursesCacheEntryComposite()
|
||||
{
|
||||
delete m_Label;
|
||||
delete m_IsNewLabel;
|
||||
delete m_Entry;
|
||||
delete this->Label;
|
||||
delete this->IsNewLabel;
|
||||
delete this->Entry;
|
||||
}
|
||||
|
||||
const char* cmCursesCacheEntryComposite::GetValue()
|
||||
{
|
||||
if (m_Label)
|
||||
if (this->Label)
|
||||
{
|
||||
return m_Label->GetValue();
|
||||
return this->Label->GetValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -36,12 +36,12 @@ protected:
|
|||
cmCursesCacheEntryComposite(const cmCursesCacheEntryComposite& from);
|
||||
void operator=(const cmCursesCacheEntryComposite&);
|
||||
|
||||
cmCursesLabelWidget* m_Label;
|
||||
cmCursesLabelWidget* m_IsNewLabel;
|
||||
cmCursesWidget* m_Entry;
|
||||
std::string m_Key;
|
||||
int m_LabelWidth;
|
||||
int m_EntryWidth;
|
||||
cmCursesLabelWidget* Label;
|
||||
cmCursesLabelWidget* IsNewLabel;
|
||||
cmCursesWidget* Entry;
|
||||
std::string Key;
|
||||
int LabelWidth;
|
||||
int EntryWidth;
|
||||
};
|
||||
|
||||
#endif // __cmCursesCacheEntryComposite_h
|
||||
|
|
|
@ -20,7 +20,7 @@ cmCursesDummyWidget::cmCursesDummyWidget(int width, int height,
|
|||
int left, int top) :
|
||||
cmCursesWidget(width, height, left, top)
|
||||
{
|
||||
m_Type = cmCacheManager::INTERNAL;
|
||||
this->Type = cmCacheManager::INTERNAL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,6 @@ cmCursesFilePathWidget::cmCursesFilePathWidget(int width, int height,
|
|||
int left, int top) :
|
||||
cmCursesPathWidget(width, height, left, top)
|
||||
{
|
||||
m_Type = cmCacheManager::FILEPATH;
|
||||
this->Type = cmCacheManager::FILEPATH;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,16 +21,16 @@ bool cmCursesForm::Debug = false;
|
|||
|
||||
cmCursesForm::cmCursesForm()
|
||||
{
|
||||
m_Form = 0;
|
||||
this->Form = 0;
|
||||
}
|
||||
|
||||
cmCursesForm::~cmCursesForm()
|
||||
{
|
||||
if (m_Form)
|
||||
if (this->Form)
|
||||
{
|
||||
unpost_form(m_Form);
|
||||
free_form(m_Form);
|
||||
m_Form = 0;
|
||||
unpost_form(this->Form);
|
||||
free_form(this->Form);
|
||||
this->Form = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
// Return the FORM. Should be only used by low-level methods.
|
||||
FORM* GetForm()
|
||||
{
|
||||
return m_Form;
|
||||
return this->Form;
|
||||
}
|
||||
|
||||
static cmCursesForm* CurrentForm;
|
||||
|
@ -71,10 +71,10 @@ protected:
|
|||
static std::ofstream DebugFile;
|
||||
static bool Debug;
|
||||
|
||||
cmCursesForm(const cmCursesForm& from);
|
||||
cmCursesForm(const cmCursesForm& form);
|
||||
void operator=(const cmCursesForm&);
|
||||
|
||||
FORM* m_Form;
|
||||
FORM* Form;
|
||||
};
|
||||
|
||||
#endif // __cmCursesForm_h
|
||||
|
|
|
@ -21,9 +21,9 @@ cmCursesLabelWidget::cmCursesLabelWidget(int width, int height,
|
|||
const std::string& name) :
|
||||
cmCursesWidget(width, height, left, top)
|
||||
{
|
||||
field_opts_off(m_Field, O_EDIT);
|
||||
field_opts_off(m_Field, O_ACTIVE);
|
||||
field_opts_off(m_Field, O_STATIC);
|
||||
field_opts_off(this->Field, O_EDIT);
|
||||
field_opts_off(this->Field, O_ACTIVE);
|
||||
field_opts_off(this->Field, O_STATIC);
|
||||
this->SetValue(name.c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -33,20 +33,20 @@ cmCursesLongMessageForm::cmCursesLongMessageForm(std::vector<std::string>
|
|||
std::vector<std::string>::const_iterator it;
|
||||
for(it=messages.begin(); it != messages.end(); it++)
|
||||
{
|
||||
m_Messages += (*it);
|
||||
this->Messages += (*it);
|
||||
// Add one blank line after each message
|
||||
m_Messages += "\n\n";
|
||||
this->Messages += "\n\n";
|
||||
}
|
||||
m_Title = title;
|
||||
m_Fields[0] = 0;
|
||||
m_Fields[1] = 0;
|
||||
this->Title = title;
|
||||
this->Fields[0] = 0;
|
||||
this->Fields[1] = 0;
|
||||
}
|
||||
|
||||
cmCursesLongMessageForm::~cmCursesLongMessageForm()
|
||||
{
|
||||
if (m_Fields[0])
|
||||
if (this->Fields[0])
|
||||
{
|
||||
free_field(m_Fields[0]);
|
||||
free_field(this->Fields[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,12 +57,12 @@ void cmCursesLongMessageForm::UpdateStatusBar()
|
|||
getmaxyx(stdscr, y, x);
|
||||
|
||||
char bar[cmCursesMainForm::MAX_WIDTH];
|
||||
int size = strlen(m_Title.c_str());
|
||||
int size = strlen(this->Title.c_str());
|
||||
if ( size >= cmCursesMainForm::MAX_WIDTH )
|
||||
{
|
||||
size = cmCursesMainForm::MAX_WIDTH-1;
|
||||
}
|
||||
strncpy(bar, m_Title.c_str(), size);
|
||||
strncpy(bar, this->Title.c_str(), size);
|
||||
for(int i=size-1; i<cmCursesMainForm::MAX_WIDTH; i++) bar[i] = ' ';
|
||||
|
||||
int width;
|
||||
|
@ -92,7 +92,7 @@ void cmCursesLongMessageForm::UpdateStatusBar()
|
|||
attroff(A_STANDOUT);
|
||||
curses_move(y-3,0);
|
||||
printw(version);
|
||||
pos_form_cursor(m_Form);
|
||||
pos_form_cursor(this->Form);
|
||||
}
|
||||
|
||||
void cmCursesLongMessageForm::PrintKeys()
|
||||
|
@ -109,7 +109,7 @@ void cmCursesLongMessageForm::PrintKeys()
|
|||
|
||||
curses_move(y-2,0);
|
||||
printw(firstLine);
|
||||
pos_form_cursor(m_Form);
|
||||
pos_form_cursor(this->Form);
|
||||
|
||||
}
|
||||
|
||||
|
@ -118,45 +118,45 @@ void cmCursesLongMessageForm::Render(int, int, int, int)
|
|||
int x,y;
|
||||
getmaxyx(stdscr, y, x);
|
||||
|
||||
if (m_Form)
|
||||
if (this->Form)
|
||||
{
|
||||
unpost_form(m_Form);
|
||||
free_form(m_Form);
|
||||
m_Form = 0;
|
||||
unpost_form(this->Form);
|
||||
free_form(this->Form);
|
||||
this->Form = 0;
|
||||
}
|
||||
|
||||
const char* msg = m_Messages.c_str();
|
||||
const char* msg = this->Messages.c_str();
|
||||
|
||||
curses_clear();
|
||||
|
||||
if (m_Fields[0])
|
||||
if (this->Fields[0])
|
||||
{
|
||||
free_field(m_Fields[0]);
|
||||
m_Fields[0] = 0;
|
||||
free_field(this->Fields[0]);
|
||||
this->Fields[0] = 0;
|
||||
}
|
||||
|
||||
m_Fields[0] = new_field(y-6, x-2, 1, 1, 0, 0);
|
||||
this->Fields[0] = new_field(y-6, x-2, 1, 1, 0, 0);
|
||||
|
||||
field_opts_off(m_Fields[0], O_STATIC);
|
||||
field_opts_off(this->Fields[0], O_STATIC);
|
||||
|
||||
m_Form = new_form(m_Fields);
|
||||
post_form(m_Form);
|
||||
this->Form = new_form(this->Fields);
|
||||
post_form(this->Form);
|
||||
|
||||
int i=0;
|
||||
form_driver(m_Form, REQ_BEG_FIELD);
|
||||
form_driver(this->Form, REQ_BEG_FIELD);
|
||||
while(msg[i] != '\0' && i < 60000)
|
||||
{
|
||||
if (msg[i] == '\n' && msg[i+1] != '\0')
|
||||
{
|
||||
form_driver(m_Form, REQ_NEW_LINE);
|
||||
form_driver(this->Form, REQ_NEW_LINE);
|
||||
}
|
||||
else
|
||||
{
|
||||
form_driver(m_Form, msg[i]);
|
||||
form_driver(this->Form, msg[i]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
form_driver(m_Form, REQ_BEG_FIELD);
|
||||
form_driver(this->Form, REQ_BEG_FIELD);
|
||||
|
||||
this->UpdateStatusBar();
|
||||
this->PrintKeys();
|
||||
|
@ -167,7 +167,7 @@ void cmCursesLongMessageForm::Render(int, int, int, int)
|
|||
|
||||
void cmCursesLongMessageForm::HandleInput()
|
||||
{
|
||||
if (!m_Form)
|
||||
if (!this->Form)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -188,19 +188,19 @@ void cmCursesLongMessageForm::HandleInput()
|
|||
}
|
||||
else if ( key == KEY_DOWN || key == ctrl('n') )
|
||||
{
|
||||
form_driver(m_Form, REQ_SCR_FLINE);
|
||||
form_driver(this->Form, REQ_SCR_FLINE);
|
||||
}
|
||||
else if ( key == KEY_UP || key == ctrl('p') )
|
||||
{
|
||||
form_driver(m_Form, REQ_SCR_BLINE);
|
||||
form_driver(this->Form, REQ_SCR_BLINE);
|
||||
}
|
||||
else if ( key == KEY_NPAGE || key == ctrl('d') )
|
||||
{
|
||||
form_driver(m_Form, REQ_SCR_FPAGE);
|
||||
form_driver(this->Form, REQ_SCR_FPAGE);
|
||||
}
|
||||
else if ( key == KEY_PPAGE || key == ctrl('u') )
|
||||
{
|
||||
form_driver(m_Form, REQ_SCR_BPAGE);
|
||||
form_driver(this->Form, REQ_SCR_BPAGE);
|
||||
}
|
||||
|
||||
this->UpdateStatusBar();
|
||||
|
|
|
@ -53,10 +53,10 @@ protected:
|
|||
cmCursesLongMessageForm(const cmCursesLongMessageForm& from);
|
||||
void operator=(const cmCursesLongMessageForm&);
|
||||
|
||||
std::string m_Messages;
|
||||
std::string m_Title;
|
||||
std::string Messages;
|
||||
std::string Title;
|
||||
|
||||
FIELD* m_Fields[2];
|
||||
FIELD* Fields[2];
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -35,69 +35,69 @@ inline int ctrl(int z)
|
|||
|
||||
cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
|
||||
int initWidth) :
|
||||
m_Args(args), m_InitialWidth(initWidth)
|
||||
Args(args), InitialWidth(initWidth)
|
||||
{
|
||||
m_NumberOfPages = 0;
|
||||
m_Fields = 0;
|
||||
m_Entries = 0;
|
||||
m_AdvancedMode = false;
|
||||
m_NumberOfVisibleEntries = 0;
|
||||
m_OkToGenerate = false;
|
||||
m_HelpMessage.push_back("Welcome to ccmake, curses based user interface for CMake.");
|
||||
m_HelpMessage.push_back("");
|
||||
m_HelpMessage.push_back(s_ConstHelpMessage);
|
||||
m_CMakeInstance = new cmake;
|
||||
this->NumberOfPages = 0;
|
||||
this->Fields = 0;
|
||||
this->Entries = 0;
|
||||
this->AdvancedMode = false;
|
||||
this->NumberOfVisibleEntries = 0;
|
||||
this->OkToGenerate = false;
|
||||
this->HelpMessage.push_back("Welcome to ccmake, curses based user interface for CMake.");
|
||||
this->HelpMessage.push_back("");
|
||||
this->HelpMessage.push_back(s_ConstHelpMessage);
|
||||
this->CMakeInstance = new cmake;
|
||||
|
||||
// create the arguments for the cmake object
|
||||
std::string whereCMake = cmSystemTools::GetProgramPath(m_Args[0].c_str());
|
||||
std::string whereCMake = cmSystemTools::GetProgramPath(this->Args[0].c_str());
|
||||
whereCMake += "/cmake";
|
||||
m_Args[0] = whereCMake;
|
||||
m_CMakeInstance->SetArgs(m_Args);
|
||||
m_CMakeInstance->SetCMakeCommand(whereCMake.c_str());
|
||||
m_SearchString = "";
|
||||
m_OldSearchString = "";
|
||||
m_SearchMode = false;
|
||||
this->Args[0] = whereCMake;
|
||||
this->CMakeInstance->SetArgs(this->Args);
|
||||
this->CMakeInstance->SetCMakeCommand(whereCMake.c_str());
|
||||
this->SearchString = "";
|
||||
this->OldSearchString = "";
|
||||
this->SearchMode = false;
|
||||
}
|
||||
|
||||
cmCursesMainForm::~cmCursesMainForm()
|
||||
{
|
||||
if (m_Form)
|
||||
if (this->Form)
|
||||
{
|
||||
unpost_form(m_Form);
|
||||
free_form(m_Form);
|
||||
m_Form = 0;
|
||||
unpost_form(this->Form);
|
||||
free_form(this->Form);
|
||||
this->Form = 0;
|
||||
}
|
||||
delete[] m_Fields;
|
||||
delete[] this->Fields;
|
||||
|
||||
// Clean-up composites
|
||||
if (m_Entries)
|
||||
if (this->Entries)
|
||||
{
|
||||
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
||||
for (it = m_Entries->begin(); it != m_Entries->end(); ++it)
|
||||
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
delete m_Entries;
|
||||
if (this->m_CMakeInstance)
|
||||
delete this->Entries;
|
||||
if (this->CMakeInstance)
|
||||
{
|
||||
delete this->m_CMakeInstance;
|
||||
this->m_CMakeInstance = 0;
|
||||
delete this->CMakeInstance;
|
||||
this->CMakeInstance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// See if a cache entry is in the list of entries in the ui.
|
||||
bool cmCursesMainForm::LookForCacheEntry(const char* key)
|
||||
{
|
||||
if (!key || !m_Entries)
|
||||
if (!key || !this->Entries)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
||||
for (it = m_Entries->begin(); it != m_Entries->end(); ++it)
|
||||
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
|
||||
{
|
||||
if (!strcmp(key, (*it)->m_Key.c_str()))
|
||||
if (!strcmp(key, (*it)->Key.c_str()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -113,12 +113,12 @@ void cmCursesMainForm::InitializeUI()
|
|||
// which contain labels, entries and new entry markers
|
||||
std::vector<cmCursesCacheEntryComposite*>* newEntries =
|
||||
new std::vector<cmCursesCacheEntryComposite*>;
|
||||
newEntries->reserve(this->m_CMakeInstance->GetCacheManager()->GetSize());
|
||||
newEntries->reserve(this->CMakeInstance->GetCacheManager()->GetSize());
|
||||
|
||||
// Count non-internal and non-static entries
|
||||
int count=0;
|
||||
for(cmCacheManager::CacheIterator i =
|
||||
this->m_CMakeInstance->GetCacheManager()->NewIterator();
|
||||
this->CMakeInstance->GetCacheManager()->NewIterator();
|
||||
!i.IsAtEnd(); i.Next())
|
||||
{
|
||||
if ( i.GetType() != cmCacheManager::INTERNAL &&
|
||||
|
@ -129,7 +129,7 @@ void cmCursesMainForm::InitializeUI()
|
|||
}
|
||||
}
|
||||
|
||||
int entrywidth = m_InitialWidth - 35;
|
||||
int entrywidth = this->InitialWidth - 35;
|
||||
|
||||
cmCursesCacheEntryComposite* comp;
|
||||
if ( count == 0 )
|
||||
|
@ -137,7 +137,7 @@ void cmCursesMainForm::InitializeUI()
|
|||
// If cache is empty, display a label saying so and a
|
||||
// dummy entry widget (does not respond to input)
|
||||
comp = new cmCursesCacheEntryComposite("EMPTY CACHE", 30, 30);
|
||||
comp->m_Entry = new cmCursesDummyWidget(1, 1, 1, 1);
|
||||
comp->Entry = new cmCursesDummyWidget(1, 1, 1, 1);
|
||||
newEntries->push_back(comp);
|
||||
}
|
||||
else
|
||||
|
@ -146,7 +146,7 @@ void cmCursesMainForm::InitializeUI()
|
|||
|
||||
// First add entries which are new
|
||||
for(cmCacheManager::CacheIterator i =
|
||||
this->m_CMakeInstance->GetCacheManager()->NewIterator();
|
||||
this->CMakeInstance->GetCacheManager()->NewIterator();
|
||||
!i.IsAtEnd(); i.Next())
|
||||
{
|
||||
const char* key = i.GetName();
|
||||
|
@ -162,13 +162,13 @@ void cmCursesMainForm::InitializeUI()
|
|||
newEntries->push_back(new cmCursesCacheEntryComposite(key, i,
|
||||
true, 30,
|
||||
entrywidth));
|
||||
m_OkToGenerate = false;
|
||||
this->OkToGenerate = false;
|
||||
}
|
||||
}
|
||||
|
||||
// then add entries which are old
|
||||
for(cmCacheManager::CacheIterator i =
|
||||
this->m_CMakeInstance->GetCacheManager()->NewIterator();
|
||||
this->CMakeInstance->GetCacheManager()->NewIterator();
|
||||
!i.IsAtEnd(); i.Next())
|
||||
{
|
||||
const char* key = i.GetName();
|
||||
|
@ -189,17 +189,17 @@ void cmCursesMainForm::InitializeUI()
|
|||
}
|
||||
|
||||
// Clean old entries
|
||||
if (m_Entries)
|
||||
if (this->Entries)
|
||||
{
|
||||
// Have to call delete on each pointer
|
||||
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
||||
for (it = m_Entries->begin(); it != m_Entries->end(); ++it)
|
||||
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
delete m_Entries;
|
||||
m_Entries = newEntries;
|
||||
delete this->Entries;
|
||||
this->Entries = newEntries;
|
||||
|
||||
// Compute fields from composites
|
||||
this->RePost();
|
||||
|
@ -209,71 +209,71 @@ void cmCursesMainForm::InitializeUI()
|
|||
void cmCursesMainForm::RePost()
|
||||
{
|
||||
// Create the fields to be passed to the form.
|
||||
if (m_Form)
|
||||
if (this->Form)
|
||||
{
|
||||
unpost_form(m_Form);
|
||||
free_form(m_Form);
|
||||
m_Form = 0;
|
||||
unpost_form(this->Form);
|
||||
free_form(this->Form);
|
||||
this->Form = 0;
|
||||
}
|
||||
delete[] m_Fields;
|
||||
delete[] this->Fields;
|
||||
|
||||
if (m_AdvancedMode)
|
||||
if (this->AdvancedMode)
|
||||
{
|
||||
m_NumberOfVisibleEntries = m_Entries->size();
|
||||
this->NumberOfVisibleEntries = this->Entries->size();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If normal mode, count only non-advanced entries
|
||||
m_NumberOfVisibleEntries = 0;
|
||||
this->NumberOfVisibleEntries = 0;
|
||||
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
||||
for (it = m_Entries->begin(); it != m_Entries->end(); ++it)
|
||||
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
|
||||
{
|
||||
cmCacheManager::CacheIterator mit =
|
||||
this->m_CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue());
|
||||
if (mit.IsAtEnd() || !m_AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))
|
||||
this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue());
|
||||
if (mit.IsAtEnd() || !this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
m_NumberOfVisibleEntries++;
|
||||
this->NumberOfVisibleEntries++;
|
||||
}
|
||||
}
|
||||
|
||||
// Assign the fields: 3 for each entry: label, new entry marker
|
||||
// ('*' or ' ') and entry widget
|
||||
m_Fields = new FIELD*[3*m_NumberOfVisibleEntries+1];
|
||||
this->Fields = new FIELD*[3*this->NumberOfVisibleEntries+1];
|
||||
int cc;
|
||||
for ( cc = 0; cc < 3 * m_NumberOfVisibleEntries+1; cc ++ )
|
||||
for ( cc = 0; cc < 3 * this->NumberOfVisibleEntries+1; cc ++ )
|
||||
{
|
||||
m_Fields[cc] = 0;
|
||||
this->Fields[cc] = 0;
|
||||
}
|
||||
|
||||
// Assign fields
|
||||
int j=0;
|
||||
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
||||
for (it = m_Entries->begin(); it != m_Entries->end(); ++it)
|
||||
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
|
||||
{
|
||||
cmCacheManager::CacheIterator mit =
|
||||
this->m_CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue());
|
||||
if (mit.IsAtEnd() || !m_AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))
|
||||
this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue());
|
||||
if (mit.IsAtEnd() || !this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
m_Fields[3*j] = (*it)->m_Label->m_Field;
|
||||
m_Fields[3*j+1] = (*it)->m_IsNewLabel->m_Field;
|
||||
m_Fields[3*j+2] = (*it)->m_Entry->m_Field;
|
||||
this->Fields[3*j] = (*it)->Label->Field;
|
||||
this->Fields[3*j+1] = (*it)->IsNewLabel->Field;
|
||||
this->Fields[3*j+2] = (*it)->Entry->Field;
|
||||
j++;
|
||||
}
|
||||
|
||||
// Has to be null terminated.
|
||||
m_Fields[3*m_NumberOfVisibleEntries] = 0;
|
||||
this->Fields[3*this->NumberOfVisibleEntries] = 0;
|
||||
}
|
||||
|
||||
void cmCursesMainForm::Render(int left, int top, int width, int height)
|
||||
{
|
||||
|
||||
if (m_Form)
|
||||
if (this->Form)
|
||||
{
|
||||
FIELD* currentField = current_field(m_Form);
|
||||
FIELD* currentField = current_field(this->Form);
|
||||
cmCursesWidget* cw = reinterpret_cast<cmCursesWidget*>
|
||||
(field_userptr(currentField));
|
||||
// If in edit mode, get out of it
|
||||
|
@ -285,14 +285,14 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
|
|||
sw->SetInEdit(false);
|
||||
}
|
||||
// Delete the previous form
|
||||
unpost_form(m_Form);
|
||||
free_form(m_Form);
|
||||
m_Form = 0;
|
||||
unpost_form(this->Form);
|
||||
free_form(this->Form);
|
||||
this->Form = 0;
|
||||
}
|
||||
|
||||
// Wrong window size
|
||||
if ( width < cmCursesMainForm::MIN_WIDTH ||
|
||||
width < m_InitialWidth ||
|
||||
width < this->InitialWidth ||
|
||||
height < cmCursesMainForm::MIN_HEIGHT )
|
||||
{
|
||||
return;
|
||||
|
@ -301,37 +301,37 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
|
|||
// Leave room for toolbar
|
||||
height -= 7;
|
||||
|
||||
if (m_AdvancedMode)
|
||||
if (this->AdvancedMode)
|
||||
{
|
||||
m_NumberOfVisibleEntries = m_Entries->size();
|
||||
this->NumberOfVisibleEntries = this->Entries->size();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If normal, display only non-advanced entries
|
||||
m_NumberOfVisibleEntries = 0;
|
||||
this->NumberOfVisibleEntries = 0;
|
||||
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
||||
for (it = m_Entries->begin(); it != m_Entries->end(); ++it)
|
||||
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
|
||||
{
|
||||
cmCacheManager::CacheIterator mit =
|
||||
this->m_CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue());
|
||||
if (mit.IsAtEnd() || !m_AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))
|
||||
this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue());
|
||||
if (mit.IsAtEnd() || !this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
m_NumberOfVisibleEntries++;
|
||||
this->NumberOfVisibleEntries++;
|
||||
}
|
||||
}
|
||||
|
||||
// Re-adjust the fields according to their place
|
||||
bool isNewPage;
|
||||
int i=0;
|
||||
m_NumberOfPages = 1;
|
||||
this->NumberOfPages = 1;
|
||||
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
||||
for (it = m_Entries->begin(); it != m_Entries->end(); ++it)
|
||||
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
|
||||
{
|
||||
cmCacheManager::CacheIterator mit =
|
||||
this->m_CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue());
|
||||
if (mit.IsAtEnd() || !m_AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))
|
||||
this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue());
|
||||
if (mit.IsAtEnd() || !this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -341,18 +341,18 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
|
|||
|
||||
if (isNewPage)
|
||||
{
|
||||
m_NumberOfPages++;
|
||||
this->NumberOfPages++;
|
||||
}
|
||||
(*it)->m_Label->Move(left, top+row-1, isNewPage);
|
||||
(*it)->m_IsNewLabel->Move(left+32, top+row-1, false);
|
||||
(*it)->m_Entry->Move(left+33, top+row-1, false);
|
||||
(*it)->m_Entry->SetPage(m_NumberOfPages);
|
||||
(*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);
|
||||
(*it)->Entry->SetPage(this->NumberOfPages);
|
||||
i++;
|
||||
}
|
||||
|
||||
// Post the form
|
||||
m_Form = new_form(m_Fields);
|
||||
post_form(m_Form);
|
||||
this->Form = new_form(this->Fields);
|
||||
post_form(this->Form);
|
||||
// Update toolbar
|
||||
this->UpdateStatusBar();
|
||||
this->PrintKeys();
|
||||
|
@ -366,7 +366,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
|
|||
int x,y;
|
||||
getmaxyx(stdscr, y, x);
|
||||
if ( x < cmCursesMainForm::MIN_WIDTH ||
|
||||
x < m_InitialWidth ||
|
||||
x < this->InitialWidth ||
|
||||
y < cmCursesMainForm::MIN_HEIGHT )
|
||||
{
|
||||
return;
|
||||
|
@ -374,9 +374,9 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
|
|||
|
||||
// Give the current widget (if it exists), a chance to print keys
|
||||
cmCursesWidget* cw = 0;
|
||||
if (m_Form)
|
||||
if (this->Form)
|
||||
{
|
||||
FIELD* currentField = current_field(m_Form);
|
||||
FIELD* currentField = current_field(this->Form);
|
||||
cw = reinterpret_cast<cmCursesWidget*>(field_userptr(currentField));
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (m_OkToGenerate)
|
||||
if (this->OkToGenerate)
|
||||
{
|
||||
sprintf(firstLine,
|
||||
"Press [c] to configure Press [g] to generate and exit");
|
||||
|
@ -412,7 +412,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
|
|||
{
|
||||
sprintf(firstLine, "Press [c] to configure ");
|
||||
}
|
||||
if (m_AdvancedMode)
|
||||
if (this->AdvancedMode)
|
||||
{
|
||||
sprintf(thirdLine, "Press [t] to toggle advanced mode (Currently On)");
|
||||
}
|
||||
|
@ -441,13 +441,13 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
|
|||
|
||||
if (cw)
|
||||
{
|
||||
sprintf(firstLine, "Page %d of %d", cw->GetPage(), m_NumberOfPages);
|
||||
sprintf(firstLine, "Page %d of %d", cw->GetPage(), this->NumberOfPages);
|
||||
curses_move(0,65-strlen(firstLine)-1);
|
||||
printw(firstLine);
|
||||
}
|
||||
// }
|
||||
|
||||
pos_form_cursor(m_Form);
|
||||
pos_form_cursor(this->Form);
|
||||
|
||||
}
|
||||
|
||||
|
@ -459,15 +459,15 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
|
|||
getmaxyx(stdscr, y, x);
|
||||
// If window size is too small, display error and return
|
||||
if ( x < cmCursesMainForm::MIN_WIDTH ||
|
||||
x < m_InitialWidth ||
|
||||
x < this->InitialWidth ||
|
||||
y < cmCursesMainForm::MIN_HEIGHT )
|
||||
{
|
||||
curses_clear();
|
||||
curses_move(0,0);
|
||||
char fmt[] = "Window is too small. A size of at least %dx%d is required.";
|
||||
printw(fmt,
|
||||
(cmCursesMainForm::MIN_WIDTH < m_InitialWidth ?
|
||||
m_InitialWidth : cmCursesMainForm::MIN_WIDTH),
|
||||
(cmCursesMainForm::MIN_WIDTH < this->InitialWidth ?
|
||||
this->InitialWidth : cmCursesMainForm::MIN_WIDTH),
|
||||
cmCursesMainForm::MIN_HEIGHT);
|
||||
touchwin(stdscr);
|
||||
wrefresh(stdscr);
|
||||
|
@ -475,12 +475,12 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
|
|||
}
|
||||
|
||||
// Get the key of the current entry
|
||||
FIELD* cur = current_field(m_Form);
|
||||
FIELD* cur = current_field(this->Form);
|
||||
int findex = field_index(cur);
|
||||
cmCursesWidget* lbl = 0;
|
||||
if ( findex >= 0 )
|
||||
{
|
||||
lbl = reinterpret_cast<cmCursesWidget*>(field_userptr(m_Fields[findex-2]));
|
||||
lbl = reinterpret_cast<cmCursesWidget*>(field_userptr(this->Fields[findex-2]));
|
||||
}
|
||||
char help[128] = "";
|
||||
const char* curField = "";
|
||||
|
@ -491,7 +491,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
|
|||
// Get the help string of the current entry
|
||||
// and add it to the help string
|
||||
cmCacheManager::CacheIterator it =
|
||||
this->m_CMakeInstance->GetCacheManager()->GetCacheIterator(curField);
|
||||
this->CMakeInstance->GetCacheManager()->GetCacheIterator(curField);
|
||||
if (!it.IsAtEnd())
|
||||
{
|
||||
const char* hs = it.GetProperty("HELPSTRING");
|
||||
|
@ -594,7 +594,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
|
|||
attroff(A_STANDOUT);
|
||||
curses_move(y-4,0);
|
||||
printw(version);
|
||||
pos_form_cursor(m_Form);
|
||||
pos_form_cursor(this->Form);
|
||||
}
|
||||
|
||||
void cmCursesMainForm::UpdateProgressOld(const char *msg, float prog, void*)
|
||||
|
@ -639,24 +639,24 @@ int cmCursesMainForm::Configure(int noconfigure)
|
|||
this->PrintKeys(1);
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
this->m_CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, this);
|
||||
this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, this);
|
||||
|
||||
// always save the current gui values to disk
|
||||
this->FillCacheManagerFromUI();
|
||||
this->m_CMakeInstance->GetCacheManager()->SaveCache(
|
||||
m_CMakeInstance->GetHomeOutputDirectory());
|
||||
this->CMakeInstance->GetCacheManager()->SaveCache(
|
||||
this->CMakeInstance->GetHomeOutputDirectory());
|
||||
this->LoadCache(0);
|
||||
|
||||
// Get rid of previous errors
|
||||
m_Errors = std::vector<std::string>();
|
||||
this->Errors = std::vector<std::string>();
|
||||
|
||||
// run the generate process
|
||||
m_OkToGenerate = true;
|
||||
this->OkToGenerate = true;
|
||||
int retVal;
|
||||
if ( noconfigure )
|
||||
{
|
||||
retVal = this->m_CMakeInstance->DoPreConfigureChecks();
|
||||
m_OkToGenerate = false;
|
||||
retVal = this->CMakeInstance->DoPreConfigureChecks();
|
||||
this->OkToGenerate = false;
|
||||
if ( retVal > 0 )
|
||||
{
|
||||
retVal = 0;
|
||||
|
@ -664,26 +664,26 @@ int cmCursesMainForm::Configure(int noconfigure)
|
|||
}
|
||||
else
|
||||
{
|
||||
retVal = this->m_CMakeInstance->Configure();
|
||||
retVal = this->CMakeInstance->Configure();
|
||||
}
|
||||
this->m_CMakeInstance->SetProgressCallback(0, 0);
|
||||
this->CMakeInstance->SetProgressCallback(0, 0);
|
||||
|
||||
keypad(stdscr,TRUE); /* Use key symbols as
|
||||
KEY_DOWN*/
|
||||
|
||||
if( retVal != 0 || !m_Errors.empty())
|
||||
if( retVal != 0 || !this->Errors.empty())
|
||||
{
|
||||
// see if there was an error
|
||||
if(cmSystemTools::GetErrorOccuredFlag())
|
||||
{
|
||||
m_OkToGenerate = false;
|
||||
this->OkToGenerate = false;
|
||||
}
|
||||
// reset error condition
|
||||
cmSystemTools::ResetErrorOccuredFlag();
|
||||
int xx,yy;
|
||||
getmaxyx(stdscr, yy, xx);
|
||||
cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(
|
||||
m_Errors,
|
||||
this->Errors,
|
||||
cmSystemTools::GetErrorOccuredFlag() ? "Errors occurred during the last pass." :
|
||||
"CMake produced the following output.");
|
||||
CurrentForm = msgs;
|
||||
|
@ -715,30 +715,30 @@ int cmCursesMainForm::Generate()
|
|||
this->PrintKeys(1);
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
this->m_CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, this);
|
||||
this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, this);
|
||||
|
||||
// Get rid of previous errors
|
||||
m_Errors = std::vector<std::string>();
|
||||
this->Errors = std::vector<std::string>();
|
||||
|
||||
// run the generate process
|
||||
int retVal = this->m_CMakeInstance->Generate();
|
||||
int retVal = this->CMakeInstance->Generate();
|
||||
|
||||
this->m_CMakeInstance->SetProgressCallback(0, 0);
|
||||
this->CMakeInstance->SetProgressCallback(0, 0);
|
||||
keypad(stdscr,TRUE); /* Use key symbols as
|
||||
KEY_DOWN*/
|
||||
|
||||
if( retVal != 0 || !m_Errors.empty())
|
||||
if( retVal != 0 || !this->Errors.empty())
|
||||
{
|
||||
// see if there was an error
|
||||
if(cmSystemTools::GetErrorOccuredFlag())
|
||||
{
|
||||
m_OkToGenerate = false;
|
||||
this->OkToGenerate = false;
|
||||
}
|
||||
// reset error condition
|
||||
cmSystemTools::ResetErrorOccuredFlag();
|
||||
int xx,yy;
|
||||
getmaxyx(stdscr, yy, xx);
|
||||
cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(m_Errors,
|
||||
cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(this->Errors,
|
||||
"Errors occurred during the last pass.");
|
||||
CurrentForm = msgs;
|
||||
msgs->Render(1,1,xx,yy);
|
||||
|
@ -761,7 +761,7 @@ int cmCursesMainForm::Generate()
|
|||
|
||||
void cmCursesMainForm::AddError(const char* message, const char*)
|
||||
{
|
||||
m_Errors.push_back(message);
|
||||
this->Errors.push_back(message);
|
||||
}
|
||||
|
||||
void cmCursesMainForm::RemoveEntry(const char* value)
|
||||
|
@ -772,12 +772,12 @@ void cmCursesMainForm::RemoveEntry(const char* value)
|
|||
}
|
||||
|
||||
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
||||
for (it = m_Entries->begin(); it != m_Entries->end(); ++it)
|
||||
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
|
||||
{
|
||||
const char* val = (*it)->GetValue();
|
||||
if ( val && !strcmp(value, val) )
|
||||
{
|
||||
m_Entries->erase(it);
|
||||
this->Entries->erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -786,16 +786,16 @@ void cmCursesMainForm::RemoveEntry(const char* value)
|
|||
// copy from the list box to the cache manager
|
||||
void cmCursesMainForm::FillCacheManagerFromUI()
|
||||
{
|
||||
int size = m_Entries->size();
|
||||
int size = this->Entries->size();
|
||||
for(int i=0; i < size; i++)
|
||||
{
|
||||
cmCacheManager::CacheIterator it =
|
||||
this->m_CMakeInstance->GetCacheManager()->GetCacheIterator(
|
||||
(*m_Entries)[i]->m_Key.c_str());
|
||||
this->CMakeInstance->GetCacheManager()->GetCacheIterator(
|
||||
(*this->Entries)[i]->Key.c_str());
|
||||
if (!it.IsAtEnd())
|
||||
{
|
||||
std::string oldValue = it.GetValue();
|
||||
std::string newValue = (*m_Entries)[i]->m_Entry->GetValue();
|
||||
std::string newValue = (*this->Entries)[i]->Entry->GetValue();
|
||||
std::string fixedOldValue;
|
||||
std::string fixedNewValue;
|
||||
this->FixValue(it.GetType(), oldValue, fixedOldValue);
|
||||
|
@ -838,7 +838,7 @@ void cmCursesMainForm::HandleInput()
|
|||
{
|
||||
int x=0,y=0;
|
||||
|
||||
if (!m_Form)
|
||||
if (!this->Form)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -852,9 +852,9 @@ void cmCursesMainForm::HandleInput()
|
|||
{
|
||||
this->UpdateStatusBar();
|
||||
this->PrintKeys();
|
||||
if ( m_SearchMode )
|
||||
if ( this->SearchMode )
|
||||
{
|
||||
std::string searchstr = "Search: " + m_SearchString;
|
||||
std::string searchstr = "Search: " + this->SearchString;
|
||||
this->UpdateStatusBar( searchstr.c_str() );
|
||||
this->PrintKeys(1);
|
||||
curses_move(y-5,searchstr.size());
|
||||
|
@ -880,28 +880,28 @@ void cmCursesMainForm::HandleInput()
|
|||
}
|
||||
}
|
||||
|
||||
currentField = current_field(m_Form);
|
||||
currentField = current_field(this->Form);
|
||||
currentWidget = reinterpret_cast<cmCursesWidget*>(field_userptr(
|
||||
currentField));
|
||||
|
||||
bool widgetHandled=false;
|
||||
|
||||
if ( m_SearchMode )
|
||||
if ( this->SearchMode )
|
||||
{
|
||||
if ( key == 10 || key == KEY_ENTER )
|
||||
{
|
||||
m_SearchMode = false;
|
||||
if ( m_SearchString.size() > 0 )
|
||||
this->SearchMode = false;
|
||||
if ( this->SearchString.size() > 0 )
|
||||
{
|
||||
this->JumpToCacheEntry(-1, m_SearchString.c_str());
|
||||
m_OldSearchString = m_SearchString;
|
||||
this->JumpToCacheEntry(-1, this->SearchString.c_str());
|
||||
this->OldSearchString = this->SearchString;
|
||||
}
|
||||
m_SearchString = "";
|
||||
this->SearchString = "";
|
||||
}
|
||||
/*
|
||||
else if ( key == KEY_ESCAPE )
|
||||
{
|
||||
m_SearchMode = false;
|
||||
this->SearchMode = false;
|
||||
}
|
||||
*/
|
||||
else if ( key >= 'a' && key <= 'z' ||
|
||||
|
@ -909,31 +909,31 @@ void cmCursesMainForm::HandleInput()
|
|||
key >= '0' && key <= '9' ||
|
||||
key == '_' )
|
||||
{
|
||||
if ( m_SearchString.size() < static_cast<std::string::size_type>(x-10) )
|
||||
if ( this->SearchString.size() < static_cast<std::string::size_type>(x-10) )
|
||||
{
|
||||
m_SearchString += key;
|
||||
this->SearchString += key;
|
||||
}
|
||||
}
|
||||
else if ( key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC )
|
||||
{
|
||||
if ( m_SearchString.size() > 0 )
|
||||
if ( this->SearchString.size() > 0 )
|
||||
{
|
||||
m_SearchString.resize(m_SearchString.size()-1);
|
||||
this->SearchString.resize(this->SearchString.size()-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (currentWidget && !m_SearchMode)
|
||||
else if (currentWidget && !this->SearchMode)
|
||||
{
|
||||
// Ask the current widget if it wants to handle input
|
||||
widgetHandled = currentWidget->HandleInput(key, this, stdscr);
|
||||
if (widgetHandled)
|
||||
{
|
||||
m_OkToGenerate = false;
|
||||
this->OkToGenerate = false;
|
||||
this->UpdateStatusBar();
|
||||
this->PrintKeys();
|
||||
}
|
||||
}
|
||||
if ((!currentWidget || !widgetHandled) && !m_SearchMode)
|
||||
if ((!currentWidget || !widgetHandled) && !this->SearchMode)
|
||||
{
|
||||
// If the current widget does not want to handle input,
|
||||
// we handle it.
|
||||
|
@ -951,19 +951,19 @@ void cmCursesMainForm::HandleInput()
|
|||
// (index always corresponds to the value field)
|
||||
else if ( key == KEY_DOWN || key == ctrl('n') )
|
||||
{
|
||||
FIELD* cur = current_field(m_Form);
|
||||
FIELD* cur = current_field(this->Form);
|
||||
int findex = field_index(cur);
|
||||
if ( findex == 3*m_NumberOfVisibleEntries-1 )
|
||||
if ( findex == 3*this->NumberOfVisibleEntries-1 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (new_page(m_Fields[findex+1]))
|
||||
if (new_page(this->Fields[findex+1]))
|
||||
{
|
||||
form_driver(m_Form, REQ_NEXT_PAGE);
|
||||
form_driver(this->Form, REQ_NEXT_PAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
form_driver(m_Form, REQ_NEXT_FIELD);
|
||||
form_driver(this->Form, REQ_NEXT_FIELD);
|
||||
}
|
||||
}
|
||||
// if not beginning of page, previous field, otherwise previous page
|
||||
|
@ -973,31 +973,31 @@ void cmCursesMainForm::HandleInput()
|
|||
// (index always corresponds to the value field)
|
||||
else if ( key == KEY_UP || key == ctrl('p') )
|
||||
{
|
||||
FIELD* cur = current_field(m_Form);
|
||||
FIELD* cur = current_field(this->Form);
|
||||
int findex = field_index(cur);
|
||||
if ( findex == 2 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( new_page(m_Fields[findex-2]) )
|
||||
if ( new_page(this->Fields[findex-2]) )
|
||||
{
|
||||
form_driver(m_Form, REQ_PREV_PAGE);
|
||||
set_current_field(m_Form, m_Fields[findex-3]);
|
||||
form_driver(this->Form, REQ_PREV_PAGE);
|
||||
set_current_field(this->Form, this->Fields[findex-3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
form_driver(m_Form, REQ_PREV_FIELD);
|
||||
form_driver(this->Form, REQ_PREV_FIELD);
|
||||
}
|
||||
}
|
||||
// pg down
|
||||
else if ( key == KEY_NPAGE || key == ctrl('d') )
|
||||
{
|
||||
form_driver(m_Form, REQ_NEXT_PAGE);
|
||||
form_driver(this->Form, REQ_NEXT_PAGE);
|
||||
}
|
||||
// pg up
|
||||
else if ( key == KEY_PPAGE || key == ctrl('u') )
|
||||
{
|
||||
form_driver(m_Form, REQ_PREV_PAGE);
|
||||
form_driver(this->Form, REQ_PREV_PAGE);
|
||||
}
|
||||
// configure
|
||||
else if ( key == 'c' )
|
||||
|
@ -1009,14 +1009,14 @@ void cmCursesMainForm::HandleInput()
|
|||
{
|
||||
getmaxyx(stdscr, y, x);
|
||||
|
||||
FIELD* cur = current_field(m_Form);
|
||||
FIELD* cur = current_field(this->Form);
|
||||
int findex = field_index(cur);
|
||||
cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(field_userptr(
|
||||
m_Fields[findex-2]));
|
||||
this->Fields[findex-2]));
|
||||
const char* curField = lbl->GetValue();
|
||||
const char* helpString=0;
|
||||
cmCacheManager::CacheIterator it =
|
||||
this->m_CMakeInstance->GetCacheManager()->GetCacheIterator(curField);
|
||||
this->CMakeInstance->GetCacheManager()->GetCacheIterator(curField);
|
||||
if (!it.IsAtEnd())
|
||||
{
|
||||
helpString = it.GetProperty("HELPSTRING");
|
||||
|
@ -1026,28 +1026,28 @@ void cmCursesMainForm::HandleInput()
|
|||
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);
|
||||
m_HelpMessage[1] = message;
|
||||
this->HelpMessage[1] = message;
|
||||
delete[] message;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_HelpMessage[1] = "";
|
||||
this->HelpMessage[1] = "";
|
||||
}
|
||||
|
||||
cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(m_HelpMessage,
|
||||
cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(this->HelpMessage,
|
||||
"Help.");
|
||||
CurrentForm = msgs;
|
||||
msgs->Render(1,1,x,y);
|
||||
msgs->HandleInput();
|
||||
CurrentForm = this;
|
||||
this->Render(1,1,x,y);
|
||||
set_current_field(m_Form, cur);
|
||||
set_current_field(this->Form, cur);
|
||||
}
|
||||
// display last errors
|
||||
else if ( key == 'l' )
|
||||
{
|
||||
getmaxyx(stdscr, y, x);
|
||||
cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(m_Errors,
|
||||
cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(this->Errors,
|
||||
"Errors occurred during the last pass.");
|
||||
CurrentForm = msgs;
|
||||
msgs->Render(1,1,x,y);
|
||||
|
@ -1057,7 +1057,7 @@ void cmCursesMainForm::HandleInput()
|
|||
}
|
||||
else if ( key == '/' )
|
||||
{
|
||||
m_SearchMode = true;
|
||||
this->SearchMode = true;
|
||||
this->UpdateStatusBar("Search");
|
||||
this->PrintKeys(1);
|
||||
touchwin(stdscr);
|
||||
|
@ -1065,21 +1065,21 @@ void cmCursesMainForm::HandleInput()
|
|||
}
|
||||
else if ( key == 'n' )
|
||||
{
|
||||
if ( m_OldSearchString.size() > 0 )
|
||||
if ( this->OldSearchString.size() > 0 )
|
||||
{
|
||||
this->JumpToCacheEntry(-1, m_OldSearchString.c_str());
|
||||
this->JumpToCacheEntry(-1, this->OldSearchString.c_str());
|
||||
}
|
||||
}
|
||||
// switch advanced on/off
|
||||
else if ( key == 't' )
|
||||
{
|
||||
if (m_AdvancedMode)
|
||||
if (this->AdvancedMode)
|
||||
{
|
||||
m_AdvancedMode = false;
|
||||
this->AdvancedMode = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_AdvancedMode = true;
|
||||
this->AdvancedMode = true;
|
||||
}
|
||||
getmaxyx(stdscr, y, x);
|
||||
this->RePost();
|
||||
|
@ -1088,17 +1088,17 @@ void cmCursesMainForm::HandleInput()
|
|||
// generate and exit
|
||||
else if ( key == 'g' )
|
||||
{
|
||||
if ( m_OkToGenerate )
|
||||
if ( this->OkToGenerate )
|
||||
{
|
||||
this->Generate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
// delete cache entry
|
||||
else if ( key == 'd' && m_NumberOfVisibleEntries )
|
||||
else if ( key == 'd' && this->NumberOfVisibleEntries )
|
||||
{
|
||||
m_OkToGenerate = false;
|
||||
FIELD* cur = current_field(m_Form);
|
||||
this->OkToGenerate = false;
|
||||
FIELD* cur = current_field(this->Form);
|
||||
int findex = field_index(cur);
|
||||
|
||||
// make the next or prev. current field after deletion
|
||||
|
@ -1111,13 +1111,13 @@ void cmCursesMainForm::HandleInput()
|
|||
{
|
||||
nextCur=0;
|
||||
}
|
||||
else if ( findex == 3*m_NumberOfVisibleEntries-1 )
|
||||
else if ( findex == 3*this->NumberOfVisibleEntries-1 )
|
||||
{
|
||||
nextCur = m_Fields[findex-5];
|
||||
nextCur = this->Fields[findex-5];
|
||||
}
|
||||
else
|
||||
{
|
||||
nextCur = m_Fields[findex+1];
|
||||
nextCur = this->Fields[findex+1];
|
||||
}
|
||||
|
||||
// Get the label widget
|
||||
|
@ -1126,10 +1126,10 @@ void cmCursesMainForm::HandleInput()
|
|||
// (findex always corresponds to the value field)
|
||||
cmCursesWidget* lbl
|
||||
= reinterpret_cast<cmCursesWidget*>(
|
||||
field_userptr(m_Fields[findex-2]));
|
||||
field_userptr(this->Fields[findex-2]));
|
||||
if ( lbl )
|
||||
{
|
||||
this->m_CMakeInstance->GetCacheManager()->RemoveCacheEntry(lbl->GetValue());
|
||||
this->CMakeInstance->GetCacheManager()->RemoveCacheEntry(lbl->GetValue());
|
||||
|
||||
std::string nextVal;
|
||||
if (nextCur)
|
||||
|
@ -1147,17 +1147,17 @@ void cmCursesMainForm::HandleInput()
|
|||
// make the next or prev. current field after deletion
|
||||
nextCur = 0;
|
||||
std::vector<cmCursesCacheEntryComposite*>::iterator it;
|
||||
for (it = m_Entries->begin(); it != m_Entries->end(); ++it)
|
||||
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
|
||||
{
|
||||
if (nextVal == (*it)->m_Key)
|
||||
if (nextVal == (*it)->Key)
|
||||
{
|
||||
nextCur = (*it)->m_Entry->m_Field;
|
||||
nextCur = (*it)->Entry->Field;
|
||||
}
|
||||
}
|
||||
|
||||
if (nextCur)
|
||||
{
|
||||
set_current_field(m_Form, nextCur);
|
||||
set_current_field(this->Form, nextCur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1172,13 +1172,13 @@ void cmCursesMainForm::HandleInput()
|
|||
int cmCursesMainForm::LoadCache(const char *)
|
||||
|
||||
{
|
||||
int r = m_CMakeInstance->LoadCache();
|
||||
int r = this->CMakeInstance->LoadCache();
|
||||
if(r < 0)
|
||||
{
|
||||
return r;
|
||||
}
|
||||
m_CMakeInstance->SetCacheArgs(m_Args);
|
||||
m_CMakeInstance->PreLoadCMakeFiles();
|
||||
this->CMakeInstance->SetCacheArgs(this->Args);
|
||||
this->CMakeInstance->PreLoadCMakeFiles();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -1190,7 +1190,7 @@ void cmCursesMainForm::JumpToCacheEntry(int idx, const char* astr)
|
|||
str = cmSystemTools::LowerCase(astr);
|
||||
}
|
||||
|
||||
if ( idx > m_NumberOfVisibleEntries )
|
||||
if ( idx > this->NumberOfVisibleEntries )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1198,7 +1198,7 @@ void cmCursesMainForm::JumpToCacheEntry(int idx, const char* astr)
|
|||
{
|
||||
return;
|
||||
}
|
||||
FIELD* cur = current_field(m_Form);
|
||||
FIELD* cur = current_field(this->Form);
|
||||
int start_index = field_index(cur);
|
||||
int findex = start_index;
|
||||
while ( (findex / 3) != idx )
|
||||
|
@ -1208,7 +1208,7 @@ void cmCursesMainForm::JumpToCacheEntry(int idx, const char* astr)
|
|||
cmCursesWidget* lbl = 0;
|
||||
if ( findex >= 0 )
|
||||
{
|
||||
lbl = reinterpret_cast<cmCursesWidget*>(field_userptr(m_Fields[findex-2]));
|
||||
lbl = reinterpret_cast<cmCursesWidget*>(field_userptr(this->Fields[findex-2]));
|
||||
}
|
||||
if ( lbl )
|
||||
{
|
||||
|
@ -1223,27 +1223,27 @@ void cmCursesMainForm::JumpToCacheEntry(int idx, const char* astr)
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( findex >= 3* m_NumberOfVisibleEntries-1 )
|
||||
if ( findex >= 3* this->NumberOfVisibleEntries-1 )
|
||||
{
|
||||
set_current_field(m_Form, m_Fields[2]);
|
||||
set_current_field(this->Form, this->Fields[2]);
|
||||
}
|
||||
else if (new_page(m_Fields[findex+1]))
|
||||
else if (new_page(this->Fields[findex+1]))
|
||||
{
|
||||
form_driver(m_Form, REQ_NEXT_PAGE);
|
||||
form_driver(this->Form, REQ_NEXT_PAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
form_driver(m_Form, REQ_NEXT_FIELD);
|
||||
form_driver(this->Form, REQ_NEXT_FIELD);
|
||||
}
|
||||
/*
|
||||
char buffer[1024];
|
||||
sprintf(buffer, "Line: %d != %d / %d\n", findex, idx, m_NumberOfVisibleEntries);
|
||||
sprintf(buffer, "Line: %d != %d / %d\n", findex, idx, this->NumberOfVisibleEntries);
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
this->UpdateStatusBar( buffer );
|
||||
usleep(100000);
|
||||
*/
|
||||
cur = current_field(m_Form);
|
||||
cur = current_field(this->Form);
|
||||
findex = field_index(cur);
|
||||
if ( findex == start_index )
|
||||
{
|
||||
|
|
|
@ -132,39 +132,39 @@ protected:
|
|||
void JumpToCacheEntry(int idx, const char* str);
|
||||
|
||||
// Copies of cache entries stored in the user interface
|
||||
std::vector<cmCursesCacheEntryComposite*>* m_Entries;
|
||||
std::vector<cmCursesCacheEntryComposite*>* Entries;
|
||||
// Errors produced during last run of cmake
|
||||
std::vector<std::string> m_Errors;
|
||||
std::vector<std::string> Errors;
|
||||
// Command line argumens to be passed to cmake each time
|
||||
// it is run
|
||||
std::vector<std::string> m_Args;
|
||||
std::vector<std::string> Args;
|
||||
// Message displayed when user presses 'h'
|
||||
// It is: Welcome + info about current entry + common help
|
||||
std::vector<std::string> m_HelpMessage;
|
||||
std::vector<std::string> HelpMessage;
|
||||
|
||||
// Common help
|
||||
static const char* s_ConstHelpMessage;
|
||||
|
||||
// Fields displayed. Includes labels, new entry markers, entries
|
||||
FIELD** m_Fields;
|
||||
FIELD** Fields;
|
||||
// Where is source of current project
|
||||
std::string m_WhereSource;
|
||||
std::string WhereSource;
|
||||
// Where is cmake executable
|
||||
std::string m_WhereCMake;
|
||||
std::string WhereCMake;
|
||||
// Number of entries shown (depends on mode -normal or advanced-)
|
||||
int m_NumberOfVisibleEntries;
|
||||
bool m_AdvancedMode;
|
||||
int NumberOfVisibleEntries;
|
||||
bool AdvancedMode;
|
||||
// Did the iteration converge (no new entries) ?
|
||||
bool m_OkToGenerate;
|
||||
bool OkToGenerate;
|
||||
// Number of pages displayed
|
||||
int m_NumberOfPages;
|
||||
int NumberOfPages;
|
||||
|
||||
int m_InitialWidth;
|
||||
cmake *m_CMakeInstance;
|
||||
int InitialWidth;
|
||||
cmake *CMakeInstance;
|
||||
|
||||
std::string m_SearchString;
|
||||
std::string m_OldSearchString;
|
||||
bool m_SearchMode;
|
||||
std::string SearchString;
|
||||
std::string OldSearchString;
|
||||
bool SearchMode;
|
||||
};
|
||||
|
||||
#endif // __cmCursesMainForm_h
|
||||
|
|
|
@ -23,16 +23,16 @@ cmCursesPathWidget::cmCursesPathWidget(int width, int height,
|
|||
int left, int top) :
|
||||
cmCursesStringWidget(width, height, left, top)
|
||||
{
|
||||
m_Type = cmCacheManager::PATH;
|
||||
m_Cycle = false;
|
||||
m_CurrentIndex = 0;
|
||||
this->Type = cmCacheManager::PATH;
|
||||
this->Cycle = false;
|
||||
this->CurrentIndex = 0;
|
||||
}
|
||||
|
||||
void cmCursesPathWidget::OnType(int& key, cmCursesMainForm* fm, WINDOW* w)
|
||||
{
|
||||
m_Cycle = false;
|
||||
m_CurrentIndex = 0;
|
||||
m_LastGlob = "";
|
||||
this->Cycle = false;
|
||||
this->CurrentIndex = 0;
|
||||
this->LastGlob = "";
|
||||
this->cmCursesStringWidget::OnType(key, fm, w);
|
||||
}
|
||||
|
||||
|
@ -47,16 +47,16 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w)
|
|||
form_driver(form, REQ_PREV_FIELD);
|
||||
std::string cstr = this->GetString();
|
||||
cstr = cstr.substr(0, cstr.find_last_not_of(" \t\n\r")+1);
|
||||
if ( m_LastString != cstr )
|
||||
if ( this->LastString != cstr )
|
||||
{
|
||||
m_Cycle = false;
|
||||
m_CurrentIndex = 0;
|
||||
m_LastGlob = "";
|
||||
this->Cycle = false;
|
||||
this->CurrentIndex = 0;
|
||||
this->LastGlob = "";
|
||||
}
|
||||
std::string glob;
|
||||
if ( m_Cycle )
|
||||
if ( this->Cycle )
|
||||
{
|
||||
glob = m_LastGlob;
|
||||
glob = this->LastGlob;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -64,10 +64,10 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w)
|
|||
}
|
||||
std::vector<cmStdString> dirs;
|
||||
|
||||
cmSystemTools::SimpleGlob(glob.c_str(), dirs, (m_Type == cmCacheManager::PATH?-1:0));
|
||||
if ( m_CurrentIndex < dirs.size() )
|
||||
cmSystemTools::SimpleGlob(glob.c_str(), dirs, (this->Type == cmCacheManager::PATH?-1:0));
|
||||
if ( this->CurrentIndex < dirs.size() )
|
||||
{
|
||||
cstr = dirs[m_CurrentIndex];
|
||||
cstr = dirs[this->CurrentIndex];
|
||||
}
|
||||
if ( cstr[cstr.size()-1] == '*' )
|
||||
{
|
||||
|
@ -83,13 +83,13 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w)
|
|||
touchwin(w);
|
||||
wrefresh(w);
|
||||
form_driver(form, REQ_END_FIELD);
|
||||
m_LastGlob = glob;
|
||||
m_LastString = cstr;
|
||||
m_Cycle = true;
|
||||
m_CurrentIndex ++;
|
||||
if ( m_CurrentIndex >= dirs.size() )
|
||||
this->LastGlob = glob;
|
||||
this->LastString = cstr;
|
||||
this->Cycle = true;
|
||||
this->CurrentIndex ++;
|
||||
if ( this->CurrentIndex >= dirs.size() )
|
||||
{
|
||||
m_CurrentIndex = 0;
|
||||
this->CurrentIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,10 +36,10 @@ protected:
|
|||
cmCursesPathWidget(const cmCursesPathWidget& from);
|
||||
void operator=(const cmCursesPathWidget&);
|
||||
|
||||
std::string m_LastString;
|
||||
std::string m_LastGlob;
|
||||
bool m_Cycle;
|
||||
std::string::size_type m_CurrentIndex;
|
||||
std::string LastString;
|
||||
std::string LastGlob;
|
||||
bool Cycle;
|
||||
std::string::size_type CurrentIndex;
|
||||
};
|
||||
|
||||
#endif // __cmCursesPathWidget_h
|
||||
|
|
|
@ -26,11 +26,11 @@ cmCursesStringWidget::cmCursesStringWidget(int width, int height,
|
|||
int left, int top) :
|
||||
cmCursesWidget(width, height, left, top)
|
||||
{
|
||||
m_InEdit = false;
|
||||
m_Type = cmCacheManager::STRING;
|
||||
set_field_fore(m_Field, A_NORMAL);
|
||||
set_field_back(m_Field, A_STANDOUT);
|
||||
field_opts_off(m_Field, O_STATIC);
|
||||
this->InEdit = false;
|
||||
this->Type = cmCacheManager::STRING;
|
||||
set_field_fore(this->Field, A_NORMAL);
|
||||
set_field_back(this->Field, A_STANDOUT);
|
||||
field_opts_off(this->Field, O_STATIC);
|
||||
}
|
||||
|
||||
void cmCursesStringWidget::OnTab(cmCursesMainForm*, WINDOW*)
|
||||
|
@ -41,25 +41,25 @@ void cmCursesStringWidget::OnTab(cmCursesMainForm*, WINDOW*)
|
|||
void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW*)
|
||||
{
|
||||
FORM* form = fm->GetForm();
|
||||
if (m_InEdit)
|
||||
if (this->InEdit)
|
||||
{
|
||||
cmCursesForm::LogMessage("String widget leaving edit.");
|
||||
m_InEdit = false;
|
||||
this->InEdit = false;
|
||||
fm->PrintKeys();
|
||||
delete[] m_OriginalString;
|
||||
delete[] this->OriginalString;
|
||||
// trick to force forms to update the field buffer
|
||||
form_driver(form, REQ_NEXT_FIELD);
|
||||
form_driver(form, REQ_PREV_FIELD);
|
||||
m_Done = true;
|
||||
this->Done = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmCursesForm::LogMessage("String widget entering edit.");
|
||||
m_InEdit = true;
|
||||
this->InEdit = true;
|
||||
fm->PrintKeys();
|
||||
char* buf = field_buffer(m_Field, 0);
|
||||
m_OriginalString = new char[strlen(buf)+1];
|
||||
strcpy(m_OriginalString, buf);
|
||||
char* buf = field_buffer(this->Field, 0);
|
||||
this->OriginalString = new char[strlen(buf)+1];
|
||||
strcpy(this->OriginalString, buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,18 +75,18 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
|
|||
|
||||
FORM* form = fm->GetForm();
|
||||
// 10 == enter
|
||||
if (!m_InEdit && ( key != 10 && key != KEY_ENTER ) )
|
||||
if (!this->InEdit && ( key != 10 && key != KEY_ENTER ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_OriginalString=0;
|
||||
m_Done = false;
|
||||
this->OriginalString=0;
|
||||
this->Done = false;
|
||||
|
||||
char debugMessage[128];
|
||||
|
||||
// <Enter> is used to change edit mode (like <Esc> in vi).
|
||||
while(!m_Done)
|
||||
while(!this->Done)
|
||||
{
|
||||
sprintf(debugMessage, "String widget handling input, key: %d", key);
|
||||
cmCursesForm::LogMessage(debugMessage);
|
||||
|
@ -111,7 +111,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
|
|||
}
|
||||
|
||||
// If resize occured during edit, move out of edit mode
|
||||
if (!m_InEdit && ( key != 10 && key != KEY_ENTER ) )
|
||||
if (!this->InEdit && ( key != 10 && key != KEY_ENTER ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -125,8 +125,8 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
|
|||
key == KEY_NPAGE || key == ctrl('d') ||
|
||||
key == KEY_PPAGE || key == ctrl('u'))
|
||||
{
|
||||
m_InEdit = false;
|
||||
delete[] m_OriginalString;
|
||||
this->InEdit = false;
|
||||
delete[] this->OriginalString;
|
||||
// trick to force forms to update the field buffer
|
||||
form_driver(form, REQ_NEXT_FIELD);
|
||||
form_driver(form, REQ_PREV_FIELD);
|
||||
|
@ -135,12 +135,12 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
|
|||
// esc
|
||||
else if (key == 27)
|
||||
{
|
||||
if (m_InEdit)
|
||||
if (this->InEdit)
|
||||
{
|
||||
m_InEdit = false;
|
||||
this->InEdit = false;
|
||||
fm->PrintKeys();
|
||||
this->SetString(m_OriginalString);
|
||||
delete[] m_OriginalString;
|
||||
this->SetString(this->OriginalString);
|
||||
delete[] this->OriginalString;
|
||||
touchwin(w);
|
||||
wrefresh(w);
|
||||
return true;
|
||||
|
@ -182,7 +182,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
|
|||
{
|
||||
this->OnType(key, fm, w);
|
||||
}
|
||||
if ( !m_Done )
|
||||
if ( !this->Done )
|
||||
{
|
||||
touchwin(w);
|
||||
wrefresh(w);
|
||||
|
@ -205,7 +205,7 @@ const char* cmCursesStringWidget::GetString()
|
|||
|
||||
const char* cmCursesStringWidget::GetValue()
|
||||
{
|
||||
return field_buffer(m_Field, 0);
|
||||
return field_buffer(this->Field, 0);
|
||||
}
|
||||
|
||||
bool cmCursesStringWidget::PrintKeys()
|
||||
|
@ -217,7 +217,7 @@ bool cmCursesStringWidget::PrintKeys()
|
|||
{
|
||||
return false;
|
||||
}
|
||||
if (m_InEdit)
|
||||
if (this->InEdit)
|
||||
{
|
||||
char firstLine[512];
|
||||
// Clean the toolbar
|
||||
|
|
|
@ -50,10 +50,8 @@ public:
|
|||
* Set/Get InEdit flag. Can be used to tell the widget to leave
|
||||
* edit mode (in case of a resize for example).
|
||||
*/
|
||||
void SetInEdit(bool inedit)
|
||||
{ m_InEdit = inedit; }
|
||||
bool GetInEdit()
|
||||
{ return m_InEdit; }
|
||||
void SetInEdit(bool inedit) { this->InEdit = inedit; }
|
||||
bool GetInEdit() { return this->InEdit; }
|
||||
|
||||
/**
|
||||
* This method is called when different keys are pressed. The
|
||||
|
@ -75,9 +73,9 @@ protected:
|
|||
void operator=(const cmCursesStringWidget&);
|
||||
|
||||
// true if the widget is in edit mode
|
||||
bool m_InEdit;
|
||||
char* m_OriginalString;
|
||||
bool m_Done;
|
||||
bool InEdit;
|
||||
char* OriginalString;
|
||||
bool Done;
|
||||
};
|
||||
|
||||
#endif // __cmCursesStringWidget_h
|
||||
|
|
|
@ -18,46 +18,46 @@
|
|||
|
||||
cmCursesWidget::cmCursesWidget(int width, int height, int left, int top)
|
||||
{
|
||||
m_Field = new_field(height, width, top, left, 0, 0);
|
||||
set_field_userptr(m_Field, reinterpret_cast<char*>(this));
|
||||
field_opts_off(m_Field, O_AUTOSKIP);
|
||||
m_Page = 0;
|
||||
this->Field = new_field(height, width, top, left, 0, 0);
|
||||
set_field_userptr(this->Field, reinterpret_cast<char*>(this));
|
||||
field_opts_off(this->Field, O_AUTOSKIP);
|
||||
this->Page = 0;
|
||||
}
|
||||
|
||||
cmCursesWidget::~cmCursesWidget()
|
||||
{
|
||||
if (m_Field)
|
||||
if (this->Field)
|
||||
{
|
||||
free_field(m_Field);
|
||||
m_Field = 0;
|
||||
free_field(this->Field);
|
||||
this->Field = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void cmCursesWidget::Move(int x, int y, bool isNewPage)
|
||||
{
|
||||
if (!m_Field)
|
||||
if (!this->Field)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
move_field(m_Field, y, x);
|
||||
move_field(this->Field, y, x);
|
||||
if (isNewPage)
|
||||
{
|
||||
set_new_page(m_Field, TRUE);
|
||||
set_new_page(this->Field, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_new_page(m_Field, FALSE);
|
||||
set_new_page(this->Field, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void cmCursesWidget::SetValue(const char* value)
|
||||
{
|
||||
m_Value = value;
|
||||
set_field_buffer(m_Field, 0, value);
|
||||
this->Value = value;
|
||||
set_field_buffer(this->Field, 0, value);
|
||||
}
|
||||
|
||||
const char* cmCursesWidget::GetValue()
|
||||
{
|
||||
return m_Value.c_str();
|
||||
return this->Value.c_str();
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
* Get the type of the widget (STRING, PATH etc...)
|
||||
*/
|
||||
cmCacheManager::CacheEntryType GetType()
|
||||
{ return m_Type; }
|
||||
{ return this->Type; }
|
||||
|
||||
/**
|
||||
* If there are any, print the widget specific commands
|
||||
|
@ -69,11 +69,11 @@ public:
|
|||
*/
|
||||
void SetPage(int page)
|
||||
{
|
||||
m_Page = page;
|
||||
this->Page = page;
|
||||
}
|
||||
int GetPage()
|
||||
{
|
||||
return m_Page;
|
||||
return this->Page;
|
||||
}
|
||||
|
||||
friend class cmCursesMainForm;
|
||||
|
@ -82,11 +82,11 @@ protected:
|
|||
cmCursesWidget(const cmCursesWidget& from);
|
||||
void operator=(const cmCursesWidget&);
|
||||
|
||||
cmCacheManager::CacheEntryType m_Type;
|
||||
std::string m_Value;
|
||||
FIELD* m_Field;
|
||||
cmCacheManager::CacheEntryType Type;
|
||||
std::string Value;
|
||||
FIELD* Field;
|
||||
// The page in the main form this widget is in
|
||||
int m_Page;
|
||||
int Page;
|
||||
};
|
||||
|
||||
#endif // __cmCursesWidget_h
|
||||
|
|
Loading…
Reference in New Issue