From 9992b8eb0e3366ff8a3948aa0b66a19c3c12c737 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 18 Nov 2012 16:30:30 -0800 Subject: Apply new indentation, brace, and whitespace style --- set_color.cpp | 407 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 216 insertions(+), 191 deletions(-) (limited to 'set_color.cpp') diff --git a/set_color.cpp b/set_color.cpp index 4de3ba60..ff8abe17 100644 --- a/set_color.cpp +++ b/set_color.cpp @@ -59,7 +59,7 @@ #define GETOPT_STRING "b:hvocu" #ifdef _ - #undef _ +#undef _ #endif #ifdef USE_GETTEXT @@ -70,74 +70,80 @@ const char *col[]= { - "black", - "red", - "green", - "brown", - "yellow", - "blue", - "magenta", - "purple", - "cyan", - "white", - "normal" + "black", + "red", + "green", + "brown", + "yellow", + "blue", + "magenta", + "purple", + "cyan", + "white", + "normal" }; const int col_idx[]= { - 0, - 1, - 2, - 3, - 3, - 4, - 5, - 5, - 6, - 7, - 8 + 0, + 1, + 2, + 3, + 3, + 4, + 5, + 5, + 6, + 7, + 8 }; void print_colors() { - size_t i; - for( i=0; i(fish_term256); - } else { + } + else + { const char *term = getenv("TERM"); support_term256 = term && strstr(term, "256color"); } - if( !fgcolor && !bgcolor && !bold && !underline ) - { - check_locale_init(); - fprintf( stderr, _("%s: Expected an argument\n"), SET_COLOR ); - print_help( argv[0], 2 ); - return 1; - } + if (!fgcolor && !bgcolor && !bold && !underline) + { + check_locale_init(); + fprintf(stderr, _("%s: Expected an argument\n"), SET_COLOR); + print_help(argv[0], 2); + return 1; + } rgb_color_t fg = rgb_color_t(fgcolor ? fgcolor : ""); - if( fgcolor && fg.is_none()) - { - check_locale_init(); - fprintf( stderr, _("%s: Unknown color '%s'\n"), SET_COLOR, fgcolor ); - return 1; - } + if (fgcolor && fg.is_none()) + { + check_locale_init(); + fprintf(stderr, _("%s: Unknown color '%s'\n"), SET_COLOR, fgcolor); + return 1; + } rgb_color_t bg = rgb_color_t(bgcolor ? bgcolor : ""); - if( bgcolor && bg.is_none()) - { - check_locale_init(); - fprintf( stderr, _("%s: Unknown color '%s'\n"), SET_COLOR, bgcolor ); - return 1; - } - - setupterm( 0, STDOUT_FILENO, 0); - - if( bold ) - { - if( enter_bold_mode ) - putp( enter_bold_mode ); - } - - if( underline ) - { - if( enter_underline_mode ) - putp( enter_underline_mode ); - } - - if( bgcolor ) - { - if( bg.is_normal() ) + if (bgcolor && bg.is_none()) { - write_background_color(0); - putp( tparm(exit_attribute_mode) ); + check_locale_init(); + fprintf(stderr, _("%s: Unknown color '%s'\n"), SET_COLOR, bgcolor); + return 1; } - } - if( fgcolor ) - { - if( fg.is_normal() ) + setupterm(0, STDOUT_FILENO, 0); + + if (bold) { - write_foreground_color(0); - putp( tparm(exit_attribute_mode) ); + if (enter_bold_mode) + putp(enter_bold_mode); } - else + + if (underline) + { + if (enter_underline_mode) + putp(enter_underline_mode); + } + + if (bgcolor) { + if (bg.is_normal()) + { + write_background_color(0); + putp(tparm(exit_attribute_mode)); + } + } + + if (fgcolor) + { + if (fg.is_normal()) + { + write_foreground_color(0); + putp(tparm(exit_attribute_mode)); + } + else + { write_foreground_color(index_for_color(fg)); + } } - } - if( bgcolor ) - { - if( ! bg.is_normal() ) + if (bgcolor) { + if (! bg.is_normal()) + { write_background_color(index_for_color(bg)); + } } - } - if( del_curterm( cur_term ) == ERR ) - { - fprintf( stderr, "%s", _("Error while closing terminfo") ); - } + if (del_curterm(cur_term) == ERR) + { + fprintf(stderr, "%s", _("Error while closing terminfo")); + } } -- cgit v1.2.3