aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/colors.c
diff options
context:
space:
mode:
authorDavid M. Syzdek <syzdek@bindlebinaries.com>2010-09-28 11:02:32 -0800
committerDavid M. Syzdek <syzdek@bindlebinaries.com>2010-09-28 11:02:32 -0800
commit73bfe202fda51a03770ac7fa2477d5cd074e84cc (patch)
treeb302dd51d45b972cabe81a51c87a9450c4d86959 /src/colors.c
parenta82f9f9275ab653ab505347330ca5c7e37389662 (diff)
downloaddmstools-73bfe202fda51a03770ac7fa2477d5cd074e84cc.tar.gz
dmstools-73bfe202fda51a03770ac7fa2477d5cd074e84cc.tar.bz2
dmstools-73bfe202fda51a03770ac7fa2477d5cd074e84cc.tar.xz
dmstools-73bfe202fda51a03770ac7fa2477d5cd074e84cc.zip
Adding ability to turn off additional ANSI codes
Diffstat (limited to 'src/colors.c')
-rw-r--r--src/colors.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/colors.c b/src/colors.c
index 9322671..349b3c8 100644
--- a/src/colors.c
+++ b/src/colors.c
@@ -130,6 +130,7 @@ void colors_usage(void)
130 // line. The two strings referenced are: PROGRAM_NAME, and 130 // line. The two strings referenced are: PROGRAM_NAME, and
131 // PACKAGE_BUGREPORT 131 // PACKAGE_BUGREPORT
132 printf(_("Usage: %s [OPTIONS]\n" 132 printf(_("Usage: %s [OPTIONS]\n"
133 " -c, --colors-only only display escape codes for colors\n"
133 " -h, --help print this help and exit\n" 134 " -h, --help print this help and exit\n"
134 " -V, --version print version number and exit\n" 135 " -V, --version print version number and exit\n"
135 "\n" 136 "\n"
@@ -167,11 +168,13 @@ int main(int argc, char * argv[])
167 int c; 168 int c;
168 int x; 169 int x;
169 int y; 170 int y;
171 int opt;
170 int opt_index; 172 int opt_index;
171 173
172 static char short_opt[] = "hV"; 174 static char short_opt[] = "chV";
173 static struct option long_opt[] = 175 static struct option long_opt[] =
174 { 176 {
177 {"colors-only", no_argument, 0, 'c'},
175 {"help", no_argument, 0, 'h'}, 178 {"help", no_argument, 0, 'h'},
176 {"version", no_argument, 0, 'V'}, 179 {"version", no_argument, 0, 'V'},
177 {NULL, 0, 0, 0 } 180 {NULL, 0, 0, 0 }
@@ -183,6 +186,8 @@ int main(int argc, char * argv[])
183 textdomain (PACKAGE); 186 textdomain (PACKAGE);
184#endif 187#endif
185 188
189 opt = 0;
190
186 while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1) 191 while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1)
187 { 192 {
188 switch(c) 193 switch(c)
@@ -190,6 +195,9 @@ int main(int argc, char * argv[])
190 case -1: /* no more arguments */ 195 case -1: /* no more arguments */
191 case 0: /* long options toggles */ 196 case 0: /* long options toggles */
192 break; 197 break;
198 case 'c':
199 opt = opt | 0x01;
200 break;
193 case 'h': 201 case 'h':
194 colors_usage(); 202 colors_usage();
195 return(0); 203 return(0);
@@ -233,15 +241,18 @@ int main(int argc, char * argv[])
233 printf(" \033[0m\n\033[40m"); 241 printf(" \033[0m\n\033[40m");
234 }; 242 };
235 243
236 // displays different text modifications 244 if (!(opt & 0x01))
237 for(y = 1; y < 10; y++) 245 {
238 printf(" \033[0;40m\033[%i;37;48m%i;37;48m\033[0;40m ", y, y); 246 // displays different text modifications
239 printf(" \033[0m\n\033[40m"); 247 for(y = 1; y < 10; y++)
248 printf(" \033[0;40m\033[%i;37;48m%i;37;48m\033[0;40m ", y, y);
249 printf(" \033[0m\n\033[40m");
240 250
241 // adds row of spaces 251 // adds row of spaces
242 for (x = 0; x < 9; x++) 252 for (x = 0; x < 9; x++)
243 printf(" \033[30;40m "); 253 printf(" \033[30;40m ");
244 printf(" \033[0m\n\033[40m"); 254 printf(" \033[0m\n\033[40m");
255 };
245 256
246 printf("\033[0m\n"); 257 printf("\033[0m\n");
247 258