|
|
#include "basicNCursesEngine.h"
basicNCursesEngine* basicNCursesEngine::_instance = NULL;
/**
* Returns the single instance of the object. */basicNCursesEngine* basicNCursesEngine::getInstance() { // check if the instance has been created yet
if ( 0 == _instance) { // if not, then create it
_instance = new basicNCursesEngine; } // return the single instance
return _instance;};
// Constructor implementation
basicNCursesEngine::basicNCursesEngine(){ def_shell_mode(); m_pCursesWin = initscr(); // Start curses mode
if(has_colors() == FALSE){ endwin(); printf("Your terminal does not support color\n"); return; }; noecho(); cbreak(); // Line buffering disabled, Pass on everty thing to me
keypad( m_pCursesWin, TRUE); // I need that nifty F1
nodelay( m_pCursesWin, TRUE); m_pCDKScreen = initCDKScreen( m_pCursesWin );
initCDKColor();
//basicThread::init();
/*
//start_color(); // Start color
//def_prog_mode(); // Save the tty modes
//cbreak(); // Line buffering disabled, Pass on
// everty thing to me
//raw();
//keypad(stdscr, TRUE); // I need that nifty F1
//noecho(); // Don't echo() while we do getch
/*
init_color( COLOR_RED, 700, 0, 0); init_pair(1, COLOR_RED, COLOR_BLACK ); attron( COLOR_PAIR(1) ); //*/
/*char *rTitles[3]={"","",""};
char *cTitles[3]={"","",""}; char filler=' '; int arr[3]={7,7,7}; char *buttons[40]; char *message[40]; message[0] = "<C></U>Simple Command Interface"; message[1] = "Pick the command you wish to run."; message[2] = "<C>Press </R>?<!R> for help."; buttons[0] = "Who"; buttons[1] = "Time"; buttons[2] = "Date"; buttons[3] = "Quit"; /*m_pCDKMatrix = newCDKMatrix (
m_pCDKScreen, LEFT, TOP, 23, 23, 3, 3, "PRU Cores", rTitles, cTitles, arr, arr, 1, 1, filler, COL, true, true, true );*/ /* Create the dialog box. */ /*question = newCDKDialog( m_pCDKScreen, LEFT, CENTER,
message, 3, buttons, 4, A_REVERSE, true, true, true);
/* Check if we got a null value back. */ /*if( question == (CDKDIALOG *)NULL)
{ destroyCDKScreen (m_pCDKScreen);
// End curses...
endCDK();
// Spit out a message.
printf ("Oops. Can't seem to create the dialog box. Is the window too small?\n"); exit (1); } else { drawCDKDialog( question, true ); } */ CDKLABEL *demo = NULL; char *mesg[4];
//cdkscreen = initCDKScreen (NULL);
//if( cdkscreen == NULL ) {
// printf("CDK Screen Youk!\n");
//return;
//}
/* Start CDK Colors */ //initCDKColor();
/* Set the labels up. */ mesg[0] = "</31>This line should have a yellow foreground and a cyan background.<!31>"; mesg[1] = "</05>This line should have a white foreground and a blue background.<!05>"; mesg[2] = "</26>This line should have a yellow foreground and a red background.<!26>"; mesg[3] = "<C>This line should be set to whatever the screen default is."; /* Set the labels up. */ //mesg[0] = "<C><#UL><#HL(26)><#UR>";
//mesg[1] = "<C><#VL></R>This text should be boxed.<!R><#VL>";
//mesg[2] = "<C><#LL><#HL(26)><#LR>";
//mesg[3] = "<C>While this is not.";
/* Declare the labels. */ //demo = newCDKLabel( m_pCDKScreen, 0, 0, mesg, 4, false, false );
/* Draw the label */ //drawCDKLabel( demo, TRUE);
//waitCDKLabel( demo, ' ');
/* Clean up */ //destroyCDKLabel (demo);
};
// Destructor implementation
basicNCursesEngine::~basicNCursesEngine(){ //destroyCDKDialog (question);
m_bThreadStatus = TH_ENDED; destroyCDKScreen( m_pCDKScreen ); m_pCDKScreen = NULL; endCDK(); delwin( m_pCursesWin ); m_pCursesWin = NULL; endwin(); // End curses mode
echo();};
bool basicNCursesEngine::attachWindow( WindowCLI *wnd ){ m_vWindowPool.push_back( wnd ); wnd->paint(); return true;};
void basicNCursesEngine::m_fThreadProc( void ){ int counter = 0; int ch; m_bThreadStatus = TH_WORKING; while( m_bThreadStatus < TH_ENDED ) { while((ch = getch()) != KEY_F(1) ) { switch(ch){ case KEY_LEFT: //MyCurses->destroy_win(my_win);
//my_win = MyCurses->create_win(height, width, starty,--startx);
break; case KEY_RIGHT: //MyCurses->destroy_win(my_win);
//my_win = MyCurses->create_win(height, width, starty,++startx);
break; case KEY_UP: //MyCurses->destroy_win(my_win);
//my_win = MyCurses->create_win(height, width, --starty,startx);
break; case KEY_DOWN: //MyCurses->destroy_win(my_win);
//my_win = MyCurses->create_win(height, width, ++starty,startx);
break; }; }; if( m_vWindowPool.size() > 0 ) { for( WIN_ITERATOR index = m_vWindowPool.begin(); index < m_vWindowPool.end(); index++ ) { (*index)->paint(); }; }; #ifdef __linux__
usleep( DEFAULT_THREAD_SLEEP_TIME ); #else
Sleep(10); #endif
mvwprintw( m_pCursesWin , 30,2, "%d\n", counter++ ); };};
//void basicNCursesEngine::
|