aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-10-09 11:15:29 +1000
committerGravatar axel <axel@liljencrantz.se>2006-10-09 11:15:29 +1000
commit7a8b46816556339059878cf62dbe142552de953a (patch)
tree7df742503172a5ff07db95980faf59042262497c
parent770fa771b6985c1ae38fe47c25e8d8c3061a0dfa (diff)
Allow Meta-newline to always insert a newline character
darcs-hash:20061009011529-ac50b-c8e3d77b569bc445e586c95aca01e4433fbff598.gz
-rw-r--r--input.c26
-rw-r--r--input.h3
-rw-r--r--reader.c12
3 files changed, 33 insertions, 8 deletions
diff --git a/input.c b/input.c
index 833e7808..406e4b2e 100644
--- a/input.c
+++ b/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:
diff --git a/input.h b/input.h
index 619c8d81..867099e3 100644
--- a/input.h
+++ b/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
}
;
diff --git a/reader.c b/reader.c
index b789a919..390a0b32 100644
--- a/reader.c
+++ b/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
{
/*