Use plgin support in output.c to make buffered pager output - noticably faster printing in many situations

darcs-hash:20060216142159-ac50b-2c31025be7d12fcc32f4ba352b59ea4cc3cc1387.gz
This commit is contained in:
axel 2006-02-17 00:21:59 +10:00
parent cfa367f14c
commit 95a01f3c8f

View file

@ -76,6 +76,7 @@ static struct termios pager_modes;
static int is_ca_mode = 0; static int is_ca_mode = 0;
static buffer_t *pager_buffer;
/** /**
The environment variables used to specify the color of different The environment variables used to specify the color of different
@ -216,6 +217,20 @@ static wint_t readch()
return input_common_readch(0); return input_common_readch(0);
} }
static int pager_buffered_writer( char c)
{
b_append( pager_buffer, &c, 1 );
return 0;
}
static void pager_flush()
{
write( 1, pager_buffer->buff, pager_buffer->used );
pager_buffer->used = 0;
}
static int print_max( const wchar_t *str, int max, int has_more ) static int print_max( const wchar_t *str, int max, int has_more )
{ {
int i; int i;
@ -239,7 +254,7 @@ static int print_max( const wchar_t *str, int max, int has_more )
static void completion_print_item( const wchar_t *prefix, comp_t *c, int width ) static void completion_print_item( const wchar_t *prefix, comp_t *c, int width )
{ {
int comp_width, desc_width; int comp_width=0, desc_width=0;
int i; int i;
int written=0; int written=0;
@ -507,6 +522,7 @@ static int completion_try_print( int cols,
} }
completion_print( cols, width, 0, rows, prefix, is_quoted, l); completion_print( cols, width, 0, rows, prefix, is_quoted, l);
pager_flush();
} }
else else
{ {
@ -539,6 +555,7 @@ static int completion_try_print( int cols,
percent ); percent );
writestr(msg); writestr(msg);
set_color( FISH_COLOR_NORMAL, FISH_COLOR_NORMAL ); set_color( FISH_COLOR_NORMAL, FISH_COLOR_NORMAL );
pager_flush();
int c = readch(); int c = readch();
switch( c ) switch( c )
@ -860,6 +877,9 @@ static void init()
halloc_util_init(); halloc_util_init();
env_universal_init( 0, 0, 0, 0); env_universal_init( 0, 0, 0, 0);
input_common_init( &interrupt_handler ); input_common_init( &interrupt_handler );
output_set_writer( &pager_buffered_writer );
pager_buffer = halloc( global_context, sizeof( buffer_t ) );
halloc_register_function( global_context, (void (*)(void *))&b_destroy, pager_buffer );
sigemptyset( & act.sa_mask ); sigemptyset( & act.sa_mask );
act.sa_flags=0; act.sa_flags=0;