CMake/Source/CursesDialog/ccurses.cxx

78 lines
1.5 KiB
C++
Raw Normal View History

2001-11-05 02:05:21 +03:00
#include "cmCursesMainForm.h"
#include "../cmCacheManager.h"
#include "../cmSystemTools.h"
2001-11-05 02:05:21 +03:00
#include <curses.h>
#include <form.h>
#include <signal.h>
#include <sys/ioctl.h>
static cmCursesMainForm* myform=0;
void onsig(int sig)
{
if (myform)
{
endwin();
WINDOW* w= initscr(); /* Initialization */
noecho(); /* Echo off */
cbreak(); /* nl- or cr not needed */
keypad(stdscr,TRUE); /* Use key symbols as
KEY_DOWN*/
refresh();
int x,y;
getmaxyx(w, y, x);
myform->SetWindow(w);
myform->Render(1,1,x,y);
2001-11-06 06:10:52 +03:00
myform->UpdateStatusBar();
2001-11-05 02:05:21 +03:00
}
signal(SIGWINCH, onsig);
}
int main(int argc, char** argv)
{
2001-11-06 06:10:52 +03:00
if ( argc > 2 )
2001-11-05 02:05:21 +03:00
{
2001-11-06 06:10:52 +03:00
std::cerr << "Usage: " << argv[0] << " source_directory."
2001-11-05 02:05:21 +03:00
<< std::endl;
return -1;
}
int newCache = false;
if (!cmCacheManager::GetInstance()->LoadCache(cmSystemTools::GetCurrentWorkingDirectory().c_str()))
{
newCache = true;
}
WINDOW* w=initscr(); /* Initialization */
noecho(); /* Echo off */
cbreak(); /* nl- or cr not needed */
keypad(stdscr,TRUE); /* Use key symbols as
KEY_DOWN*/
signal(SIGWINCH, onsig);
int x,y;
getmaxyx(w, y, x);
2001-11-06 06:10:52 +03:00
if ( argc == 2 )
{
2001-11-06 20:03:36 +03:00
myform = new cmCursesMainForm(argv[1], argv[0], newCache);
2001-11-06 06:10:52 +03:00
}
else
{
2001-11-06 20:03:36 +03:00
myform = new cmCursesMainForm("", argv[0], newCache);
2001-11-06 06:10:52 +03:00
}
2001-11-05 02:05:21 +03:00
myform->InitializeUI(w);
myform->Render(1, 1, x, y);
myform->HandleInput();
// Need to clean-up better
endwin();
delete myform;
return 0;
}