"Fossies" - the Fresh Open Source Software Archive

Member "devtodo-0.1.20/src/todoterm.cc" (28 Jun 2007, 851 Bytes) of package /linux/privat/old/devtodo-0.1.20.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "todoterm.cc" see the Fossies "Dox" file reference documentation.

    1 #include "config.h"
    2 #include "todoterm.h"
    3 
    4 #ifdef USETERMCAP
    5 #include <iostream>
    6 #include <string>
    7 #include <stdexcept>
    8 #include <curses.h>
    9 #include <term.h>
   10 
   11 static char info[2048];
   12 static bool term_initialized;
   13 
   14 using namespace std;
   15 
   16 int getWidth() {
   17     if (!term_initialized) {
   18     char const *termtype = getenv("TERM");
   19         if (!termtype) {
   20             cerr << "can't get terminal type, defaulting to vt100." << endl;
   21             cerr << "please set the TERM env variable." << endl;
   22             setenv("TERM", "vt100", 0);
   23         }
   24     int result = tgetent(info, getenv("TERM"));
   25         if (result < 0)
   26             throw runtime_error("could not access termcap database");
   27         if (result == 0)
   28             throw runtime_error(string(string("unknown terminal type '") + termtype + "'").c_str());
   29         term_initialized = true;
   30     }
   31     return tgetnum(const_cast<char*>("co"));
   32 }
   33 #else
   34 
   35 int getWidth() { return 80; }
   36 
   37 #endif