diff --git a/output.c b/output.c index 0825aa7c8..ab65ecc68 100644 --- a/output.c +++ b/output.c @@ -51,6 +51,8 @@ */ #define COLORS (sizeof(col)/sizeof(wchar_t *)) +static int writeb_internal( char c ); + /** Names of different colors. */ @@ -106,14 +108,14 @@ static char *writestr_buff = 0; The function used for output */ -static int (*out)(char *str) = &writembs; +static int (*out)(char c) = &writeb_internal; static void output_destroy() { free( writestr_buff ); } -void output_set_writer( int (*writer)(char *) ) +void output_set_writer( int (*writer)(char) ) { out = writer; } @@ -141,8 +143,8 @@ void set_color( int c, int c2 ) { c = c2 = FISH_COLOR_NORMAL; if( fg ) - out( tparm( fg, 0 ) ); - out( exit_attribute_mode ); + writembs( tparm( fg, 0 ) ); + writembs( exit_attribute_mode ); return; } @@ -175,7 +177,7 @@ void set_color( int c, int c2 ) Background color changed and is set, so we enter bold mode to make reading easier */ - out( enter_bold_mode ); + writembs( enter_bold_mode ); } if(!bg_set && last_bg_set) { @@ -183,14 +185,14 @@ void set_color( int c, int c2 ) Background color changed and is no longer set, so we exit bold mode */ - out( exit_attribute_mode ); + writembs( exit_attribute_mode ); /* We don't know if exit_attribute_mode resets colors, so we set it to something known. */ if( fg ) { - out( tparm( fg, 0 ) ); + writembs( tparm( fg, 0 ) ); last_color=0; } } @@ -201,8 +203,8 @@ void set_color( int c, int c2 ) if( c==FISH_COLOR_NORMAL ) { if( fg ) - out( tparm( fg, 0 ) ); - out( exit_attribute_mode ); + writembs( tparm( fg, 0 ) ); + writembs( exit_attribute_mode ); last_color2 = FISH_COLOR_NORMAL; } @@ -210,7 +212,7 @@ void set_color( int c, int c2 ) { if( fg ) { - out( tparm( fg, c ) ); + writembs( tparm( fg, c ) ); } } } @@ -223,13 +225,13 @@ void set_color( int c, int c2 ) { if( bg ) { - out( tparm( bg, 0 ) ); + writembs( tparm( bg, 0 ) ); } - out(exit_attribute_mode); + writembs(exit_attribute_mode); if(( last_color != FISH_COLOR_NORMAL ) && fg ) { - out(tparm( fg, last_color )); + writembs(tparm( fg, last_color )); } last_color2 = c2; @@ -238,7 +240,7 @@ void set_color( int c, int c2 ) { if( bg ) { - out( tparm( bg, c2 ) ); + writembs( tparm( bg, c2 ) ); } last_color2 = c2; } @@ -260,30 +262,37 @@ void move_cursor( int steps ) if( steps < 0 ){ for( i=0; i>steps; i--) { - out(cursor_left); + writembs(cursor_left); } } else { for( i=0; i= 0 ) - break; - - if( errno == EINTR ) - continue; - - wperror( L"write" ); - return 1; - } - + for( i=0; i8) - { - writespace( c-8); - } + int i; + + for( i=0; i