mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 06:05:39 +08:00
Allow Meta-newline to always insert a newline character
darcs-hash:20061009011529-ac50b-c8e3d77b569bc445e586c95aca01e4433fbff598.gz
This commit is contained in:
parent
770fa771b6
commit
7a8b468165
26
input.c
26
input.c
|
@ -130,7 +130,8 @@ static const wchar_t *name_arr[] =
|
|||
L"self-insert",
|
||||
L"null",
|
||||
L"eof",
|
||||
L"vi-arg-digit"
|
||||
L"vi-arg-digit",
|
||||
L"execute"
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -207,7 +208,8 @@ static const wchar_t code_arr[] =
|
|||
R_SELF_INSERT,
|
||||
R_NULL,
|
||||
R_EOF,
|
||||
R_VI_ARG_DIGIT
|
||||
R_VI_ARG_DIGIT,
|
||||
R_EXECUTE
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -1222,6 +1224,14 @@ static void add_common_bindings()
|
|||
*/
|
||||
for( i=0; i<3; i++ )
|
||||
{
|
||||
add_mapping( name[i], L"\n", L"Execute contents of commandline", L"execute" );
|
||||
|
||||
/*
|
||||
This will make Meta-newline insert a newline, since
|
||||
self-insert ignored the escape character unless it is the
|
||||
only character of the sequence.
|
||||
*/
|
||||
add_mapping( name[i], L"\e\n", L"Meta-newline", L"self-insert" );
|
||||
/*
|
||||
We need alternative keybidnings for arrowkeys, since
|
||||
terminfo sometimes specifies a different sequence than what
|
||||
|
@ -1509,6 +1519,7 @@ static wint_t input_exec_binding( mapping *m, const wchar_t *seq )
|
|||
{
|
||||
switch( code )
|
||||
{
|
||||
|
||||
case R_DUMP_FUNCTIONS:
|
||||
{
|
||||
for( i=0; i<repeat_count; i++ )
|
||||
|
@ -1519,10 +1530,17 @@ static wint_t input_exec_binding( mapping *m, const wchar_t *seq )
|
|||
|
||||
case R_SELF_INSERT:
|
||||
{
|
||||
int idx = 0;
|
||||
|
||||
if( seq[0] == L'\e' && seq[1] )
|
||||
{
|
||||
idx = 1;
|
||||
}
|
||||
|
||||
for( i=1; i<repeat_count; i++ )
|
||||
input_unreadch( seq[0] );
|
||||
input_unreadch( seq[idx] );
|
||||
repeat_count = 1;
|
||||
return seq[0];
|
||||
return seq[idx];
|
||||
}
|
||||
|
||||
case R_VI_ARG_DIGIT:
|
||||
|
|
3
input.h
3
input.h
|
@ -45,7 +45,8 @@ enum
|
|||
R_HISTORY_TOKEN_SEARCH_FORWARD,
|
||||
R_SELF_INSERT,
|
||||
R_VI_ARG_DIGIT,
|
||||
R_VI_DELETE_TO
|
||||
R_VI_DELETE_TO,
|
||||
R_EXECUTE
|
||||
}
|
||||
;
|
||||
|
||||
|
|
12
reader.c
12
reader.c
|
@ -2248,8 +2248,12 @@ wchar_t *reader_readline()
|
|||
break;
|
||||
}
|
||||
|
||||
/* Newline, evaluate*/
|
||||
case L'\n':
|
||||
/*
|
||||
Evaluate. If the current command is unfinished, or if
|
||||
the charater is escaped using a backslash, insert a
|
||||
newline
|
||||
*/
|
||||
case R_EXECUTE:
|
||||
{
|
||||
/*
|
||||
Allow backslash-escaped newlines
|
||||
|
@ -2443,8 +2447,10 @@ wchar_t *reader_readline()
|
|||
/* Other, if a normal character, we add it to the command */
|
||||
default:
|
||||
{
|
||||
if( (!wchar_private(c)) && (c>31) && (c != 127) )
|
||||
if( (!wchar_private(c)) && (( (c>31) || (c=L'\n'))&& (c != 127)) )
|
||||
{
|
||||
insert_char( c );
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue
Block a user