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 56 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().

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

char* term_end void   ) 
 

Definition at line 118 of file term.c.

Referenced by main().

00119 {
00120    return enddata;
00121 }

char* term_prep void   ) 
 

Definition at line 113 of file term.c.

00114 {
00115    return prepdata;
00116 }

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

Definition at line 99 of file term.c.

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

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

char* term_quit void   ) 
 

Definition at line 123 of file term.c.

Referenced by main().

00124 {
00125    return quitdata;
00126 }


Generated on Sun Apr 18 23:34:18 2004 for Asterisk by doxygen 1.3.6-20040222