Imported Upstream version 5.10.0.47

Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-24 17:04:36 +00:00
parent 88ff76fe28
commit e46a49ecf1
5927 changed files with 226314 additions and 129848 deletions

View File

@ -1102,6 +1102,16 @@ namespace System {
}
public string ReadLine ()
{
return ReadUntilConditionInternal (true);
}
public string ReadToEnd ()
{
return ReadUntilConditionInternal (false);
}
private string ReadUntilConditionInternal (bool haltOnNewLine)
{
if (!inited)
Init ();
@ -1120,6 +1130,8 @@ namespace System {
rl_starty = cursorTop;
char eof = (char) control_characters [ControlCharacters.EOF];
bool treatAsEnterKey;
do {
key = ReadKeyInternal (out fresh);
echo = echo || fresh;
@ -1128,7 +1140,9 @@ namespace System {
if (c == eof && c != 0 && builder.Length == 0)
return null;
if (key.Key != ConsoleKey.Enter) {
treatAsEnterKey = haltOnNewLine && (key.Key == ConsoleKey.Enter);
if (!treatAsEnterKey) {
if (key.Key != ConsoleKey.Backspace) {
builder.Append (c);
} else if (builder.Length > 0) {
@ -1142,7 +1156,7 @@ namespace System {
// echo fresh keys back to the console
if (echo)
Echo (key);
} while (key.Key != ConsoleKey.Enter);
} while (!treatAsEnterKey);
EchoFlush ();