System.TermInfoDriver.GetKeyFromBuffer C# (CSharp) Method

GetKeyFromBuffer() private method

private GetKeyFromBuffer ( bool cooked ) : object
cooked bool
return object
		object GetKeyFromBuffer (bool cooked)
		{
			if (readpos >= writepos)
				return null;

			int next = buffer [readpos];
			if (!cooked || !rootmap.StartsWith (next)) {
				readpos++;
				AdjustBuffer ();
				return CreateKeyInfoFromInt (next, false);
			}

			int used;
			TermInfoStrings str = rootmap.Match (buffer, readpos, writepos - readpos, out used);
			if ((int) str == -1){
				// Escape sequences: alt keys are sent as ESC-key
				if (buffer [readpos] == 27 && (writepos - readpos) >= 2){
					readpos += 2;
					AdjustBuffer ();
					if (buffer [readpos+1] == 127)
						return new ConsoleKeyInfo ((char)8, ConsoleKey.Backspace, false, true, false);
					return CreateKeyInfoFromInt (buffer [readpos+1], true);
				} else
					return null;
			}

			ConsoleKeyInfo key;
			if (keymap [str] != null) {
				key = (ConsoleKeyInfo) keymap [str];
			} else {
				readpos++;
				AdjustBuffer ();
				return CreateKeyInfoFromInt (next, false);
			}

			readpos += used;
			AdjustBuffer ();
			return key;
		}