![]() |
00001 // Copyright (C) 2003 Johan Hoffman and Anders Logg. 00002 // Licensed under the GNU GPL Version 2. 00003 00004 #ifndef __CURSES_LOGGER_H 00005 #define __CURSES_LOGGER_H 00006 00007 #ifndef NO_CURSES 00008 00009 #include <curses.h> 00010 00011 #include <dolfin/constants.h> 00012 #include <dolfin/Buffer.h> 00013 #include <dolfin/Progress.h> 00014 #include <dolfin/GenericLogger.h> 00015 00016 namespace dolfin { 00017 00018 class CursesLogger : public GenericLogger { 00019 public: 00020 00021 CursesLogger(); 00022 ~CursesLogger(); 00023 00024 void info (const char* msg); 00025 void debug (const char* msg, const char* location); 00026 void warning (const char* msg, const char* location); 00027 void error (const char* msg, const char* location); 00028 void dassert (const char* msg, const char* location); 00029 void progress(const char* title, const char* label, real p); 00030 00031 void update(); 00032 void quit(); 00033 bool finished(); 00034 00035 void progress_add (Progress* p); 00036 void progress_remove (Progress *p); 00037 void progress_flush (); 00038 00039 private: 00040 00041 enum State { RUNNING, PAUSED, ERROR, ABOUT, HELP, FINISHED, QUIT }; 00042 00043 bool running; // True while running, will remain false when first set to false 00044 bool waiting; // True if waiting for input, ignore alarm 00045 bool updating; // True if we are currently updating, ignore extra calls 00046 00047 State state; // State (what to display) 00048 00049 int lines; // Number of lines 00050 int cols; // Number of columns 00051 int offset; // Start position for buffer (depends on the number of progress bars) 00052 00053 Progress** pbars; // List of progress bars 00054 int* ptimes; // Remaining time to display progress bars 00055 WINDOW *win; // Pointer to the terminal 00056 Buffer buffer; // Buffer 00057 char* guiinfo; // Message from the curses interface (not program) 00058 char* tmp; // Temporary storage 00059 00060 void initColors(); 00061 00062 void updateInternal(); 00063 00064 void updateRunning (char c); 00065 void updatePaused (char c); 00066 void updateError (char c); 00067 void updateAbout (char c); 00068 void updateHelp (char c); 00069 void updateFinished(char c); 00070 00071 void killProgram(); 00072 00073 void setSignals(); 00074 00075 void setInfo(const char* msg); 00076 00077 void clearLines(); 00078 void clearBuffer(); 00079 void clearLine(int line, int col); 00080 00081 bool getYesNo(); 00082 void getAnyKey(); 00083 00084 void drawTitle(); 00085 void drawProgress(); 00086 void drawBuffer(); 00087 void drawAbout(); 00088 void drawHelp(); 00089 void drawInfo(); 00090 void drawCommands(); 00091 00092 void redraw(); 00093 00094 void indent(int _level); 00095 00096 }; 00097 00098 } 00099 00100 #endif 00101 00102 #endif
Documentation automatically generated with Doxygen on 10 Sep 2004.