Attached is a patch which changes fish_pager so that It can take input
about completions to display on stdin.
Currently, completions are sent to fish_pager on the command line, which
means we run into limitations imposed by the operating system on how
long a command line can be.
This version of fish pager doesn't break compatibility with older
versions of fish, it still supports the current method of accepting
completions on the command line, it only tries to read stdin when no
completions are found on the command line (when argc == 3)
I made the patch against the current code in darcs where Axel has
already made many of the necessary changes to fish to use this
functionality (thanks!)
stew
diff -rN old-darcs/complete.h new-darcs/complete.h
56a57,67
> Sent to the fish_pager to signify the end of input
> */
>
> #define PAGER_EOT '\003'
>
> /**
> Sent to the fish_pager to signify the end of input
> */
> #define PAGER_EOT_STR L"\003"
>
> /**
diff -rN old-darcs/fish_pager.c new-darcs/fish_pager.c
886d885
<
897a897
> int in = dup( 0 );
899c899,901
< if( open( ttyname(0), O_WRONLY ) != 1 )
---
> close(0);
>
> if( (in = open( ttyname(2), O_RDWR )) != -1 )
903c905,911
< debug( 0, L"Could not set up file descriptors for pager" );
---
> debug( 0, L"Could not set up output file descriptors for pager" );
> exit( 1 );
> }
>
> if( dup2( in, 0 ) == -1 )
> {
> debug( 0, L"Could not set up input file descriptors for pager %d", in );
906a915,919
> else
> {
> debug( 0, L"Could not open tty for pager" );
> exit( 1 );
> }
908c921
<
---
>
920c933
<
---
>
925a939
>
933c947
<
---
>
941,942c955,956
< pager_modes.c_cc[VMIN]=1;
< pager_modes.c_cc[VTIME]=0;
---
> pager_modes.c_cc[VMIN]=1;
> pager_modes.c_cc[VTIME]=0;
950c964
< exit(1);
---
> /* exit(1); */
974a989,1023
> #define BUFSIZE 1024
> void read_array( FILE* file, array_list_t *comp )
> {
> char buffer[BUFSIZE];
> char c;
> int i;
> wchar_t *wcs;
>
> while( !feof( file ) )
> {
> i = 0;
> while( i < BUFSIZE-1 )
> {
> c = getc( file );
> if( c == '\n' || c == PAGER_EOT )
> {
> break;
> }
>
> buffer[ i++ ] = c;
> }
> buffer[ i ] = '\0';
>
> wcs = str2wcs( buffer );
> if( wcs )
> {
> al_push( comp, wcs );
> }
> if( c == PAGER_EOT )
> {
> break;
> }
> }
> }
>
982,983d1030
< init();
<
990,993c1037,1040
< comp = al_halloc( global_context );
< prefix = str2wcs( argv[2] );
< is_quoted = strcmp( "1", argv[1] )==0;
< is_quoted = 0;
---
> comp = al_halloc( global_context );
> prefix = str2wcs( argv[2] );
> is_quoted = strcmp( "1", argv[1] )==0;
> is_quoted = 0;
995c1042
< debug( 3, L"prefix is '%ls'", prefix );
---
> debug( 3, L"prefix is '%ls'", prefix );
997,1000c1044,1046
< for( i=3; i<argc; i++ )
< {
< wchar_t *wcs = str2wcs( argv[i] );
< if( wcs )
---
> if( argc > 3 )
> {
> for( i=3; i<argc; i++ )
1002c1048,1052
< al_push( comp, wcs );
---
> wchar_t *wcs = str2wcs( argv[i] );
> if( wcs )
> {
> al_push( comp, wcs );
> }
1005,1009c1055,1066
<
< mangle_descriptions( comp );
< if( wcscmp( prefix, L"-" ) == 0 )
< join_completions( comp );
< mangle_completions( comp, prefix );
---
> else
> {
> read_array( stdin, comp );
> }
>
>
> init();
>
> mangle_descriptions( comp );
> if( wcscmp( prefix, L"-" ) == 0 )
> join_completions( comp );
> mangle_completions( comp, prefix );
1011c1068
< for( i = 6; i>0; i-- )
---
> for( i = 6; i>0; i-- )
1013c1070
< switch( completion_try_print( i, prefix, is_quoted, comp ) )
---
> switch( completion_try_print( i, prefix, is_quoted, comp ) )
1015,1022c1072,1079
< case 0:
< break;
< case 1:
< i=0;
< break;
< case 2:
< i=7;
< break;
---
> case 0:
> break;
> case 1:
> i=0;
> break;
> case 2:
> i=7;
> break;
1027c1084
< free(prefix );
---
> free(prefix );
1029,1030c1086,1087
< fwprintf( out_file, L"%ls", (wchar_t *)out_buff.buff );
< if( is_ca_mode )
---
> fwprintf( out_file, L"%ls", (wchar_t *)out_buff.buff );
> if( is_ca_mode )
1032,1033c1089,1090
< writembs(exit_ca_mode);
< pager_flush();
---
> writembs(exit_ca_mode);
> pager_flush();
diff -rN old-darcs/proc.h new-darcs/proc.h
47a48,52
> /**
> A buffer
> */
> INTERNAL_BUFFER,
>
69c74
< INTERNAL_EXEC.
---
> INTERNAL_EXEC, INTERNAL_BUFFER
82c87
< If the process is of type ITERNAL_BUILTIN, argv is the argument
---
> If the process is of type INTERNAL_BUILTIN, argv is the argument
85c90
< If the process is of type ITERNAL_FUNCTION, argv is the argument
---
> If the process is of type INTERNAL_FUNCTION, argv is the argument
88c93
< If the process is of type ITERNAL_BLOCK, argv has exactly one
---
> If the process is of type INTERNAL_BLOCK, argv has exactly one
96,97c101,102
< INTERNAL_BUILTIN, \c INTERNAL_FUNCTION, \c INTERNAL_BLOCK or
< INTERNAL_EXEC
---
> INTERNAL_BUILTIN, \c INTERNAL_FUNCTION, \c INTERNAL_BLOCK,
> INTERNAL_EXEC, or INTERNAL_BUFFER
diff -rN old-darcs/reader.c new-darcs/reader.c
1488c1488
< wchar_t *el = escape( (wchar_t*)al_get( comp, i ),1);
---
> wchar_t *el = (wchar_t*)al_get( comp, i );
1490d1489
< free(el);
1491a1491
> sb_printf( &msg, PAGER_EOT_STR );
1529d1528
<
2550c2549
< wchar_t *begin, *end;
---
> wchar_t *begin, *end;
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users