diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:47 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:47 +0200 |
| commit | d4c9f10efe815af146438cafb694d16da0e5650a (patch) | |
| tree | 93956195c448768b2d58892cb672bee36a6a6463 /src/ncur | |
| parent | ee315a27b72dc967a8a90f132725b7c8e4fd9fba (diff) | |
tagging ychat-0.7.0ychat-0.7.0
Diffstat (limited to 'src/ncur')
| -rwxr-xr-x | src/ncur/menu.cpp | 11 | ||||
| -rwxr-xr-x | src/ncur/menu.h | 7 | ||||
| -rwxr-xr-x | src/ncur/ncur.cpp | 43 | ||||
| -rwxr-xr-x | src/ncur/ncur.h | 18 |
4 files changed, 30 insertions, 49 deletions
diff --git a/src/ncur/menu.cpp b/src/ncur/menu.cpp index 3243df9..c5734a5 100755 --- a/src/ncur/menu.cpp +++ b/src/ncur/menu.cpp @@ -6,9 +6,8 @@ #ifndef MENU_CPP #define MENU_CPP -using namespace std; -menu::menu( int i_startx, int i_starty, int i_width, int i_height, char *c_header, char **choices, int i_numchoices, const chtype ch ) +using namespace std; menu::menu( int i_startx, int i_starty, int i_width, int i_height, char *c_header, char **choices, int i_numchoices, const chtype ch ) { this->i_startx = i_startx; this->i_starty = i_starty; @@ -51,17 +50,16 @@ menu::display() box( win, 0, 0 ); mvwprintw( win, y++, x, "%s", c_header ); - for( i = 0; i < i_numchoices; i++ ) + for( i=0; i<i_numchoices; i++ ) { - ++y; + y++; - if( i_highlight == i+1 ) // Highlight the current selection. + if( i_highlight == i + 1 ) /* High light the present choice */ { wattron( win, A_REVERSE); mvwprintw( win, y, x, "%d. %s", i, choices[i]); wattroff( win, A_REVERSE); } - else { mvwprintw( win, y, x, "%d. %s", i, choices[i]); @@ -109,6 +107,7 @@ menu::start( void (*swich_case_menu_action)(int) ) break; } + // Menu action. ( *swich_case_menu_action ) ( i_choice ); i_choice = 0; diff --git a/src/ncur/menu.h b/src/ncur/menu.h index d931be3..7e4fc5b 100755 --- a/src/ncur/menu.h +++ b/src/ncur/menu.h @@ -1,7 +1,6 @@ #include "../incl.h" #ifdef NCURSES - #ifndef MENU_H #define MENU_H @@ -28,11 +27,7 @@ public: void display(); void start( void (*swich_case_menu_action)(int) ); - - void activate_menu_win() - { - keypad(win, 1); - } + void activate_menu_win() { keypad(win, 1); } }; #endif diff --git a/src/ncur/ncur.cpp b/src/ncur/ncur.cpp index 9da9488..fa91a74 100755 --- a/src/ncur/ncur.cpp +++ b/src/ncur/ncur.cpp @@ -35,10 +35,8 @@ ncur::start( void *p_void ) ncur::init_ncurses(); char *choices[] = { - "Unload all modules ", //<< - "Reload all modules ", //<< - //>>" ", - //>>" ", + "Unload all modules ", + "Reload all modules ", "Clear template cache ", "Run garbage collector ", //<< //>>" ", @@ -46,14 +44,13 @@ ncur::start( void *p_void ) "Compile changed sources ", "Recompile all sources ", "Show source stats ", - "Command line interface ", - //<<* + "Command Line Interface ", #ifdef DATABASE - "Close DB connections ", + "Disconnect from DB ", //<< #else - " ", + " ", //<< #endif - //*>> + //>>" ", "Shut down server" }; @@ -65,20 +62,21 @@ ncur::start( void *p_void ) mvwprintw( p_serveroutput, 2, 2, NCURMSG ); wrefresh ( p_serveroutput ); - print( string("yChat ") + VERSION ); + print( VERSION ); p_menu = new menu( 1, 1, 30, 19, NCURADM, choices, 11, COLOR_PAIR(1)); - mvprintw(NCUR_SERVER_HEADER_X,NCUR_SERVER_HEADER_Y, NCURSE0); - mvprintw(NCUR_POOL_HEADER_X,NCUR_POOL_HEADER_Y, NCURSE1); - mvprintw(NCUR_DATA_HEADER_X,NCUR_DATA_HEADER_Y, NCURSE2); //<< - mvprintw(NCUR_CHAT_HEADER_X,NCUR_CHAT_HEADER_Y, NCURSE3); //<< - mvprintw(NCUR_CACHED_HEADER_X,NCUR_CACHED_HEADER_Y, NCURSE4); - + mvprintw( NCUR_SERVER_HEADER_X,NCUR_SERVER_HEADER_Y, "HTTP server:"); + mvprintw( NCUR_POOL_HEADER_X,NCUR_POOL_HEADER_Y, "Thread pool:"); +#ifdef DATABASE + mvprintw( NCUR_DATA_HEADER_X,NCUR_DATA_HEADER_Y, "Data stats:"); //<< +#endif + mvprintw( NCUR_CHAT_HEADER_X,NCUR_CHAT_HEADER_Y, "Chat stats:"); //<< + mvprintw( NCUR_CACHED_HEADER_X,NCUR_CACHED_HEADER_Y, "Caching:"); wrap::HTML->print_cached(0); - is_ready(true); + is_ready( true ); wrap::SMAN->print_init_ncurses(); //<< wrap::STAT->print_num_rooms(); //<< @@ -121,10 +119,8 @@ ncur::print( char* c_print ) int i; char* c_temp = new char[i_message_length]; memcpy( c_temp, c_print, strlen(c_print) ); - - for ( i = strlen(c_print); i < i_message_length; ++i ) + for ( i = strlen(c_print); i < i_message_length; i++ ) c_temp[i] = ' '; - c_temp[i] = '\0'; pthread_mutex_lock( &mut_messages ); @@ -133,7 +129,7 @@ ncur::print( char* c_print ) { char* c_front = p_messagelist->front(); p_messagelist->pop_front(); - free(c_front); + free( c_front ); } p_messagelist->push_back( c_temp ); @@ -144,7 +140,7 @@ ncur::print( char* c_print ) list<char*>::iterator iter; iter = p_messagelist->begin(); - for ( i = 4; i < 18 && iter != p_messagelist->end(); ++i, ++iter ) + for ( i=4; i<18 && iter != p_messagelist->end(); i++, iter++ ) mvwprintw( p_serveroutput, i, 2, *iter ); wrefresh ( p_serveroutput ); @@ -161,7 +157,6 @@ ncur::switch_main_menu_( int i_choice ) if( i_choice != 0 ) switch ( i_choice ) { - //<<* case 1: wrap::MODL->unload_modules(); mvprintw( 20,2, "Unloaded all modules "); @@ -172,7 +167,6 @@ ncur::switch_main_menu_( int i_choice ) mvprintw( 20,2, "Reloaded all modules "); refresh(); break; - //*>> case 3: wrap::HTML->clear_cache(); mvprintw( 20,2, "Cleared the template cache "); @@ -280,6 +274,5 @@ ncur::is_ready() pthread_mutex_unlock( &mut_is_ready ); return b_ret; } - #endif #endif diff --git a/src/ncur/ncur.h b/src/ncur/ncur.h index 53849d0..692a48a 100755 --- a/src/ncur/ncur.h +++ b/src/ncur/ncur.h @@ -1,10 +1,8 @@ #include "../incl.h" #ifdef NCURSES - #ifndef NCUR_H #define NCUR_H - #include <ncurses.h> #include <list> @@ -19,12 +17,11 @@ private: menu* p_menu; WINDOW* p_serveroutput; list<char*>* p_messagelist; // contains the messages for p_serveroutput! + pthread_mutex_t mut_messages; // for syncronization of p_serveroutput! int i_message_length; // the maximum length of a system message! - bool b_is_ready; // is set to TRUE if the admin interface is initialized. + bool b_is_ready; // is set to TRUE if the admin interface is initialized. static void init_ncurses(); static void close_ncurses(); - - pthread_mutex_t mut_messages; pthread_mutex_t mut_is_ready; public: @@ -32,18 +29,15 @@ public: ~ncur( ); void start( void *p_void ); - void print( char* c_print ); - void print( string s_msg ); - void print( string* p_msg ); + virtual void print( char* c_print ); + virtual void print( string s_msg ); + virtual void print( string* p_msg ); void is_ready( bool b_is_ready ); bool is_ready(); static void switch_main_menu_( int i_choice ); void shutdown(); - void activate_menu_win() - { - p_menu->activate_menu_win(); - } + { p_menu->activate_menu_win(); } }; #endif |
