root/todo/trunk/src/todoterm.cc

Revision 443, 0.8 kB (checked in by athomas, 1 year ago)

Dev Todo:

  • A few bugfixes.
  • Added XML declaration parsing/saving. This is a stop-gap at best, but will
    hopefully be useful to some.
  • Removed reliance on builtin regex library. Hopefully the completely broken
    version of glibc that instigated the inclusion of it is now out of
    circulation.
  • Fixed a whole bunch of compiler warnings on more recent GCC versions.
Line 
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
Note: See TracBrowser for help on using the browser.