Add progress to ccmake
This commit is contained in:
parent
0cb9343e83
commit
1d39833446
@ -353,7 +353,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
|
||||
refresh();
|
||||
}
|
||||
|
||||
void cmCursesMainForm::PrintKeys()
|
||||
void cmCursesMainForm::PrintKeys(int process /* = 0 */)
|
||||
{
|
||||
int x,y;
|
||||
getmaxyx(stdscr, y, x);
|
||||
@ -381,10 +381,24 @@ void cmCursesMainForm::PrintKeys()
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
char firstLine[512], secondLine[512], thirdLine[512];
|
||||
char firstLine[512]="";
|
||||
char secondLine[512]="";
|
||||
char thirdLine[512]="";
|
||||
if (process)
|
||||
{
|
||||
sprintf(firstLine,
|
||||
" ");
|
||||
sprintf(secondLine,
|
||||
" ");
|
||||
sprintf(thirdLine,
|
||||
" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_OkToGenerate)
|
||||
{
|
||||
sprintf(firstLine, "Press [c] to configure Press [g] to generate and exit");
|
||||
sprintf(firstLine,
|
||||
"Press [c] to configure Press [g] to generate and exit");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -399,11 +413,16 @@ void cmCursesMainForm::PrintKeys()
|
||||
sprintf(thirdLine, "Press [t] to toggle advanced mode (Currently Off)");
|
||||
}
|
||||
|
||||
sprintf(secondLine, "Press [h] for help Press [q] to quit without generating");
|
||||
|
||||
sprintf(secondLine,
|
||||
"Press [h] for help Press [q] to quit without generating");
|
||||
}
|
||||
|
||||
curses_move(y-4,0);
|
||||
char fmt[] = "Press [enter] to edit option";
|
||||
char *fmt = "Press [enter] to edit option";
|
||||
if ( process )
|
||||
{
|
||||
fmt = " ";
|
||||
}
|
||||
printw(fmt);
|
||||
curses_move(y-3,0);
|
||||
printw(firstLine);
|
||||
@ -426,7 +445,7 @@ void cmCursesMainForm::PrintKeys()
|
||||
|
||||
// Print the key of the current entry and the CMake version
|
||||
// on the status bar. Designed for a width of 80 chars.
|
||||
void cmCursesMainForm::UpdateStatusBar()
|
||||
void cmCursesMainForm::UpdateStatusBar(const char* message)
|
||||
{
|
||||
int x,y;
|
||||
getmaxyx(stdscr, y, x);
|
||||
@ -500,6 +519,25 @@ void cmCursesMainForm::UpdateStatusBar()
|
||||
width = cmCursesMainForm::MAX_WIDTH;
|
||||
}
|
||||
|
||||
if ( message )
|
||||
{
|
||||
curField = message;
|
||||
curFieldLen = strlen(message);
|
||||
if ( curFieldLen < width )
|
||||
{
|
||||
strcpy(bar, curField);
|
||||
for(i=curFieldLen; i < width; ++i)
|
||||
{
|
||||
bar[i] = ' ';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(bar, curField, width);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (curFieldLen >= width)
|
||||
{
|
||||
strncpy(bar, curField, width);
|
||||
@ -523,9 +561,12 @@ void cmCursesMainForm::UpdateStatusBar()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bar[width] = '\0';
|
||||
|
||||
|
||||
// Display CMake version info on the next line
|
||||
// We want to display this on the right
|
||||
char version[cmCursesMainForm::MAX_WIDTH];
|
||||
@ -540,14 +581,14 @@ void cmCursesMainForm::UpdateStatusBar()
|
||||
// Now print both lines
|
||||
curses_move(y-5,0);
|
||||
attron(A_STANDOUT);
|
||||
printw(bar);
|
||||
printw("%s", bar);
|
||||
attroff(A_STANDOUT);
|
||||
curses_move(y-4,0);
|
||||
printw(version);
|
||||
pos_form_cursor(m_Form);
|
||||
}
|
||||
|
||||
void cmCursesMainForm::UpdateProgress(const char *msg, float prog, void*)
|
||||
void cmCursesMainForm::UpdateProgressOld(const char *msg, float prog, void*)
|
||||
{
|
||||
if ( prog < 0 )
|
||||
{
|
||||
@ -555,18 +596,41 @@ void cmCursesMainForm::UpdateProgress(const char *msg, float prog, void*)
|
||||
}
|
||||
}
|
||||
|
||||
void cmCursesMainForm::UpdateProgress(const char *msg, float prog, void* vp)
|
||||
{
|
||||
cmCursesMainForm* cm = static_cast<cmCursesMainForm*>(vp);
|
||||
if ( !cm )
|
||||
{
|
||||
return;
|
||||
}
|
||||
char tmp[1024];
|
||||
const char *cmsg = tmp;
|
||||
if ( prog >= 0 )
|
||||
{
|
||||
sprintf(tmp, "%s %i%%",msg,(int)(100*prog));
|
||||
}
|
||||
else
|
||||
{
|
||||
cmsg = msg;
|
||||
}
|
||||
cm->UpdateStatusBar(cmsg);
|
||||
cm->PrintKeys(1);
|
||||
curses_move(1,1);
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
}
|
||||
|
||||
int cmCursesMainForm::Configure()
|
||||
{
|
||||
|
||||
int xi,yi;
|
||||
getmaxyx(stdscr, yi, xi);
|
||||
|
||||
curses_clear();
|
||||
curses_move(1,1);
|
||||
this->UpdateStatusBar("Configuring, please wait...");
|
||||
this->PrintKeys(1);
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
endwin();
|
||||
std::cerr << "Configuring, please wait...\n\r";
|
||||
this->m_CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, this);
|
||||
|
||||
// always save the current gui values to disk
|
||||
@ -583,9 +647,6 @@ int cmCursesMainForm::Configure()
|
||||
int retVal = this->m_CMakeInstance->Configure();
|
||||
this->m_CMakeInstance->SetProgressCallback(0, 0);
|
||||
|
||||
initscr(); /* Initialization */
|
||||
noecho(); /* Echo off */
|
||||
cbreak(); /* nl- or cr not needed */
|
||||
keypad(stdscr,TRUE); /* Use key symbols as
|
||||
KEY_DOWN*/
|
||||
|
||||
@ -626,12 +687,11 @@ int cmCursesMainForm::Generate()
|
||||
int xi,yi;
|
||||
getmaxyx(stdscr, yi, xi);
|
||||
|
||||
curses_clear();
|
||||
curses_move(1,1);
|
||||
this->UpdateStatusBar("Generating, please wait...");
|
||||
this->PrintKeys(1);
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
endwin();
|
||||
std::cerr << "Generating, please wait...\n\r";
|
||||
this->m_CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, this);
|
||||
|
||||
// Get rid of previous errors
|
||||
@ -641,9 +701,6 @@ int cmCursesMainForm::Generate()
|
||||
int retVal = this->m_CMakeInstance->Generate();
|
||||
|
||||
this->m_CMakeInstance->SetProgressCallback(0, 0);
|
||||
initscr(); /* Initialization */
|
||||
noecho(); /* Echo off */
|
||||
cbreak(); /* nl- or cr not needed */
|
||||
keypad(stdscr,TRUE); /* Use key symbols as
|
||||
KEY_DOWN*/
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "cmCursesStandardIncludes.h"
|
||||
|
||||
class cmCursesCacheEntryComposite;
|
||||
class cmCursesWidget;
|
||||
class cmake;
|
||||
|
||||
/** \class cmCursesMainForm
|
||||
@ -65,17 +66,21 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* This method should normally called only by the form.
|
||||
* The only exception is during a resize.
|
||||
* This method should normally be called only by the form. The only
|
||||
* exception is during a resize. The optional argument specifies the
|
||||
* string to be displayed in the status bar.
|
||||
*/
|
||||
virtual void UpdateStatusBar();
|
||||
virtual void UpdateStatusBar() { this->UpdateStatusBar(0); }
|
||||
virtual void UpdateStatusBar(const char* message);
|
||||
|
||||
/**
|
||||
* Display current commands and their keys on the toolbar.
|
||||
* This method should normally called only by the form.
|
||||
* The only exception is during a resize.
|
||||
* Display current commands and their keys on the toolbar. This
|
||||
* method should normally called only by the form. The only
|
||||
* exception is during a resize. If the optional argument process is
|
||||
* specified and is either 1 (configure) or 2 (generate), then keys
|
||||
* will be displayed accordingly.
|
||||
*/
|
||||
void PrintKeys();
|
||||
void PrintKeys(int process = 0);
|
||||
|
||||
/**
|
||||
* During a CMake run, an error handle should add errors
|
||||
@ -101,6 +106,7 @@ public:
|
||||
/**
|
||||
* Progress callback
|
||||
*/
|
||||
static void UpdateProgressOld(const char *msg, float prog, void*);
|
||||
static void UpdateProgress(const char *msg, float prog, void*);
|
||||
|
||||
protected:
|
||||
|
Loading…
x
Reference in New Issue
Block a user