System.TermInfoDriver.ReadLine C# (CSharp) Méthode

ReadLine() public méthode

public ReadLine ( ) : string
Résultat string
		public string ReadLine ()
 		{
			if (!inited)
				Init ();

			// Hack to make Iron Python work (since it goes behind our backs
			// when writing to the console thus preventing us from keeping
			// cursor state normally).
			GetCursorPosition ();

			StringBuilder builder = new StringBuilder ();
			bool fresh, echo = false;
			ConsoleKeyInfo key;
			char c;

			rl_startx = cursorLeft;
			rl_starty = cursorTop;
			char eof = (char) control_characters [ControlCharacters.EOF];

			do {
				key = ReadKeyInternal (out fresh);
				echo = echo || fresh;
				c = key.KeyChar;
				// EOF -> Ctrl-D (EOT) pressed.
				if (c == eof && c != 0 && builder.Length == 0)
					return null;

				if (key.Key != ConsoleKey.Enter) {
					if (key.Key != ConsoleKey.Backspace) {
						builder.Append (c);
					} else if (builder.Length > 0) {
						builder.Length--;
					} else {
						// skips over echoing the key to the console
						continue;
					}
				}

				// echo fresh keys back to the console
				if (echo)
					Echo (key);
			} while (key.Key != ConsoleKey.Enter);

			EchoFlush ();

			rl_startx = -1;
			rl_starty = -1;

			return builder.ToString ();
 		}