Change "color" int option to "no-background-color" bool option.
This commit is contained in:
		
							parent
							
								
									0ce1526c81
								
							
						
					
					
						commit
						da9a59649f
					
				
							
								
								
									
										9
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								README
									
									
									
									
									
								
							| @ -80,10 +80,11 @@ | |||||||
| 
 | 
 | ||||||
| ** Usage | ** Usage | ||||||
|    #+begin_src text |    #+begin_src text | ||||||
|    usage: ttysolitaire [-v|--version] [-h|--help] [-p|--passes=NUMBER] |    usage: ./ttysolitaire [OPTIONS] | ||||||
|    -v, --version  Show version |      -v, --version              Show version | ||||||
|    -h, --help     Show this message |      -h, --help                 Show this message | ||||||
|    -p, --passes   Number of passes through the deck |      -p, --passes               Number of passes through the deck  (default: 3) | ||||||
|  |          --no-background-color  Don't draw background color        (default: false) | ||||||
|    #+end_src |    #+end_src | ||||||
| 
 | 
 | ||||||
| ** Development | ** Development | ||||||
|  | |||||||
| @ -23,17 +23,17 @@ int main(int argc, char *argv[]) { | |||||||
|   int option; |   int option; | ||||||
|   int option_index; |   int option_index; | ||||||
|   int passes_through_deck = 3; |   int passes_through_deck = 3; | ||||||
|   int color = 1; |   static int no_background_color; | ||||||
|   static const struct option options[] = { |   static const struct option options[] = { | ||||||
|       {"help", no_argument, NULL, 'h'}, |       {"help", no_argument, NULL, 'h'}, | ||||||
|       {"version", no_argument, NULL, 'v'}, |       {"version", no_argument, NULL, 'v'}, | ||||||
|       {"passes", required_argument, NULL, 'p'}, |       {"passes", required_argument, NULL, 'p'}, | ||||||
|       {"color", required_argument, NULL, 'c'}, |       {"no-background-color", no_argument, &no_background_color, 1}, | ||||||
|       {0, 0, 0, 0}}; |       {0, 0, 0, 0}}; | ||||||
| 
 | 
 | ||||||
|   program_name = argv[0]; |   program_name = argv[0]; | ||||||
| 
 | 
 | ||||||
|   while ((option = getopt_long(argc, argv, "hvpc:", options, &option_index)) != |   while ((option = getopt_long(argc, argv, "hvp:", options, &option_index)) != | ||||||
|          -1) { |          -1) { | ||||||
|     switch (option) { |     switch (option) { | ||||||
|     case 'v': |     case 'v': | ||||||
| @ -42,10 +42,11 @@ int main(int argc, char *argv[]) { | |||||||
|     case 'p': |     case 'p': | ||||||
|       passes_through_deck = atoi(optarg); |       passes_through_deck = atoi(optarg); | ||||||
|       break; |       break; | ||||||
|     case 'c': |  | ||||||
|       color = atoi(optarg) > 0 ? 1 : 0; |  | ||||||
|       break; |  | ||||||
|     case 'h': |     case 'h': | ||||||
|  |     case 0: | ||||||
|  |       /* If this option set a "no_argument" flag, do nothing else now. */ | ||||||
|  |       if (options[option_index].flag != 0) | ||||||
|  |         break; | ||||||
|     default: |     default: | ||||||
|       usage(program_name); |       usage(program_name); | ||||||
|       exit(0); |       exit(0); | ||||||
| @ -60,10 +61,10 @@ int main(int argc, char *argv[]) { | |||||||
|   start_color(); |   start_color(); | ||||||
|   curs_set(FALSE); |   curs_set(FALSE); | ||||||
|   set_escdelay(0); |   set_escdelay(0); | ||||||
|   if (color) { |   if (no_background_color) { | ||||||
|     assume_default_colors(COLOR_WHITE, COLOR_GREEN); |  | ||||||
|   } else { |  | ||||||
|     use_default_colors(); |     use_default_colors(); | ||||||
|  |   } else { | ||||||
|  |     assume_default_colors(COLOR_WHITE, COLOR_GREEN); | ||||||
|   } |   } | ||||||
|   init_pair(1, COLOR_BLACK, COLOR_WHITE); |   init_pair(1, COLOR_BLACK, COLOR_WHITE); | ||||||
|   init_pair(2, COLOR_RED, COLOR_WHITE); |   init_pair(2, COLOR_RED, COLOR_WHITE); | ||||||
| @ -129,13 +130,13 @@ void draw_greeting() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void usage(const char *program_name) { | void usage(const char *program_name) { | ||||||
|   printf("usage: %s [-v|--version] [-h|--help] [-p|--passes=NUMBER]\n", |   printf("usage: %s [OPTIONS]\n", program_name); | ||||||
|          program_name); |   printf("  -v, --version              Show version\n"); | ||||||
|   printf("  -v, --version  Show version\n"); |   printf("  -h, --help                 Show this message\n"); | ||||||
|   printf("  -h, --help     Show this message\n"); |   printf("  -p, --passes               Number of passes through the deck  " | ||||||
|   printf("  -p, --passes   Number of passes through the deck\n"); |          "(default: 3)\n"); | ||||||
|   printf("  -c, --color    1 (default) - use suggested colors\n"); |   printf("      --no-background-color  Don't draw background color        " | ||||||
|   printf("                 0 - use terminal colors\n"); |          "(default: false)\n"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void version() { printf("%s\n", VERSION); } | void version() { printf("%s\n", VERSION); } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user