Added debugging.

This commit is contained in:
Berk Geveci 2001-12-04 11:16:04 -05:00
parent cb4f04c94e
commit d42ded5b16
6 changed files with 81 additions and 1 deletions

View File

@ -38,13 +38,21 @@ void CMakeErrorHandler(const char* message, const char* title, bool& disable)
int main(int argc, char** argv)
{
bool debug = false;
unsigned int i;
int j;
cmake msg;
std::vector<std::string> args;
for(j =0; j < argc; ++j)
{
args.push_back(argv[j]);
if(strcmp(argv[j], "-debug") == 0)
{
debug = true;
}
else
{
args.push_back(argv[j]);
}
}
for(i=1; i < args.size(); ++i)
@ -64,6 +72,11 @@ int main(int argc, char** argv)
cmCacheManager::GetInstance()->LoadCache(cmSystemTools::GetCurrentWorkingDirectory().c_str());
if (debug)
{
cmCursesForm::DebugStart();
}
initscr(); /* Initialization */
noecho(); /* Echo off */
cbreak(); /* nl- or cr not needed */

View File

@ -1,5 +1,8 @@
#include "cmCursesForm.h"
std::ofstream cmCursesForm::DebugFile;
bool cmCursesForm::Debug = false;
cmCursesForm::cmCursesForm()
{
m_Form = 0;
@ -14,3 +17,30 @@ cmCursesForm::~cmCursesForm()
m_Form = 0;
}
}
void cmCursesForm::DebugStart()
{
cmCursesForm::Debug = true;
cmCursesForm::DebugFile.open("ccmakelog.txt");
}
void cmCursesForm::DebugEnd()
{
if (!cmCursesForm::Debug)
{
return;
}
cmCursesForm::Debug = false;
cmCursesForm::DebugFile.close();
}
void cmCursesForm::LogMessage(const char* msg)
{
if (!cmCursesForm::Debug)
{
return;
}
cmCursesForm::DebugFile << msg << std::endl;
}

View File

@ -1,6 +1,7 @@
#ifndef __cmCursesForm_h
#define __cmCursesForm_h
#include "../cmStandardIncludes.h"
#include "cmCursesStandardIncludes.h"
class cmCursesForm
@ -22,13 +23,31 @@ public:
// The only exception is during a resize.
virtual void UpdateStatusBar() = 0;
// Description:
// During a CMake run, an error handle should add errors
// to be displayed afterwards.
virtual void AddError(const char* message, const char* title) {};
// Description:
// Turn debugging on. This will create ccmakelog.txt.
static void DebugStart();
// Description:
// Turn debugging off. This will close ccmakelog.txt.
static void DebugEnd();
// Description:
// Write a debugging message.
static void LogMessage(const char* msg);
static cmCursesForm* CurrentForm;
protected:
static std::ofstream DebugFile;
static bool Debug;
cmCursesForm(const cmCursesForm& from);
void operator=(const cmCursesForm&);

View File

@ -156,10 +156,15 @@ void cmCursesLongMessageForm::HandleInput()
return;
}
char debugMessage[128];
while(1)
{
int key = getch();
sprintf(debugMessage, "Message widget handling input, key: %d", key);
cmCursesForm::LogMessage(debugMessage);
// quit
if ( key == 'o' )
{

View File

@ -539,6 +539,9 @@ void cmCursesMainForm::HandleInput()
FIELD* currentField;
cmCursesWidget* currentWidget;
char debugMessage[128];
while(1)
{
this->UpdateStatusBar();
@ -551,6 +554,8 @@ void cmCursesMainForm::HandleInput()
if (!currentWidget || !currentWidget->HandleInput(key, m_Form, stdscr))
{
sprintf(debugMessage, "Main form handling input, key: %d", key);
cmCursesForm::LogMessage(debugMessage);
// quit
if ( key == 'q' )
{

View File

@ -1,4 +1,6 @@
#include "cmCursesStringWidget.h"
#include "cmCursesForm.h"
inline int ctrl(int z)
{
return (z&037);
@ -26,9 +28,13 @@ bool cmCursesStringWidget::HandleInput(int& key, FORM* form, WINDOW* w)
char* originalStr=0;
char debugMessage[128];
// <Enter> is used to change edit mode (like <Esc> in vi).
while(1)
{
sprintf(debugMessage, "String widget handling input, key: %d", key);
cmCursesForm::LogMessage(debugMessage);
// If resize occured during edit, move out of edit mode
if (!m_InEdit && ( key != 10 && key != KEY_ENTER ) )
{
@ -39,6 +45,7 @@ bool cmCursesStringWidget::HandleInput(int& key, FORM* form, WINDOW* w)
{
if (m_InEdit)
{
cmCursesForm::LogMessage("String widget leaving edit.");
m_InEdit = false;
delete[] originalStr;
// trick to force forms to update the field buffer
@ -48,6 +55,7 @@ bool cmCursesStringWidget::HandleInput(int& key, FORM* form, WINDOW* w)
}
else
{
cmCursesForm::LogMessage("String widget entering edit.");
m_InEdit = true;
char* buf = field_buffer(m_Field, 0);
originalStr = new char[strlen(buf)+1];