summaryrefslogtreecommitdiffstats
path: root/Source/CursesDialog/ccmake.cxx
diff options
context:
space:
mode:
authorBerk Geveci <berk.geveci@kitware.com>2001-11-29 21:44:22 (GMT)
committerBerk Geveci <berk.geveci@kitware.com>2001-11-29 21:44:22 (GMT)
commit521d8d9410c7c7bb5958357933c9759035f51828 (patch)
treebe128f3ce5a15f3aedd02601de35a2018cbc6cbc /Source/CursesDialog/ccmake.cxx
parente57a982136f654e21607ce8db0d890dfd65a0878 (diff)
downloadCMake-521d8d9410c7c7bb5958357933c9759035f51828.zip
CMake-521d8d9410c7c7bb5958357933c9759035f51828.tar.gz
CMake-521d8d9410c7c7bb5958357933c9759035f51828.tar.bz2
Improvements to the curses interface.
Diffstat (limited to 'Source/CursesDialog/ccmake.cxx')
-rw-r--r--Source/CursesDialog/ccmake.cxx84
1 files changed, 57 insertions, 27 deletions
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index 61e50e2..e47e382 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -1,5 +1,6 @@
#include "../cmCacheManager.h"
#include "../cmSystemTools.h"
+#include "../cmake.h"
#include <signal.h>
#include <sys/ioctl.h>
@@ -9,11 +10,11 @@
#include <curses.h>
#include <form.h>
-static cmCursesMainForm* myform=0;
+cmCursesForm* cmCursesForm::CurrentForm=0;
void onsig(int sig)
{
- if (myform)
+ if (cmCursesForm::CurrentForm)
{
endwin();
WINDOW* w= initscr(); /* Initialization */
@@ -23,30 +24,44 @@ void onsig(int sig)
KEY_DOWN*/
refresh();
int x,y;
- getmaxyx(w, y, x);
- myform->SetWindow(w);
- myform->Render(1,1,x,y);
- myform->UpdateStatusBar();
+ getmaxyx(stdscr, y, x);
+ cmCursesForm::CurrentForm->Render(1,1,x,y);
+ cmCursesForm::CurrentForm->UpdateStatusBar();
}
signal(SIGWINCH, onsig);
}
+void CMakeErrorHandler(const char* message, const char* title, bool& disable)
+{
+ cmCursesForm::CurrentForm->AddError(message, title);
+}
+
int main(int argc, char** argv)
{
+ unsigned int i;
+ cmake msg;
+ std::vector<std::string> args;
+ for(i =0; i < argc; ++i)
+ {
+ args.push_back(argv[i]);
+ }
- if ( argc > 2 )
+ for(i=1; i < args.size(); ++i)
{
- std::cerr << "Usage: " << argv[0] << " source_directory."
- << std::endl;
- return -1;
+ 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;
+ }
}
- int newCache = false;
- if (!cmCacheManager::GetInstance()->LoadCache(cmSystemTools::GetCurrentWorkingDirectory().c_str()))
- {
- newCache = true;
- }
+ cmSystemTools::DisableRunCommandOutput();
+ cmCacheManager::GetInstance()->LoadCache(cmSystemTools::GetCurrentWorkingDirectory().c_str());
WINDOW* w=initscr(); /* Initialization */
noecho(); /* Echo off */
@@ -57,25 +72,40 @@ int main(int argc, char** argv)
signal(SIGWINCH, onsig);
int x,y;
- getmaxyx(w, y, x);
- std::string whereCMake = cmSystemTools::GetProgramPath(argv[0]);
- whereCMake += "/cmake";
- if ( argc == 2 )
+ getmaxyx(stdscr, y, x);
+ if ( x < cmCursesMainForm::MIN_WIDTH ||
+ y < cmCursesMainForm::MIN_HEIGHT )
{
-
- myform = new cmCursesMainForm(argv[1], whereCMake.c_str(), newCache);
- }
- else
- {
- myform = new cmCursesMainForm("", whereCMake.c_str(), newCache);
+ 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;
}
- myform->InitializeUI(w);
+
+
+ cmCursesMainForm* myform;
+
+ myform = new cmCursesMainForm(args);
+
+ cmSystemTools::SetErrorCallback(CMakeErrorHandler);
+
+ cmCursesForm::CurrentForm = myform;
+
+ myform->InitializeUI();
+ myform->RunCMake(false);
+
myform->Render(1, 1, x, y);
myform->HandleInput();
// Need to clean-up better
+ clear();
+ touchwin(stdscr);
endwin();
- delete myform;
+ delete cmCursesForm::CurrentForm;
+ cmCursesForm::CurrentForm = 0;
+
return 0;
}