Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

qscr.cpp

00001 #include "qscr.h"
00002 #include <iostream>
00003 
00004 #ifdef CURSES
00005 #include <ncurses.h>
00006 #include <curses.h>
00007 #endif
00008 
00009 void qinit() {
00010 #ifdef CURSES
00011   (void) initscr();      /* initialize the curses library */
00012   keypad(stdscr, TRUE);  /* enable keyboard mapping */
00013   (void) nonl();         /* tell curses not to do NL->CR/NL on output */
00014   (void) cbreak();       /* take input chars one at a time, no wait for \n */
00015   (void) noecho();       /* don't echo input */
00016 
00017 #else
00018 
00019 #endif
00020 }
00021 
00022 void qend() {
00023 #ifdef CURSES
00024   endwin();
00025 #else
00026 
00027 #endif
00028 }
00029 
00030 void qmvaddstr(unsigned x, unsigned y, char const* st) {
00031 #ifdef CURSES
00032   mvaddstr(x,y,st);
00033   wrefresh(stdscr);
00034 #else 
00035 #ifdef NOOP 
00036   
00037 #else
00038   std::cerr << st << std::endl;
00039 #endif
00040 #endif
00041 }
00042 
00043 void qmove(unsigned x, unsigned y) {
00044 #ifdef CURSES
00045   move(x,y);
00046 #else
00047 
00048 #endif
00049 
00050 }
00051 
00052 char qgetch() {
00053   char res;
00054 #ifdef CURSES
00055   res = getch();
00056 #else  
00057   std::cin >> res;
00058 #endif
00059 
00060   return res;
00061 }
00062 
00063 void qaddstr(char const* st) {
00064 #ifdef CURSES
00065   addstr(st);
00066   wrefresh(stdscr);
00067 #else
00068 #ifdef NOOP 
00069   
00070 #else
00071   std::cerr << st;
00072 #endif
00073 #endif
00074 }
00075 
00076 void qclrtoeol() {
00077 #ifdef CURSES
00078   clrtoeol();
00079   wrefresh(stdscr);
00080 #else
00081 #ifdef NOOP 
00082   
00083 #else
00084   //  std::cerr << std::endl;
00085 #endif
00086 #endif
00087 }
00088 
00089 void qinsertln() {
00090 #ifdef CURSES
00091   insertln();
00092   wrefresh(stdscr);
00093 #else
00094 #ifdef NOOP 
00095   
00096 #else
00097   std::cerr << std::endl;
00098 #endif
00099 #endif
00100 }
00101 
00102 ////////////////////////////////////////////////////////////////////////////////
00103 
00104 
00105 #ifdef TEST
00106 
00107 int main() {
00108   try {
00109     qinit();
00110     qmvaddstr(5,5, "First line placed at coordinates (5,5)");
00111     char c;
00112     std::cin >> c; 
00113     qend();
00114 
00115     
00116     std::cerr << std::endl << "Nu skulle vi gerne være tilbage..." << std::endl;
00117 
00118     
00119 
00120     //    std::cerr << "Nothing to test in qscr.cpp\n";
00121   } catch(std::string const& err) {
00122     std::cerr << err << std::endl;
00123     return 1;
00124   }
00125   return 0;
00126 }
00127 
00128 
00129 #endif//TEST

Generated on Tue Feb 14 16:05:52 2006 for estfunc by doxygen 1.3.6