FreeBSD Bugzilla – Attachment 14585 Details for
Bug 27374
Added bold color to the /bin/ls color support
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 3.69 KB, created by
fracture
on 2001-05-16 08:20:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
fracture
Created:
2001-05-16 08:20:01 UTC
Size:
3.69 KB
patch
obsolete
>--- ls-dist/extern.h Tue Jul 11 23:19:14 2000 >+++ ls/extern.h Tue May 15 23:38:08 2001 >@@ -54,6 +54,8 @@ > void parsecolors __P((char *cs)); > void colorquit __P((int)); > >+extern char *enter_bold; >+extern char *attrs_off; > extern char *ansi_fgcol; > extern char *ansi_bgcol; > extern char *ansi_coloff; >--- ls-dist/ls.c Wed Aug 16 12:57:11 2000 >+++ ls/ls.c Tue May 15 23:38:33 2001 >@@ -116,6 +116,8 @@ > #ifdef COLORLS > int f_color; /* add type in color for non-regular files */ > >+char *enter_bold; /* sequence to set color to bold mode */ >+char *attrs_off; /* sequence to turn off attributes (bold mode, etc) */ > char *ansi_bgcol; /* ANSI sequence to set background colour */ > char *ansi_fgcol; /* ANSI sequence to set foreground colour */ > char *ansi_coloff; /* ANSI sequence to reset colours */ >@@ -282,6 +284,8 @@ > (isatty(STDOUT_FILENO) || getenv("CLICOLOR_FORCE"))) > #ifdef COLORLS > if (tgetent(termcapbuf, getenv("TERM")) == 1) { >+ enter_bold = tgetstr("md", &bp); >+ attrs_off = tgetstr("me", &bp); > ansi_fgcol = tgetstr("AF", &bp); > ansi_bgcol = tgetstr("AB", &bp); > >--- ls-dist/print.c Tue Jul 11 23:19:14 2000 >+++ ls/print.c Tue May 15 23:38:16 2001 >@@ -95,7 +95,12 @@ > > char *defcolors = "4x5x2x3x1x464301060203"; > >-static int colors[C_NUMCOLORS][2]; >+/* colors for file types */ >+static struct { >+ int num[2]; >+ int bold; >+} colors[C_NUMCOLORS]; >+ > #endif > > void >@@ -383,14 +388,17 @@ > { > char *ansiseq; > >- if (colors[c][0] != -1) { >- ansiseq = tgoto(ansi_fgcol, 0, colors[c][0]); >+ if (colors[c].bold) >+ tputs(enter_bold, 1, putch); >+ >+ if (colors[c].num[0] != -1) { >+ ansiseq = tgoto(ansi_fgcol, 0, colors[c].num[0]); > if (ansiseq) > tputs(ansiseq, 1, putch); > } > >- if (colors[c][1] != -1) { >- ansiseq = tgoto(ansi_bgcol, 0, colors[c][1]); >+ if (colors[c].num[1] != -1) { >+ ansiseq = tgoto(ansi_bgcol, 0, colors[c].num[1]); > if (ansiseq) > tputs(ansiseq, 1, putch); > } >@@ -401,6 +409,7 @@ > int sig; > { > tputs(ansi_coloff, 1, sig ? writech : putch); >+ tputs(attrs_off, 1, sig ? writech : putch); > } > > static int >@@ -455,6 +464,8 @@ > if (cs == NULL) cs = ""; /* LSCOLORS not set */ > len = strlen(cs); > for (i = 0 ; i < C_NUMCOLORS ; i++) { >+ colors[i].bold = 0; >+ > if (len <= 2*i) { > c[0] = defcolors[2*i]; > c[1] = defcolors[2*i+1]; >@@ -464,17 +475,52 @@ > c[1] = cs[2*i+1]; > } > for (j = 0 ; j < 2 ; j++) { >+ /* shifted 0-7 (!, @, #, etc) do bold */ > if ((c[j] < '0' || c[j] > '7') && >- tolower((unsigned char)c[j]) != 'x') { >+ tolower((unsigned char)c[j]) != 'x' && >+ c[j] != ')' && c[j] != '!' && c[j] != '@' && >+ c[j] != '#' && c[j] != '$' && c[j] != '%' && >+ c[j] != '^' && c[j] != '&') { > fprintf(stderr, >- "error: invalid character '%c' in LSCOLORS env var\n", >- c[j]); >- c[j] = defcolors[2*i+j]; >+ "error: invalid character '%c' in LSCOLORS" >+ " env var\n", c[j]); >+ c[j] = defcolors[2*i+j]-'0'; >+ } >+ >+ if (c[j] >= '0' && c[j] <= '7') >+ colors[i].num[j] = c[j]-'0'; >+ else if (tolower((unsigned char)c[j] == 'x')) >+ colors[i].num[j] = -1; >+ else { >+ colors[i].bold = 1; >+ >+ switch (c[j]) { >+ case ')': >+ colors[i].num[j] = 0; >+ break; >+ case '!': >+ colors[i].num[j] = 1; >+ break; >+ case '@': >+ colors[i].num[j] = 2; >+ break; >+ case '#': >+ colors[i].num[j] = 3; >+ break; >+ case '$': >+ colors[i].num[j] = 4; >+ break; >+ case '%': >+ colors[i].num[j] = 5; >+ break; >+ case '^': >+ colors[i].num[j] = 6; >+ break; >+ case '&': >+ colors[i].num[j] = 7; >+ break; >+ } > } >- if (tolower((unsigned char)c[j]) == 'x') >- colors[i][j] = -1; >- else >- colors[i][j] = c[j]-'0'; > } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 27374
: 14585