diff options
author | Ken Martin <ken.martin@kitware.com> | 2002-09-06 17:00:12 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2002-09-06 17:00:12 (GMT) |
commit | 2c7e9b3b59cda840adc2aa4c3bfe1ffa0707be99 (patch) | |
tree | a95ace3252950c108fea1c9ba8bdc0303388d909 /Source/CursesDialog | |
parent | b0fa5117bf35aeff25cddb5c7dd195591d048cdf (diff) | |
download | CMake-2c7e9b3b59cda840adc2aa4c3bfe1ffa0707be99.zip CMake-2c7e9b3b59cda840adc2aa4c3bfe1ffa0707be99.tar.gz CMake-2c7e9b3b59cda840adc2aa4c3bfe1ffa0707be99.tar.bz2 |
new architecture
Diffstat (limited to 'Source/CursesDialog')
-rw-r--r-- | Source/CursesDialog/ccmake.cxx | 2 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesLongMessageForm.cxx | 4 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.cxx | 122 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesMainForm.h | 9 |
4 files changed, 105 insertions, 32 deletions
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 444eb2c..b852ca7 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -133,7 +133,7 @@ int main(int argc, char** argv) cmCursesForm::CurrentForm = myform; myform->InitializeUI(); - if (myform->RunCMake(false) == 0 ) + if (myform->Configure() == 0 ) { myform->Render(1, 1, x, y); myform->HandleInput(); diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index dd09956..3b4e8d5 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -79,8 +79,8 @@ void cmCursesLongMessageForm::UpdateStatusBar() char version[cmCursesMainForm::MAX_WIDTH]; char vertmp[128]; - sprintf(vertmp,"CMake Version %d.%d - %s", cmMakefile::GetMajorVersion(), - cmMakefile::GetMinorVersion(),cmMakefile::GetReleaseVersion()); + sprintf(vertmp,"CMake Version %d.%d - %s", cmake::GetMajorVersion(), + cmake::GetMinorVersion(),cmake::GetReleaseVersion()); int sideSpace = (width-strlen(vertmp)); for(int i=0; i<sideSpace; i++) { version[i] = ' '; } sprintf(version+sideSpace, "%s", vertmp); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index cbdc535..cd4aff2 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -47,6 +47,12 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args, m_HelpMessage.push_back(""); m_HelpMessage.push_back(s_ConstHelpMessage); m_CMakeInstance = new cmake; + + // create the arguments for the cmake object + std::string whereCMake = cmSystemTools::GetProgramPath(m_Args[0].c_str()); + whereCMake += "/cmake"; + m_Args[0] = whereCMake; + m_CMakeInstance->SetArgs(m_Args); } cmCursesMainForm::~cmCursesMainForm() @@ -362,11 +368,15 @@ void cmCursesMainForm::PrintKeys() cw = reinterpret_cast<cmCursesWidget*>(field_userptr(currentField)); } - if (cw && cw->PrintKeys()) + if (cw) { + cw->PrintKeys(); } - else - { + +// { +// } +// else +// { char firstLine[512], secondLine[512], thirdLine[512]; if (m_OkToGenerate) { @@ -374,7 +384,7 @@ void cmCursesMainForm::PrintKeys() } else { - sprintf(firstLine, "Press [c] to configure"); + sprintf(firstLine, "Press [c] to configure "); } if (m_AdvancedMode) { @@ -404,7 +414,7 @@ void cmCursesMainForm::PrintKeys() curses_move(0,65-strlen(firstLine)-1); printw(firstLine); } - } +// } pos_form_cursor(m_Form); @@ -504,8 +514,8 @@ void cmCursesMainForm::UpdateStatusBar() // We want to display this on the right char version[cmCursesMainForm::MAX_WIDTH]; char vertmp[128]; - sprintf(vertmp,"CMake Version %d.%d - %s", cmMakefile::GetMajorVersion(), - cmMakefile::GetMinorVersion(),cmMakefile::GetReleaseVersion()); + sprintf(vertmp,"CMake Version %d.%d - %s", cmake::GetMajorVersion(), + cmake::GetMinorVersion(),cmake::GetReleaseVersion()); int sideSpace = (width-strlen(vertmp)); for(i=0; i<sideSpace; i++) { version[i] = ' '; } sprintf(version+sideSpace, "%s", vertmp); @@ -521,7 +531,7 @@ void cmCursesMainForm::UpdateStatusBar() pos_form_cursor(m_Form); } -int cmCursesMainForm::RunCMake(bool generateMakefiles) +int cmCursesMainForm::Configure() { int x,y; @@ -532,33 +542,21 @@ int cmCursesMainForm::RunCMake(bool generateMakefiles) touchwin(stdscr); refresh(); endwin(); - std::cerr << "Running CMake, please wait...\n\r"; + std::cerr << "Configuring, please wait...\n\r"; - // free the old cmake and create a new one here - if (this->m_CMakeInstance) - { - delete this->m_CMakeInstance; - this->m_CMakeInstance = 0; - } - this->m_CMakeInstance = new cmake; // always save the current gui values to disk this->FillCacheManagerFromUI(); this->m_CMakeInstance->GetCacheManager()->SaveCache( cmSystemTools::GetCurrentWorkingDirectory().c_str()); - // create the arguments for the cmake object - std::string whereCMake = cmSystemTools::GetProgramPath(m_Args[0].c_str()); - whereCMake += "/cmake"; - - m_Args[0] = whereCMake; - + // Get rid of previous errors m_Errors = std::vector<std::string>(); // run the generate process m_OkToGenerate = true; - int retVal = this->m_CMakeInstance->Generate(m_Args, generateMakefiles); + int retVal = this->m_CMakeInstance->Configure(m_Args[0].c_str(), &m_Args); initscr(); /* Initialization */ noecho(); /* Echo off */ @@ -591,7 +589,6 @@ int cmCursesMainForm::RunCMake(bool generateMakefiles) CurrentForm = this; this->Render(1,1,x,y); } - this->InitializeUI(); this->Render(1, 1, x, y); @@ -599,6 +596,64 @@ int cmCursesMainForm::RunCMake(bool generateMakefiles) return 0; } +int cmCursesMainForm::Generate() +{ + m_CMakeInstance->Generate(); + + int x,y; + getmaxyx(stdscr, y, x); + + curses_clear(); + curses_move(1,1); + touchwin(stdscr); + refresh(); + endwin(); + std::cerr << "Generating, please wait...\n\r"; + + // Get rid of previous errors + m_Errors = std::vector<std::string>(); + + // run the generate process + int retVal = this->m_CMakeInstance->Generate(); + + initscr(); /* Initialization */ + noecho(); /* Echo off */ + cbreak(); /* nl- or cr not needed */ + keypad(stdscr,TRUE); /* Use key symbols as + KEY_DOWN*/ + + if( retVal != 0 || !m_Errors.empty()) + { + // see if there was an error + if(cmSystemTools::GetErrorOccuredFlag()) + { + m_OkToGenerate = false; + } + // reset error condition + cmSystemTools::ResetErrorOccuredFlag(); + int x,y; + getmaxyx(stdscr, y, x); + cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(m_Errors, + "Errors which during last pass."); + CurrentForm = msgs; + msgs->Render(1,1,x,y); + msgs->HandleInput(); + // If they typed the wrong source directory, we report + // an error and exit + if ( retVal == -2 ) + { + return retVal; + } + CurrentForm = this; + this->Render(1,1,x,y); + } + + this->InitializeUI(); + this->Render(1, 1, x, y); + + return 0; +} + void cmCursesMainForm::AddError(const char* message, const char*) { m_Errors.push_back(message); @@ -693,7 +748,19 @@ void cmCursesMainForm::HandleInput() currentField)); // Ask the current widget if it wants to handle input - if (!currentWidget || !currentWidget->HandleInput(key, this, stdscr)) + bool widgetHandled; + + if (currentWidget) + { + widgetHandled = currentWidget->HandleInput(key, this, stdscr); + if (widgetHandled) + { + m_OkToGenerate = false; + this->UpdateStatusBar(); + this->PrintKeys(); + } + } + if (!currentWidget || !widgetHandled) { // If the current widget does not want to handle input, // we handle it. @@ -762,7 +829,7 @@ void cmCursesMainForm::HandleInput() // configure else if ( key == 'c' ) { - this->RunCMake(false); + this->Configure(); } // display help else if ( key == 'h' ) @@ -834,13 +901,14 @@ void cmCursesMainForm::HandleInput() { if ( m_OkToGenerate ) { - this->RunCMake(true); + this->Generate(); break; } } // delete cache entry else if ( key == 'd' ) { + m_OkToGenerate = false; FIELD* cur = current_field(m_Form); int index = field_index(cur); diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index d6e8074..6c2b380 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -84,9 +84,14 @@ public: virtual void AddError(const char* message, const char* title); /** - * Used to run cmake. + * Used to do a configure. */ - int RunCMake(bool generateMakefiles); + int Configure(); + + /** + * Used to generate + */ + int Generate(); /** * Used by main program |