System.TermInfoDriver.ReadKeyInternal C# (CSharp) Method

ReadKeyInternal() private method

private ReadKeyInternal ( bool &fresh ) : ConsoleKeyInfo
fresh bool
return ConsoleKeyInfo
		ConsoleKeyInfo ReadKeyInternal (out bool fresh)
		{
			if (!inited)
				Init ();

			InitKeys ();

			object o;

			if ((o = GetKeyFromBuffer (true)) == null) {
				do {
					if (ConsoleDriver.InternalKeyAvailable (150) > 0) {
						do {
							AddToBuffer (stdin.Read ());
						} while (ConsoleDriver.InternalKeyAvailable (0) > 0);
					} else if (stdin.DataAvailable ()) {
						do {
							AddToBuffer (stdin.Read ());
						} while (stdin.DataAvailable ());
					} else {
						if ((o = GetKeyFromBuffer (false)) != null)
							break;

						AddToBuffer (stdin.Read ());
					}
					
					o = GetKeyFromBuffer (true);
				} while (o == null);

				// freshly read character
				fresh = true;
			} else {
				// this char was pre-buffered (e.g. not fresh)
				fresh = false;
			}

			return (ConsoleKeyInfo) o;
		}