CMake/Source/CursesDialog/ccmake.cxx

112 lines
2.4 KiB
C++
Raw Normal View History

#include "../cmCacheManager.h"
#include "../cmSystemTools.h"
2001-11-29 21:44:22 +00:00
#include "../cmake.h"
2001-11-04 23:05:21 +00:00
#include <signal.h>
#include <sys/ioctl.h>
#include "cmCursesMainForm.h"
#include <curses.h>
#include <form.h>
2001-11-29 21:44:22 +00:00
cmCursesForm* cmCursesForm::CurrentForm=0;
2001-11-04 23:05:21 +00:00
void onsig(int sig)
{
2001-11-29 21:44:22 +00:00
if (cmCursesForm::CurrentForm)
2001-11-04 23:05:21 +00:00
{
endwin();
2001-11-30 15:54:04 +00:00
initscr(); /* Initialization */
2001-11-04 23:05:21 +00:00
noecho(); /* Echo off */
cbreak(); /* nl- or cr not needed */
keypad(stdscr,TRUE); /* Use key symbols as
KEY_DOWN*/
refresh();
int x,y;
2001-11-29 21:44:22 +00:00
getmaxyx(stdscr, y, x);
cmCursesForm::CurrentForm->Render(1,1,x,y);
cmCursesForm::CurrentForm->UpdateStatusBar();
2001-11-04 23:05:21 +00:00
}
signal(SIGWINCH, onsig);
}
2001-11-29 21:44:22 +00:00
void CMakeErrorHandler(const char* message, const char* title, bool& disable)
{
cmCursesForm::CurrentForm->AddError(message, title);
}
2001-11-04 23:05:21 +00:00
int main(int argc, char** argv)
{
2001-11-29 21:44:22 +00:00
unsigned int i;
cmake msg;
std::vector<std::string> args;
for(i =0; i < argc; ++i)
{
args.push_back(argv[i]);
}
2001-11-04 23:05:21 +00:00
2001-11-29 21:44:22 +00:00
for(i=1; i < args.size(); ++i)
2001-11-04 23:05:21 +00:00
{
2001-11-29 21:44:22 +00:00
std::string arg = args[i];
if(arg.find("-help",0) != std::string::npos ||
arg.find("--help",0) != std::string::npos ||
arg.find("/?",0) != std::string::npos ||
arg.find("-usage",0) != std::string::npos)
{
msg.Usage(args[0].c_str());
return -1;
}
2001-11-04 23:05:21 +00:00
}
2001-11-29 21:44:22 +00:00
cmSystemTools::DisableRunCommandOutput();
2001-11-04 23:05:21 +00:00
2001-11-29 21:44:22 +00:00
cmCacheManager::GetInstance()->LoadCache(cmSystemTools::GetCurrentWorkingDirectory().c_str());
2001-11-04 23:05:21 +00:00
2001-11-30 15:54:04 +00:00
initscr(); /* Initialization */
2001-11-04 23:05:21 +00:00
noecho(); /* Echo off */
cbreak(); /* nl- or cr not needed */
keypad(stdscr,TRUE); /* Use key symbols as
KEY_DOWN*/
signal(SIGWINCH, onsig);
int x,y;
2001-11-29 21:44:22 +00:00
getmaxyx(stdscr, y, x);
if ( x < cmCursesMainForm::MIN_WIDTH ||
y < cmCursesMainForm::MIN_HEIGHT )
2001-11-06 03:10:52 +00:00
{
2001-11-29 21:44:22 +00:00
endwin();
std::cerr << "Window is too small. A size of at least "
<< cmCursesMainForm::MIN_WIDTH << " x "
<< cmCursesMainForm::MIN_HEIGHT
<< " is required to run ccmake." << std::endl;
return 1;
2001-11-06 03:10:52 +00:00
}
2001-11-29 21:44:22 +00:00
cmCursesMainForm* myform;
myform = new cmCursesMainForm(args);
cmSystemTools::SetErrorCallback(CMakeErrorHandler);
cmCursesForm::CurrentForm = myform;
myform->InitializeUI();
myform->RunCMake(false);
2001-11-04 23:05:21 +00:00
myform->Render(1, 1, x, y);
myform->HandleInput();
// Need to clean-up better
2001-11-29 21:44:22 +00:00
clear();
touchwin(stdscr);
2001-11-04 23:05:21 +00:00
endwin();
2001-11-29 21:44:22 +00:00
delete cmCursesForm::CurrentForm;
cmCursesForm::CurrentForm = 0;
2001-11-04 23:05:21 +00:00
return 0;
}