Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

term.h File Reference

Go to the source code of this file.

Defines

#define ESC   0x1b
#define ATTR_RESET   0
#define ATTR_BRIGHT   1
#define ATTR_DIM   2
#define ATTR_UNDER   4
#define ATTR_BLINK   5
#define ATTR_REVER   7
#define ATTR_HIDDEN   8
#define COLOR_BLACK   30
#define COLOR_GRAY   30 | 128
#define COLOR_RED   31
#define COLOR_BRRED   31 | 128
#define COLOR_GREEN   32
#define COLOR_BRGREEN   32 | 128
#define COLOR_BROWN   33
#define COLOR_YELLOW   33 | 128
#define COLOR_BLUE   34
#define COLOR_BRBLUE   34 | 128
#define COLOR_MAGENTA   35
#define COLOR_BRMAGENTA   35 | 128
#define COLOR_CYAN   36
#define COLOR_BRCYAN   36 | 128
#define COLOR_WHITE   37
#define COLOR_BRWHITE   37 | 128

Functions

char * term_color (char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
char * term_prompt (char *outbuf, const char *inbuf, int maxout)
char * term_prep (void)
char * term_end (void)
char * term_quit (void)


Define Documentation

#define ATTR_BLINK   5
 

Definition at line 26 of file term.h.

#define ATTR_BRIGHT   1
 

Definition at line 23 of file term.h.

Referenced by term_color(), term_init(), and term_prompt().

#define ATTR_DIM   2
 

Definition at line 24 of file term.h.

#define ATTR_HIDDEN   8
 

Definition at line 28 of file term.h.

#define ATTR_RESET   0
 

Definition at line 22 of file term.h.

Referenced by term_init().

#define ATTR_REVER   7
 

Definition at line 27 of file term.h.

#define ATTR_UNDER   4
 

Definition at line 25 of file term.h.

#define COLOR_BLACK   30
 

Definition at line 30 of file term.h.

Referenced by ast_frame_dump(), ast_load_resource(), ast_register_translator(), main(), term_color(), term_init(), and term_prompt().

#define COLOR_BLUE   34
 

Definition at line 38 of file term.h.

Referenced by term_prompt().

#define COLOR_BRBLUE   34 | 128
 

Definition at line 39 of file term.h.

#define COLOR_BRCYAN   36 | 128
 

Definition at line 43 of file term.h.

Referenced by ast_frame_dump(), and ast_register_application().

#define COLOR_BRGREEN   32 | 128
 

Definition at line 35 of file term.h.

Referenced by ast_frame_dump().

#define COLOR_BRMAGENTA   35 | 128
 

Definition at line 41 of file term.h.

Referenced by ast_frame_dump().

#define COLOR_BROWN   33
 

Definition at line 36 of file term.h.

Referenced by ast_load_resource(), and term_init().

#define COLOR_BRRED   31 | 128
 

Definition at line 33 of file term.h.

Referenced by ast_frame_dump().

#define COLOR_BRWHITE   37 | 128
 

Definition at line 45 of file term.h.

Referenced by ast_log(), load_modules(), and main().

#define COLOR_CYAN   36
 

Definition at line 42 of file term.h.

#define COLOR_GRAY   30 | 128
 

Definition at line 31 of file term.h.

#define COLOR_GREEN   32
 

Definition at line 34 of file term.h.

#define COLOR_MAGENTA   35
 

Definition at line 40 of file term.h.

Referenced by ast_register_translator().

#define COLOR_RED   31
 

Definition at line 32 of file term.h.

#define COLOR_WHITE   37
 

Definition at line 44 of file term.h.

Referenced by term_color(), term_init(), and term_prompt().

#define COLOR_YELLOW   33 | 128
 

Definition at line 37 of file term.h.

Referenced by ast_frame_dump().

#define ESC   0x1b
 

Definition at line 21 of file term.h.

Referenced by term_color(), term_init(), and term_prompt().


Function Documentation

char* term_color char *  outbuf,
const char *  inbuf,
int  fgcolor,
int  bgcolor,
int  maxout
 

Definition at line 54 of file term.c.

References ATTR_BRIGHT, COLOR_BLACK, COLOR_WHITE, and ESC.

Referenced by ast_frame_dump(), ast_load_resource(), ast_log(), ast_register_application(), ast_register_translator(), load_modules(), and main().

00055 {
00056    int attr=0;
00057    char tmp[40];
00058    if (!vt100compat) {
00059       strncpy(outbuf, inbuf, maxout -1);
00060       return outbuf;
00061    }
00062    if (!fgcolor && !bgcolor) {
00063       strncpy(outbuf, inbuf, maxout - 1);
00064       return outbuf;
00065    }
00066    if ((fgcolor & 128) && (bgcolor & 128)) {
00067       /* Can't both be highlighted */
00068       strncpy(outbuf, inbuf, maxout - 1);
00069       return outbuf;
00070    }
00071    if (!bgcolor)
00072       bgcolor = COLOR_BLACK;
00073 
00074    if (bgcolor) {
00075       bgcolor &= ~128;
00076       bgcolor += 10;
00077    }
00078    if (fgcolor & 128) {
00079       attr = ATTR_BRIGHT;
00080       fgcolor &= ~128;
00081    }
00082    if (fgcolor && bgcolor) {
00083       snprintf(tmp, sizeof(tmp), "%d;%d", fgcolor, bgcolor);
00084    } else if (bgcolor) {
00085       snprintf(tmp, sizeof(tmp), "%d", bgcolor);
00086    } else if (fgcolor) {
00087       snprintf(tmp, sizeof(tmp), "%d", fgcolor);
00088    }
00089    if (attr) {
00090       snprintf(outbuf, maxout, "%c[%d;%sm%s%c[0;%d;%dm", ESC, attr, tmp, inbuf, ESC, COLOR_WHITE, COLOR_BLACK + 10);
00091    } else {
00092       snprintf(outbuf, maxout, "%c[%sm%s%c[0;%d;%dm", ESC, tmp, inbuf, ESC, COLOR_WHITE, COLOR_BLACK + 10);
00093    }
00094    return outbuf;
00095 }

char* term_end void   ) 
 

Definition at line 116 of file term.c.

Referenced by main().

00117 {
00118    return enddata;
00119 }

char* term_prep void   ) 
 

Definition at line 111 of file term.c.

00112 {
00113    return prepdata;
00114 }

char* term_prompt char *  outbuf,
const char *  inbuf,
int  maxout
 

Definition at line 97 of file term.c.

References ATTR_BRIGHT, COLOR_BLACK, COLOR_BLUE, COLOR_WHITE, and ESC.

00098 {
00099    if (!vt100compat) {
00100       strncpy(outbuf, inbuf, maxout -1);
00101       return outbuf;
00102    }
00103    snprintf(outbuf, maxout, "%c[%d;%d;%dm%c%c[%d;%d;%dm%s",
00104       ESC, ATTR_BRIGHT, COLOR_BLUE, COLOR_BLACK + 10,
00105       inbuf[0],
00106       ESC, 0, COLOR_WHITE, COLOR_BLACK + 10,
00107       inbuf + 1);
00108    return outbuf;
00109 }

char* term_quit void   ) 
 

Definition at line 121 of file term.c.

Referenced by main().

00122 {
00123    return quitdata;
00124 }


Generated on Fri Oct 31 07:05:18 2003 for Asterisk by doxygen 1.3.4