Changeset View
Changeset View
Standalone View
Standalone View
bin/ls/ls.c
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | #ifdef COLORLS | ||||
int colorflag = COLORFLAG_NEVER; /* passed in colorflag */ | int colorflag = COLORFLAG_NEVER; /* passed in colorflag */ | ||||
int f_color; /* add type in color for non-regular files */ | int f_color; /* add type in color for non-regular files */ | ||||
bool explicitansi; /* Explicit ANSI sequences, no termcap(5) */ | bool explicitansi; /* Explicit ANSI sequences, no termcap(5) */ | ||||
char *ansi_bgcol; /* ANSI sequence to set background colour */ | char *ansi_bgcol; /* ANSI sequence to set background colour */ | ||||
char *ansi_fgcol; /* ANSI sequence to set foreground colour */ | char *ansi_fgcol; /* ANSI sequence to set foreground colour */ | ||||
char *ansi_coloff; /* ANSI sequence to reset colours */ | char *ansi_coloff; /* ANSI sequence to reset colours */ | ||||
char *attrs_off; /* ANSI sequence to turn off attributes */ | char *attrs_off; /* ANSI sequence to turn off attributes */ | ||||
char *enter_bold; /* ANSI sequence to set color to bold mode */ | char *enter_bold; /* ANSI sequence to set color to bold mode */ | ||||
char *enter_underline; /* ANSI sequence to enter underline mode */ | |||||
#endif | #endif | ||||
static int rval; | static int rval; | ||||
static bool | static bool | ||||
do_color_from_env(void) | do_color_from_env(void) | ||||
{ | { | ||||
const char *p; | const char *p; | ||||
▲ Show 20 Lines • Show All 310 Lines • ▼ Show 20 Lines | #endif | ||||
if (do_color()) { | if (do_color()) { | ||||
#ifdef COLORLS | #ifdef COLORLS | ||||
if ((term = getenv("TERM")) != NULL && | if ((term = getenv("TERM")) != NULL && | ||||
tgetent(termcapbuf, term) == 1) { | tgetent(termcapbuf, term) == 1) { | ||||
ansi_fgcol = tgetstr("AF", &bp); | ansi_fgcol = tgetstr("AF", &bp); | ||||
ansi_bgcol = tgetstr("AB", &bp); | ansi_bgcol = tgetstr("AB", &bp); | ||||
attrs_off = tgetstr("me", &bp); | attrs_off = tgetstr("me", &bp); | ||||
enter_bold = tgetstr("md", &bp); | enter_bold = tgetstr("md", &bp); | ||||
enter_underline = tgetstr("us", &bp); | |||||
/* To switch colours off use 'op' if | /* To switch colours off use 'op' if | ||||
* available, otherwise use 'oc', or | * available, otherwise use 'oc', or | ||||
* don't do colours at all. */ | * don't do colours at all. */ | ||||
ansi_coloff = tgetstr("op", &bp); | ansi_coloff = tgetstr("op", &bp); | ||||
if (!ansi_coloff) | if (!ansi_coloff) | ||||
ansi_coloff = tgetstr("oc", &bp); | ansi_coloff = tgetstr("oc", &bp); | ||||
if (ansi_fgcol && ansi_bgcol && ansi_coloff) | if (ansi_fgcol && ansi_bgcol && ansi_coloff) | ||||
▲ Show 20 Lines • Show All 519 Lines • Show Last 20 Lines |