win32vt100.cxx

Go to the documentation of this file.
00001 // @(#)root/editline:$Id: win32vt100.cxx 30440 2009-09-25 10:48:50Z rdm $
00002 // Author: Axel Naumann, 2009
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "win32vt100.h"
00013 #include <set>
00014 #include <cstring>
00015 #include <stdarg.h>
00016 #include <stdio.h>
00017 #include <strings.h>
00018 
00019 char*
00020 tigetstr(const char* cap) {
00021    // We support reset, set foreground, set bold, reset to default.
00022    // The escape sequence is \027 plus the capability string
00023    // plus ",parameter" for setf.
00024    static const char opts[] = "\027oc\000\027setaf%d\000\027bold\000\027sgr0\000";
00025    const char* o = opts;
00026    const char* p = 0;
00027 
00028    while (*o && !(p = strstr(o + 1, cap))) {
00029       o += strlen(o) + 1;
00030    }
00031 
00032    if (*o && p) {
00033       return (char*) p - 1;
00034    }
00035    return 0;
00036 } // tigetstr
00037 
00038 
00039 typedef int (*PutcFunc_t)(int);
00040 int
00041 tputs(const char* what, int, PutcFunc_t myputc) {
00042    if (!what || !(*what)) {
00043       return 1;
00044    }
00045    const char* c = what;
00046 
00047    while (*c)
00048       (*myputc)(*(c++));
00049    return c - what;
00050 }
00051 
00052 
00053 char*
00054 tparm(const char* termstr, ...) {
00055    if (termstr[0] != '\027') {
00056       return 0;
00057    }
00058 
00059    switch (termstr[2]) {
00060    case 'c': {
00061       // SetTermToNormal
00062       break;
00063    }
00064    case 'e': {
00065       // Set color
00066       va_list vl;
00067       va_start(vl, termstr);
00068 
00069       va_arg(vl, int);
00070       va_end(vl);
00071       // set color i
00072       break;
00073    }
00074    case 'o': {
00075       // bold
00076       break;
00077    }
00078    case 'g': {
00079       // reset
00080       break;
00081    }
00082    } // switch
00083    return (char*) "";
00084 } // tparm
00085 
00086 
00087 int
00088 setupterm(const char* /*term*/, int /*fd*/, int* errcode) {
00089    if (errcode) {
00090       *errcode = 0;
00091    }
00092    return !ERR;
00093 }
00094 
00095 
00096 int
00097 win32vt100_putc(int c) {
00098    return putc(c, stdout);
00099 }

Generated on Tue Jul 5 14:11:39 2011 for ROOT_528-00b_version by  doxygen 1.5.1