private static string ReadFromInput(bool isNumber, out uint inpLen) { ConsoleColors.SetAndPushDefaultColors(); var input = ""; char ch; inpLen = 0; while (!(ch = Console.ReadKey(true).KeyChar).Equals(Nl[0]) || inpLen.Equals(0)) { switch (ch) { case '\r': continue; case '\b' when inpLen != 0: input = input.Remove(input.Length - 1); inpLen--; Console.Write("\b \b"); break; default: { if (inpLen != 9 && ch != '\b') { if (isNumber && (ch < '0' || ch > '9')) { continue; } Console.Write(ch); input += ch; inpLen++; } break; } } } ConsoleColors.SetPreviousAndPopColors(); return(input); }
public static void PrintControls() { const string line = " - "; const string tab = " "; string[] newInstanceString = { "RETURN", "compile&execute", "Q", "exit", "F", "choose file", "T/Ctr-T", "ACtest" }; _lengthOfControls = 0; for (var i = 0; i < newInstanceString.Length; i++) { _lengthOfControls += (uint)newInstanceString[i].Length; ConsoleColors.SetAndPushColors(Green); Console.Write(newInstanceString[i++]); ConsoleColors.SetPreviousAndPopColors(); ConsoleColors.SetAndPushColors(Yellow); Console.Write(line); ConsoleColors.SetPreviousAndPopColors(); _lengthOfControls += (uint)newInstanceString[i].Length; ConsoleColors.SetAndPushColors(Cyan); Console.Write(newInstanceString[i]); if (!i.Equals(newInstanceString.Length - 1)) { Console.Write(tab); } ConsoleColors.SetPreviousAndPopColors(); } _lengthOfControls += (uint)(newInstanceString.Length / 2 * line.Length + (newInstanceString.Length / 2 - 1) * tab.Length); }