2002-01-21 23:30:43 +03:00
|
|
|
/*=========================================================================
|
|
|
|
|
2002-10-24 02:03:27 +04:00
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
2002-01-21 23:30:43 +03:00
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
2002-10-24 02:03:27 +04:00
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
2002-01-21 23:30:43 +03:00
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
2001-11-05 16:37:22 +03:00
|
|
|
#include "../cmCacheManager.h"
|
|
|
|
#include "../cmSystemTools.h"
|
2001-11-30 00:44:22 +03:00
|
|
|
#include "../cmake.h"
|
2001-11-05 02:05:21 +03:00
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
2001-11-14 17:56:33 +03:00
|
|
|
#include "cmCursesMainForm.h"
|
|
|
|
|
|
|
|
#include <curses.h>
|
|
|
|
#include <form.h>
|
|
|
|
|
2001-11-30 00:44:22 +03:00
|
|
|
cmCursesForm* cmCursesForm::CurrentForm=0;
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2002-06-11 17:14:19 +04:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
|
2002-06-19 01:20:07 +04:00
|
|
|
void onsig(int)
|
2001-11-05 02:05:21 +03:00
|
|
|
{
|
2001-11-30 00:44:22 +03:00
|
|
|
if (cmCursesForm::CurrentForm)
|
2001-11-05 02:05:21 +03:00
|
|
|
{
|
|
|
|
endwin();
|
2001-11-30 18:54:04 +03:00
|
|
|
initscr(); /* Initialization */
|
2001-11-05 02:05:21 +03:00
|
|
|
noecho(); /* Echo off */
|
|
|
|
cbreak(); /* nl- or cr not needed */
|
|
|
|
keypad(stdscr,TRUE); /* Use key symbols as
|
2002-10-24 02:03:27 +04:00
|
|
|
KEY_DOWN*/
|
2001-11-05 02:05:21 +03:00
|
|
|
refresh();
|
|
|
|
int x,y;
|
2001-11-30 00:44:22 +03:00
|
|
|
getmaxyx(stdscr, y, x);
|
|
|
|
cmCursesForm::CurrentForm->Render(1,1,x,y);
|
|
|
|
cmCursesForm::CurrentForm->UpdateStatusBar();
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
signal(SIGWINCH, onsig);
|
|
|
|
}
|
2002-06-11 17:14:19 +04:00
|
|
|
|
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2002-09-18 22:18:43 +04:00
|
|
|
void CMakeErrorHandler(const char* message, const char* title, bool&, void* clientData)
|
2001-11-30 00:44:22 +03:00
|
|
|
{
|
2002-09-18 22:18:43 +04:00
|
|
|
cmCursesForm* self = static_cast<cmCursesForm*>( clientData );
|
|
|
|
self->AddError(message, title);
|
2001-11-30 00:44:22 +03:00
|
|
|
}
|
|
|
|
|
2001-11-05 02:05:21 +03:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2001-12-04 19:16:04 +03:00
|
|
|
bool debug = false;
|
2001-11-30 00:44:22 +03:00
|
|
|
unsigned int i;
|
2001-11-30 18:58:23 +03:00
|
|
|
int j;
|
2001-11-30 00:44:22 +03:00
|
|
|
cmake msg;
|
|
|
|
std::vector<std::string> args;
|
2001-11-30 18:58:23 +03:00
|
|
|
for(j =0; j < argc; ++j)
|
2001-11-30 00:44:22 +03:00
|
|
|
{
|
2001-12-04 19:16:04 +03:00
|
|
|
if(strcmp(argv[j], "-debug") == 0)
|
|
|
|
{
|
|
|
|
debug = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
args.push_back(argv[j]);
|
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2002-05-07 19:03:56 +04:00
|
|
|
std::string cacheDir = cmSystemTools::GetCurrentWorkingDirectory();
|
2001-11-30 00:44:22 +03:00
|
|
|
for(i=1; i < args.size(); ++i)
|
2001-11-05 02:05:21 +03:00
|
|
|
{
|
2001-11-30 00:44:22 +03:00
|
|
|
std::string arg = args[i];
|
2002-05-07 19:03:56 +04:00
|
|
|
if(arg.find("-B",0) == 0)
|
|
|
|
{
|
|
|
|
cacheDir = arg.substr(2);
|
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
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-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
|
2001-11-30 00:44:22 +03:00
|
|
|
cmSystemTools::DisableRunCommandOutput();
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2001-12-04 19:16:04 +03:00
|
|
|
if (debug)
|
|
|
|
{
|
|
|
|
cmCursesForm::DebugStart();
|
|
|
|
}
|
|
|
|
|
2001-11-30 18:54:04 +03:00
|
|
|
initscr(); /* Initialization */
|
2001-11-05 02:05:21 +03: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-30 00:44:22 +03:00
|
|
|
getmaxyx(stdscr, y, x);
|
|
|
|
if ( x < cmCursesMainForm::MIN_WIDTH ||
|
|
|
|
y < cmCursesMainForm::MIN_HEIGHT )
|
2001-11-06 06:10:52 +03:00
|
|
|
{
|
2001-11-30 00:44:22 +03:00
|
|
|
endwin();
|
|
|
|
std::cerr << "Window is too small. A size of at least "
|
2002-10-24 02:03:27 +04:00
|
|
|
<< cmCursesMainForm::MIN_WIDTH << " x "
|
|
|
|
<< cmCursesMainForm::MIN_HEIGHT
|
|
|
|
<< " is required to run ccmake." << std::endl;
|
2001-11-30 00:44:22 +03:00
|
|
|
return 1;
|
2001-11-06 06:10:52 +03:00
|
|
|
}
|
2001-11-30 00:44:22 +03:00
|
|
|
|
|
|
|
|
|
|
|
cmCursesMainForm* myform;
|
|
|
|
|
2002-05-01 19:34:27 +04:00
|
|
|
myform = new cmCursesMainForm(args, x);
|
2002-08-29 00:35:54 +04:00
|
|
|
myform->LoadCache(cacheDir.c_str());
|
2001-11-30 00:44:22 +03:00
|
|
|
|
2002-09-18 22:18:43 +04:00
|
|
|
cmSystemTools::SetErrorCallback(CMakeErrorHandler, myform);
|
2001-11-30 00:44:22 +03:00
|
|
|
|
|
|
|
cmCursesForm::CurrentForm = myform;
|
|
|
|
|
|
|
|
myform->InitializeUI();
|
2002-09-06 21:00:12 +04:00
|
|
|
if (myform->Configure() == 0 )
|
2002-04-24 00:16:48 +04:00
|
|
|
{
|
|
|
|
myform->Render(1, 1, x, y);
|
|
|
|
myform->HandleInput();
|
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
|
|
|
// Need to clean-up better
|
2001-11-30 19:34:13 +03:00
|
|
|
curses_clear();
|
2001-11-30 00:44:22 +03:00
|
|
|
touchwin(stdscr);
|
2001-11-05 02:05:21 +03:00
|
|
|
endwin();
|
2001-11-30 00:44:22 +03:00
|
|
|
delete cmCursesForm::CurrentForm;
|
|
|
|
cmCursesForm::CurrentForm = 0;
|
|
|
|
|
2001-12-06 19:49:16 +03:00
|
|
|
std::cout << std::endl << std::endl;
|
|
|
|
|
2001-11-05 02:05:21 +03:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|