"Fossies" - the Fresh Open Source Software Archive

Member "devtodo-0.1.20/util/Terminal.cc" (9 May 2006, 2136 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 "Terminal.cc" see the Fossies "Dox" file reference documentation.

    1 #include "Terminal.h"
    2 namespace term {
    3 
    4 // this is SUCH a dodgy hack
    5 static bool forcecolour = false;
    6 
    7 void forceColour(bool state) {
    8     forcecolour = state; 
    9 }
   10 
   11 string title(string const &str) {
   12     return string("]0;") + str + "";
   13 }
   14 
   15 string background(Colour colour) {
   16     return string("[4") + str::stringify(colour) + "m";
   17 }
   18 
   19 string foreground(Colour colour) {
   20     return string("[3") + str::stringify(colour) + "m";
   21 }
   22 
   23 string colour(Colour colour) {
   24     return string("[3") + str::stringify(colour) + "m";
   25 }
   26 
   27 string attribute(Attribute attribute) {
   28     return string("[") + str::stringify(attribute) + "m";
   29 }
   30 
   31 ostream &black(ostream &os) {
   32     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   33     return os;
   34 }
   35 
   36 ostream &red(ostream &os) {
   37     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   38     return os;
   39 }
   40 
   41 ostream &green(ostream &os) {
   42     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   43     return os;
   44 }
   45 
   46 ostream &yellow(ostream &os) {
   47     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   48     return os;
   49 }
   50 
   51 ostream &blue(ostream &os) {
   52     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   53     return os;
   54 }
   55 
   56 ostream &magenta(ostream &os) {
   57     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   58     return os;
   59 }
   60 
   61 ostream &cyan(ostream &os) {
   62     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   63     return os;
   64 }
   65 
   66 ostream &white(ostream &os) {
   67     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   68     return os;
   69 }
   70 
   71 ostream &normal(ostream &os) {
   72     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   73     return os;
   74 }
   75 
   76 ostream &bold(ostream &os) {
   77     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   78     return os;
   79 }
   80 
   81 ostream &halfbright(ostream &os) {
   82     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   83     return os;
   84 }
   85 
   86 ostream &underline(ostream &os) {
   87     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   88     return os;
   89 }
   90 
   91 ostream &blink(ostream &os) {
   92     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   93     return os;
   94 }
   95 
   96 ostream &reverse(ostream &os) {
   97     if (&cout == &os && (forcecolour || isatty(1))) os << "";
   98     return os;
   99 }
  100 
  101 }