mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Escape from token search and help updates
darcs-hash:20050924163122-ac50b-25d56f7e806bedeeaafabae415cd25a676c7e4cf.gz
This commit is contained in:
parent
b1dcf542bc
commit
fe29e1b5d4
4 changed files with 82 additions and 31 deletions
|
@ -1,9 +1,14 @@
|
||||||
2005-09-23 Axel Liljencrantz <axel@liljencrantz.se>
|
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
|
* 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
|
* 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>
|
2005-09-22 Axel Liljencrantz <axel@liljencrantz.se>
|
||||||
|
|
||||||
|
|
|
@ -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 -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 -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 -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 --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 --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
|
\subsection type-example Example
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,31 @@
|
||||||
|
|
||||||
|
|
||||||
function _contains_help -d "Helper function for contains"
|
function _contains_help -d "Helper function for contains"
|
||||||
echo "SYNOPSIS"
|
|
||||||
echo \tcontains \[OPTION] KEY [VALUES...]
|
set bullet \*
|
||||||
echo
|
if count $LANG >/dev/null
|
||||||
echo DESCRIPTION
|
if test (expr match $LANG ".*UTF") -gt 0
|
||||||
echo \t-h, --help
|
set bullet \u2022
|
||||||
echo \t\tdisplay help and exit
|
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 \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
|
end
|
||||||
|
|
||||||
function contains -d "Test if a key is contained in a set of values"
|
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
|
switch $argv
|
||||||
|
|
||||||
case '-h' '--h' '--he' '--hel' '--help'
|
case '-h' '--h' '--he' '--hel' '--help'
|
||||||
printf "Synopsis\n\t%svared%s VARIABLE\n\n" (set_color $fish_color_command) (set_color normal)
|
__vared_help
|
||||||
printf "\tInteractively edit the value of an environment variable\n\n"
|
|
||||||
|
|
||||||
case '-*'
|
case '-*'
|
||||||
printf "vared: Unknown option %s\n" $argv
|
printf "vared: Unknown option %s\n" $argv
|
||||||
|
@ -288,6 +304,18 @@ function vared -d "Edit variable value"
|
||||||
end
|
end
|
||||||
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
|
# This function is bound to Alt-L, it is used to list the contents of
|
||||||
# the directory under the cursor
|
# the directory under the cursor
|
||||||
|
@ -544,7 +572,9 @@ if count $LANG >/dev/null
|
||||||
end
|
end
|
||||||
|
|
||||||
echo \ttype - Indicate how a name would be interpreted if used as a \n\tcommand name
|
echo \ttype - Indicate how a name would be interpreted if used as a \n\tcommand name
|
||||||
|
echo
|
||||||
echo (__bold Synopsis)
|
echo (__bold Synopsis)
|
||||||
|
echo
|
||||||
echo \t(set_color $fish_color_command)type(set_color normal) [OPTIONS] name [name ...]
|
echo \t(set_color $fish_color_command)type(set_color normal) [OPTIONS] name [name ...]
|
||||||
echo
|
echo
|
||||||
echo (__bold Description)
|
echo (__bold Description)
|
||||||
|
@ -591,6 +621,7 @@ function type -d "Print the type of a command"
|
||||||
|
|
||||||
case -h --h --he --hel --help
|
case -h --h --he --hel --help
|
||||||
__type_help
|
__type_help
|
||||||
|
return 0
|
||||||
|
|
||||||
case --
|
case --
|
||||||
break
|
break
|
||||||
|
|
53
reader.c
53
reader.c
|
@ -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.
|
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
|
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;
|
current_pos = data->token_history_pos;
|
||||||
|
@ -2683,12 +2689,19 @@ wchar_t *reader_readline()
|
||||||
case L'\e':
|
case L'\e':
|
||||||
if( *data->search_buff )
|
if( *data->search_buff )
|
||||||
{
|
{
|
||||||
history_reset();
|
if( data->token_history_pos==-1 )
|
||||||
wcscpy( data->buff, data->search_buff );
|
{
|
||||||
data->buff_pos = data->buff_len = wcslen(data->buff);
|
history_reset();
|
||||||
|
reader_set_buffer( data->search_buff,
|
||||||
|
wcslen(data->search_buff ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader_replace_current_token( data->search_buff );
|
||||||
|
}
|
||||||
*data->search_buff=0;
|
*data->search_buff=0;
|
||||||
check_colors();
|
check_colors();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -2896,6 +2909,8 @@ wchar_t *reader_readline()
|
||||||
{
|
{
|
||||||
data->search_buff[0]=0;
|
data->search_buff[0]=0;
|
||||||
history_reset();
|
history_reset();
|
||||||
|
data->token_history_pos=-1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue