public void StartInputting(string[] args) { while (true) { GuiApp.LineRed(Console.ReadLine()); } }
public void StartInputting() { while (true) { GuiApp.LineRed(System.Console.ReadLine()); } }
private void DoKeyStuff(ConsoleKeyInfo key) { switch (key.Key) { case ConsoleKey.Tab: int rem; if (_hinting) { _hintIndex++; if (_hintIndex >= _hints.Count) { _hintIndex = 0; } rem = GetSkipAmount(-1, true); } else { _hinting = true; var hints = CommandManager.ParseTab(Globals.ConsoleSender, _line.Substring(0, Math.Min(_line.Length, _cursor))); _hints = hints.Where(s => s.StartsWith(_currentArg)).ToList(); _hintIndex = 0; rem = _currentArg.Length; } if (_hints.Count == 0) { return; } if (rem > 0) { _line = _line.Remove(_cursor - rem, rem); } AddCursorPos(-rem); var hint = _hints[_hintIndex]; _line = _line.Insert(_cursor, hint); AddCursorPos(hint.Length); SetCursorPos(); return; case ConsoleKey.Enter: System.Console.Write("\n"); _history.Insert(0, _line); GuiApp.LineRed(_line); Reset(); break; case ConsoleKey.LeftArrow: AddCursorPos(key.Modifiers.HasFlag(ConsoleModifiers.Control) ? -GetSkipAmount(-1, true) : -1); break; case ConsoleKey.RightArrow: AddCursorPos(key.Modifiers.HasFlag(ConsoleModifiers.Control) ? GetSkipAmount(1, false) : 1); break; case ConsoleKey.UpArrow: History(1); break; case ConsoleKey.DownArrow: History(-1); break; case ConsoleKey.Backspace: if (key.Modifiers.HasFlag(ConsoleModifiers.Control)) { var amount = GetSkipAmount(-1, true); if (amount > 0) { _line = _line.Remove(_cursor - amount, amount); } AddCursorPos(-amount); } else { if (_cursor > 0) { _line = _line.Remove(_cursor - 1, 1); } AddCursorPos(-1); } break; case ConsoleKey.Delete: if (key.Modifiers.HasFlag(ConsoleModifiers.Control)) { var amount = GetSkipAmount(1, false); if (amount > 0 && _cursor < _line.Length) { _line = _line.Remove(_cursor, amount); } } else { if (_cursor < _line.Length) { _line = _line.Remove(_cursor, 1); } } break; default: HandleKey(); break; } _hinting = false; SetCurrentArg(); SetCursorPos(); }
private void DoKeyStuff() { switch (_key.Key) { case ConsoleKey.End: GuiApp.Log(new FancyText($"UwU{new Random().Next()}", FancyColor.Aqua)); break; case ConsoleKey.Tab: int rem; if (_hinting) { _hintIndex++; if (_hintIndex >= _hints.Count) { _hintIndex = 0; } rem = GetSkipAmount(-1, true); } else { _hinting = true; var hints = GetTabbyThingy.GetHints(_line); _hints = hints.Where(s => s.StartsWith(_currentArg)).ToList(); _hintIndex = 0; rem = _currentArg.Length; } if (_hints.Count == 0) { return; } if (rem > 0) { _line = _line.Remove(_cursor - rem, rem); } AddCursorPos(-rem); var hint = _hints[_hintIndex]; _line = _line.Insert(_cursor, hint); AddCursorPos(hint.Length); SetCursorPos(); return; case ConsoleKey.Enter: Console.Write("\n"); _history.Insert(0, _line); GuiApp.LineRed(_line); Reset(); break; case ConsoleKey.LeftArrow: AddCursorPos(_key.Modifiers.HasFlag(ConsoleModifiers.Control) ? -GetSkipAmount(-1, true) : -1); break; case ConsoleKey.RightArrow: AddCursorPos(_key.Modifiers.HasFlag(ConsoleModifiers.Control) ? GetSkipAmount(1, false) : 1); break; case ConsoleKey.UpArrow: History(1); break; case ConsoleKey.DownArrow: History(-1); break; case ConsoleKey.Backspace: if (_key.Modifiers.HasFlag(ConsoleModifiers.Control)) { var amount = GetSkipAmount(-1, true); if (amount > 0) { _line = _line.Remove(_cursor - amount, amount); } AddCursorPos(-amount); } else { if (_cursor > 0) { _line = _line.Remove(_cursor - 1, 1); } AddCursorPos(-1); } break; case ConsoleKey.Delete: if (_key.Modifiers.HasFlag(ConsoleModifiers.Control)) { var amount = GetSkipAmount(1, false); if (amount > 0 && _cursor < _line.Length) { _line = _line.Remove(_cursor, amount); } } else { if (_cursor < _line.Length) { _line = _line.Remove(_cursor, 1); } } break; default: HandleKey(); break; } _hinting = false; SetCurrentArg(); SetCursorPos(); }