curses_stub.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // Copyright 2002, Lowell Boggs Jr.
00004 //
00005 // This file or directory, containing source code for a computer program,
00006 // is Copyrighted by Lowell Boggs, Jr.  987 Regency Drive, Lewisville
00007 // TX (USA), 75067.  You may use, copy, modify, and distribute this
00008 // source file without charge or obligation so long as you agree to
00009 // the following:
00010 //
00011 //  1.  You must indemnify Lowell Boggs against any and all financial
00012 //      obligations caused by its use, misuse, function, or malfunction.
00013 //      Further, you acknowledge that there is no warranty of any kind,
00014 //      whatsoever.
00015 //
00016 //  2.  You agree not to attempt to patent any portion of this original
00017 //      work -- though you may attempt to patent your own extensions to
00018 //      it if you so choose.
00019 //
00020 //  3.  You keep this copyright notice with the file and all copies
00021 //      of the file and do not change it anyway except language translation.
00022 //
00023 // You are responsible for enforcing your own compliance with these
00024 // conditions and may not use this source file if you cannot agree to the
00025 // above terms and conditions.
00026 
00027 
00028 
00029 //@File
00030 //
00034 
00035 #include <iostream>
00036 
00037 #include <cxxtls/cursesinterface.h>
00038 
00039 using namespace std;
00040 using namespace cxxtls;
00041 
00042 namespace cxxtls
00043 {
00044 
00045 namespace CursesInterface
00046 {
00047   bool winch_occurred = false;
00048   bool resize_requested = false;
00049 
00050   int row;
00051   int col;
00052 
00053   int att;
00054 
00055   void openCursesTerminal()
00056   {
00057     std::cout << "opening terminal" << std::endl;
00058   }
00059 
00060   void closeCursesTerminal()
00061   {
00062     std::cout << "closing terminal" << std::endl;
00063   }
00064 
00065   int mapCursesKey(int curses_key)  // map to CursorWindow key representation
00066   {
00067     return curses_key;
00068   }
00069 
00070   void getCursesCursor(int *row, int *col)
00071   {
00072     *row = CursesInterface::row;
00073     *col = CursesInterface::col;
00074   }
00075 
00076   void getCursesScreenSize(int *row, int *col)
00077   {
00078     *row = 25;
00079     *col = 80;
00080   }
00081 
00082 
00083   void setCursesAttributes( int a )
00084   {
00085     CursesInterface::att = a;
00086   }
00087 
00088 
00089   void paintCharString(char const *r, int count, int a, int row, int col)
00090   {
00091       std::cout << "paintCharString(\"";
00092 
00093       std::cout.write(r, count);
00094 
00095       std::cout << "\", " << count << ", " << a << ", " << row << ", " << col << ")" << std::endl;
00096 
00097       setCursesAttributes(a);
00098 
00099       moveCursesCursor(row,col);
00100 
00101       while(count--)
00102           {
00103               ++CursesInterface::row;
00104               ++r;
00105           }
00106   }
00107 
00108   void paintCharString(long c, int count, int a, int row, int col)
00109   {
00110       std::cout << "paintCharString('" << (char)(c) ;
00111       std::cout << "', " << count << ", " << a << ", " << row << ", " << col << ")" << std::endl;
00112 
00113       setCursesAttributes(a);
00114 
00115       moveCursesCursor(row,col);
00116 
00117       while(count--)
00118           {
00119               ++CursesInterface::col;
00120           }
00121   }
00122 
00123 
00124 
00125   void refreshCursesWindow()
00126   {
00127   }
00128 
00129   void beepCursesTerminal()
00130   {
00131   }
00132 
00133 
00134   void moveCursesCursor(int row, int col)
00135   {
00136     CursesInterface::row = row;
00137     CursesInterface::col = col;
00138 
00139     std::cout << "moveCursesCursor(" << row << ", " << col << ")" << std::endl;
00140   }
00141 
00142 
00143   void make_xterm_terminfo_file(FileName const &dir)
00144   {
00145   }
00146 
00147     void create_key_sequences_map()
00148     {
00149     }
00150 
00151 
00152     int alarm_occurred=0;
00153 
00154     int read_key_char()
00155       // return a 'char' to the user -- or a 0 that indicates the alarm
00156       // timer fired.
00157     {
00158        return ' ';
00159     }
00160 
00161 
00162     int read_mapped_key(CursorWindow &w)
00163       //
00164       // read a key from the keyboard and handle function key sequences
00165       //
00166     {
00167       static int eof_counter=0;
00168 
00169       if(std::cin.eof())
00170       {
00171          //
00172          // when encountering an eof situation, alternate between
00173          // return escape and ' ' -- most of my tests expect ' ' to
00174          // terminate them and others require escp.
00175          //
00176          ++eof_counter;
00177         
00178          if(eof_counter & 1)
00179            return ' ';
00180          else
00181            return 0x1b;
00182       }
00183 
00184       return std::cin.get();
00185 
00186     }
00187 
00188   long line_chars[lcCOUNT];
00189   mouse_info read_mouse_info() { return mouse_info(0,0,0); } // not yet implemented
00190 
00191 };
00192 
00193 }
Generated on Wed Feb 29 22:50:05 2012 for CXXUtilities by  doxygen 1.6.3