Escape from token search and help updates

darcs-hash:20050924163122-ac50b-25d56f7e806bedeeaafabae415cd25a676c7e4cf.gz
This commit is contained in:
axel 2005-09-25 02:31:22 +10:00
parent b1dcf542bc
commit fe29e1b5d4
4 changed files with 82 additions and 31 deletions

View file

@ -1,9 +1,14 @@
2005-09-24 Axel Liljencrantz <axel@liljencrantz.se>
* reader.c (reader_readline): Quit token search on escape
2005-09-23 Axel Liljencrantz <axel@liljencrantz.se>
* reader.c (set_signal_handlers): Ignore SIG_PIPE, generated by fishd socket
* exec.c (exec_read_io_buffer): Do not block, since SIG_PIPE seems to mess up EOF status on pipes
* init/fish_function.fish (type): Minor improvements to the type function
2005-09-22 Axel Liljencrantz <axel@liljencrantz.se>

View file

@ -12,8 +12,8 @@ With no options, indicate how each name would be interpreted if used as a comman
- \c -a or \c --all print all of possible definitions of the specified names
- \c -f or \c --no-functions supresses function and builtin lookup
- \c -t or \c --type print a string which is one of alias, keyword, function, builtin, or file if name is an alias, shell reserved word, function, builtin, or disk file, respectively
- \c -p or \c --path either return the name of the disk file that would be executed if name were specified as a command name, or nothing if type -t name would not return file
- \c -P or \c --force-path either return the name of the disk file that would be executed if name were specified as a command name, or nothing no file with the spacified name could be found in the PATH
- \c -p or \c --path either return the name of the disk file that would be executed if name were specified as a command name, or nothing if 'type -t name' would not return 'file'
- \c -P or \c --force-path either return the name of the disk file that would be executed if name were specified as a command name, or nothing no file with the specified name could be found in the PATH
\subsection type-example Example

View file

@ -4,14 +4,31 @@
function _contains_help -d "Helper function for contains"
echo "SYNOPSIS"
echo \tcontains \[OPTION] KEY [VALUES...]
echo
echo DESCRIPTION
echo \t-h, --help
echo \t\tdisplay help and exit
set bullet \*
if count $LANG >/dev/null
if test (expr match $LANG ".*UTF") -gt 0
set bullet \u2022
end
end
echo \tcontains - Test if a word is present in a list\n
__bold Synopsis
echo \n\n\tcontains \[OPTION] KEY [VALUES...]\n
__bold Description
echo \n\n\t$bullet (__bold -h) or (__bold --help) display help and exit\n
echo \tTest if the set VALUES contains the string KEY.
echo \tReturn 0 if yes, 1 otherwise.
echo \tReturn status is 0 if yes, 1 otherwise.\n
__bold Example
echo \n
echo \tfor i in \~/bin /usr/local/bin
echo \t\tif not contains \$i \$PATH
echo \t\t\tset PATH \$PATH i
echo \t\tend
echo \tend
echo
echo \tThe above code tests if "~/bin" and /usr/local/bin are in the path
echo \tand if they are not, they are added.
end
function contains -d "Test if a key is contained in a set of values"
@ -242,8 +259,7 @@ function vared -d "Edit variable value"
switch $argv
case '-h' '--h' '--he' '--hel' '--help'
printf "Synopsis\n\t%svared%s VARIABLE\n\n" (set_color $fish_color_command) (set_color normal)
printf "\tInteractively edit the value of an environment variable\n\n"
__vared_help
case '-*'
printf "vared: Unknown option %s\n" $argv
@ -288,6 +304,18 @@ function vared -d "Edit variable value"
end
end
function __vared_help -d "Display help for the vared shellscript function"
printf "\tvared - Interactively edit the value of an environment variable\n\n"
printf "%s\n\t%svared%s VARIABLE\n\n" (__bold Synopsis) (set_color $fish_color_command) (set_color normal)
__bold Description
printf "\n\n\tvared is used to interactively edit the value of an environment \n"
printf "\tvariable. Array variables as a whole can not be edited using vared,\n"
printf "\tbut individual array elements can.\n\n"
__bold Example
printf "\n\n\t"\'"%svared%s PATH[3]"\'" edits the third element of the PATH array.\n\n" (set_color $fish_color_co\mmand) (set_color normal)
end
#
# This function is bound to Alt-L, it is used to list the contents of
# the directory under the cursor
@ -544,7 +572,9 @@ if count $LANG >/dev/null
end
echo \ttype - Indicate how a name would be interpreted if used as a \n\tcommand name
echo
echo (__bold Synopsis)
echo
echo \t(set_color $fish_color_command)type(set_color normal) [OPTIONS] name [name ...]
echo
echo (__bold Description)
@ -591,6 +621,7 @@ function type -d "Print the type of a command"
case -h --h --he --hel --help
__type_help
return 0
case --
break

View file

@ -1944,6 +1944,26 @@ static int contains( const wchar_t *needle,
}
static void reset_token_history()
{
wchar_t *begin, *end;
reader_current_token_extent( &begin, &end, 0, 0 );
if( begin )
{
wcslcpy(data->search_buff, begin, end-begin+1);
}
else
data->search_buff[0]=0;
data->token_history_pos = -1;
data->search_pos=0;
al_foreach( &data->search_prev, (void (*)(const void *))&free );
al_truncate( &data->search_prev, 0 );
al_push( &data->search_prev, wcsdup( data->search_buff ) );
}
/**
Handles a token search command.
@ -1961,22 +1981,8 @@ static void handle_token_history( int forward, int reset )
/*
Start a new token search using the current token
*/
reset_token_history();
wchar_t *begin, *end;
reader_current_token_extent( &begin, &end, 0, 0 );
if( begin )
{
wcslcpy(data->search_buff, begin, end-begin+1);
}
else
data->search_buff[0]=0;
data->token_history_pos = -1;
data->search_pos=0;
al_foreach( &data->search_prev, (void (*)(const void *))&free );
al_truncate( &data->search_prev, 0 );
al_push( &data->search_prev, wcsdup( data->search_buff ) );
}
current_pos = data->token_history_pos;
@ -2683,9 +2689,16 @@ wchar_t *reader_readline()
case L'\e':
if( *data->search_buff )
{
history_reset();
wcscpy( data->buff, data->search_buff );
data->buff_pos = data->buff_len = wcslen(data->buff);
if( data->token_history_pos==-1 )
{
history_reset();
reader_set_buffer( data->search_buff,
wcslen(data->search_buff ) );
}
else
{
reader_replace_current_token( data->search_buff );
}
*data->search_buff=0;
check_colors();
@ -2896,6 +2909,8 @@ wchar_t *reader_readline()
{
data->search_buff[0]=0;
history_reset();
data->token_history_pos=-1;
}