internal void ParseInitialText() { if (PromptForText) { Text = _console.Read("Enter your text: ", CurrentConfig.LastWrittenText); } else if (Menu) { for (int i = 0; i < CurrentConfig.Texts.Length; i++) { _console.WriteLine($"[{i}] {CurrentConfig.Texts[i]}"); } _console.WriteLine("[#] [Enter a custom text]"); _console.AddHistory(Enumerable.Range(0, CurrentConfig.Texts.Length).Select(i => i.ToString()).ToArray()); int index = -1; int lastUsedTextIndex = (CurrentConfig.LastTextIndexUsedInMenu ?? 0); string enteredIndex = null; do { enteredIndex = _console.Read("\r\nEnter the desired text index: ", enteredIndex ?? (TextIndex ?? lastUsedTextIndex).ToString()); if (enteredIndex == "#") { Text = _console.Read("Enter your text: ", CurrentConfig.LastWrittenText); return; } else if (!int.TryParse(enteredIndex, out index) || index < 0 || index >= CurrentConfig.Texts.Length) { _console.WriteLine($"'{enteredIndex}' is not a valid index. Enter a value between 0 and {CurrentConfig.Texts.Length - 1}."); index = -1; } } while (index == -1); CurrentConfig.LastTextIndexUsedInMenu = index; Text = CurrentConfig.Texts[index]; } else { Text = CurrentConfig.Texts[TextIndex ?? CurrentConfig.NextTextIndex ?? 0]; } }