/[ascend]/trunk/base/generic/utilities/ascPrint.c
ViewVC logotype

Diff of /trunk/base/generic/utilities/ascPrint.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 585 by johnpye, Fri Apr 21 10:41:45 2006 UTC revision 586 by johnpye, Thu May 11 00:47:54 2006 UTC
# Line 12  Line 12 
12   *  Copyright 1997, Carnegie Mellon University   *  Copyright 1997, Carnegie Mellon University
13   *   *
14   *  The ASCEND utilities is free software; you can redistribute   *  The ASCEND utilities is free software; you can redistribute
15   *  it and/or modify it under the terms of the GNU General Public License as               *  it and/or modify it under the terms of the GNU General Public License as
16   *  published by the Free Software Foundation; either version 2 of the   *  published by the Free Software Foundation; either version 2 of the
17   *  License, or (at your option) any later version.   *  License, or (at your option) any later version.
18   *   *
# Line 238  int Asc_Putchar( int c ) Line 238  int Asc_Putchar( int c )
238    return Asc_Printf( "%c", c );    return Asc_Printf( "%c", c );
239  }  }
240    
241    static int use_xterm_color = 0;
242    
243    /**
244        Little routine to aid output of XTERM colour codes where supported.
245        Not very efficient, so use sparingly.
246    */
247    int color_on(FILE *f, const char *colorcode){
248        char *term;
249        if(!use_xterm_color){
250            term = getenv("TERM");
251            if(term!=NULL){
252                if(strcmp(term,"msys")==0 || strcmp(term,"xterm")){
253                    use_xterm_color=1;
254                }else{
255                    use_xterm_color=-1;
256                }
257                free(term);
258            }else{
259                use_xterm_color=-1;
260            }
261        }
262    
263        if(colorcode!=NULL && use_xterm_color==1){
264            return fprintf(f,"\033[%sm",colorcode);
265        }
266        return 0;
267    }
268    
269    /**
270        Little routine to aid output of XTERM colour codes where supported.
271        Not very efficient, so use sparingly.
272    */
273    int color_off(FILE *f){
274        if(use_xterm_color==1){
275            return fprintf(f,"\033[0m");
276        }
277        return 0;
278    }

Legend:
Removed from v.585  
changed lines
  Added in v.586

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22