Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ncursesFrontEnd.cpp

Go to the documentation of this file.
00001 #include "ncursesFrontEnd.h"
00002 
00003 #include <unistd.h>
00004 #include <malloc.h>
00005 
00006 NCursesFrontEnd::NCursesFrontEnd () {
00007 };
00008 
00009 NCursesFrontEnd::NCursesFrontEnd (int argc, char** argv) {
00010     initscr ();
00011     start_color ();
00012     cbreak ();
00013     noecho ();
00014     nonl ();
00015     intrflush (stdscr, FALSE);
00016     keypad (stdscr, TRUE);
00017     curs_set (0);
00018     
00019     init_pair (1, COLOR_WHITE, COLOR_BLUE);
00020     init_pair (2, COLOR_YELLOW, COLOR_BLUE);
00021     init_pair (3, COLOR_BLACK, COLOR_CYAN);
00022     
00023     attron (COLOR_PAIR(1));
00024     attron (A_BOLD);
00025     
00026     border (0,0,0,0,0,0,0,0);
00027     
00028     bkgd (COLOR_PAIR(1));
00029     
00030     attron (COLOR_PAIR(1));
00031     attron (A_BOLD);
00032     
00033     mvaddstr (2,2, "Users connected: ");
00034     mvaddstr (3,2, "Matrices open  : ");
00035     mvaddstr (4,2, "Debug message  : ");
00036 
00037     
00038     for (int i = 0; i < 16; i++) {
00039     oldMsg[i] = (char*) malloc (100);
00040     strcpy (oldMsg[i], " ");
00041     };
00042     
00043     refresh ();
00044 };
00045 
00046 NCursesFrontEnd::~NCursesFrontEnd () {
00047     curs_set (1);
00048     execl ("/usr/bin/reset","");
00049 };
00050     
00051 void    NCursesFrontEnd::update () {
00052     refresh ();
00053 };
00054     
00055 void    NCursesFrontEnd::displayUsers (int users) {
00056     attron (COLOR_PAIR(1));
00057     attron (A_BOLD);
00058     
00059     mvaddstr (2,2, "Users connected:           ");
00060     
00061     attron (COLOR_PAIR(2));
00062     
00063     mvaddch (2,19, (char)(48 + users));
00064     
00065     refresh ();
00066 };
00067 
00068 void    NCursesFrontEnd::displayMatrices (int matrices) {
00069     attron (COLOR_PAIR(1));
00070     attron (A_BOLD);
00071     
00072     mvaddstr (3,2, "Matrices open  :           ");
00073     
00074     attron (COLOR_PAIR(2));
00075     
00076     mvaddch (3,19, (char)(48 + matrices));
00077 
00078     refresh ();
00079 };
00080     
00081 void    NCursesFrontEnd::displayDebugMessage (const char* msg) {
00082     attron (COLOR_PAIR (1));
00083     attron (A_BOLD);
00084     
00085     mvaddstr (4,2, "Debug message  : ");
00086     
00087     for (int i = 15; i > 0; i--) {
00088     strcpy (oldMsg[i], oldMsg[i - 1]);
00089     };
00090 
00091     strcpy (oldMsg[0], msg);
00092         
00093     attron (COLOR_PAIR (3));
00094     
00095     for (int i = 0; i < 16; i++) {
00096     mvaddstr (4 + i,19, clean);
00097     
00098     mvaddstr (4 + i,19, oldMsg[i]);
00099     };
00100     
00101     refresh ();
00102 };

Generated at Sat May 13 13:50:20 2000 for 3Dsia by doxygen 1.1.2 written by Dimitri van Heesch, © 1997-2000