diff --git a/telegram/tgcli.cs b/telegram/tgcli.cs index ce1bf48..92df884 100644 --- a/telegram/tgcli.cs +++ b/telegram/tgcli.cs @@ -6,11 +6,13 @@ using System.Threading; using System.Threading.Tasks; using Td = TdLib; using static telegram.Util; +// ReSharper disable SwitchStatementMissingSomeEnumCasesNoDefault namespace telegram { /* * TODO: + * make the command system not shit (classes & manager & /help etc) * reply to x messages ago * cap length & truncate extremely long chat names! * replace emoji on send & un-replace on edit, two-way dictionary!! @@ -18,7 +20,6 @@ namespace telegram * make typing newlines actually good (inputline as list?) * waaay more error messages instead of just doing nothing * make Util.getActualStringWidth better - * make the command system not shit (classes & manager & /help etc) * refactor everything * add option to disable terminal bell * command /s /search -> list matching chats, option 1-n, archived indicator @@ -235,24 +236,39 @@ namespace telegram break; default: { - if (key.Key == ConsoleKey.N && key.Modifiers.HasFlag(ConsoleModifiers.Control)) + switch (key.Key) { - currentInputLine += "⏎"; - ScreenUpdate(); - return; - } - if (key.Key == ConsoleKey.D && key.Modifiers.HasFlag(ConsoleModifiers.Control)) - { - Command.ParseCommand("q"); - ScreenUpdate(); - return; - } - if (key.Key == ConsoleKey.L && key.Modifiers.HasFlag(ConsoleModifiers.Control)) - { - Command.ParseCommand("cl"); - ScreenUpdate(); - return; + case ConsoleKey.N when key.Modifiers.HasFlag(ConsoleModifiers.Control): + currentInputLine += "⏎"; + ScreenUpdate(); + return; + case ConsoleKey.D when key.Modifiers.HasFlag(ConsoleModifiers.Control): + Command.ParseCommand("q"); + ScreenUpdate(); + return; + case ConsoleKey.Q when key.Modifiers.HasFlag(ConsoleModifiers.Control): + Command.ParseCommand("q"); + ScreenUpdate(); + return; + case ConsoleKey.E when key.Modifiers.HasFlag(ConsoleModifiers.Control): + Command.ParseCommand("c"); + ScreenUpdate(); + return; + case ConsoleKey.U when key.Modifiers.HasFlag(ConsoleModifiers.Control): + Command.ParseCommand("u"); + ScreenUpdate(); + return; + case ConsoleKey.O when key.Modifiers.HasFlag(ConsoleModifiers.Control): + if (string.IsNullOrWhiteSpace(currentInputLine)) + currentInputLine = "/o "; + ScreenUpdate(); + return; + case ConsoleKey.L when key.Modifiers.HasFlag(ConsoleModifiers.Control): + Command.ParseCommand("cl"); + ScreenUpdate(); + return; } + if (!SpecialKeys.Contains(key.Key)) { currentInputLine += key.KeyChar;