From 132334bedd6bd4a536cf376875f5d2f01dc8bf65 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sat, 14 Dec 2019 20:54:53 +0100 Subject: [PATCH] improve padding --- telegram/Command.cs | 2 -- telegram/Util.cs | 4 ++-- telegram/tgcli.cs | 4 +++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/telegram/Command.cs b/telegram/Command.cs index 08fe97d..8a3c4f5 100644 --- a/telegram/Command.cs +++ b/telegram/Command.cs @@ -130,7 +130,6 @@ namespace telegram else if (chat.UnreadCount > 0) { var unreads = GetHistory(chatId, chat.UnreadCount); - Console.WriteLine(unreads.Count); var rest = GetHistory(chatId, 5 - unreads.Count, unreads.First().Id); rest.ForEach(AddMessageToQueue); messageQueue.Add($"{Ansi.Yellow}[tgcli] ---UNREAD---"); @@ -204,7 +203,6 @@ namespace telegram else if (chat.UnreadCount > 0) { var unreads = GetHistory(chat.Id, chat.UnreadCount); - Console.WriteLine(unreads.Count); var rest = GetHistory(chat.Id, 5 - unreads.Count, unreads.First().Id); rest.ForEach(AddMessageToQueue); messageQueue.Add($"{Ansi.Yellow}[tgcli] ---UNREAD---"); diff --git a/telegram/Util.cs b/telegram/Util.cs index ea7745c..c2afe57 100644 --- a/telegram/Util.cs +++ b/telegram/Util.cs @@ -380,7 +380,7 @@ namespace telegram return results.ChatIds.First(p => GetChat(p).Type is ChatType.ChatTypePrivate type && GetUser(type.UserId).Username == query.Substring(1)); - return results.ChatIds.First(); + return results.ChatIds.First(p => !(GetChat(p).Type is ChatType.ChatTypeSecret)); } catch { @@ -495,7 +495,7 @@ namespace telegram maxLen = 2; if (input.Contains("⏎")) input = "⏎" + input.Split("⏎").Last(); - return input.Length <= maxLen ? input : "<" + input.Substring(input.Length - maxLen + 1); + return input.Length < maxLen ? input : "<" + input.Substring(input.Length - maxLen + 2); } public static readonly List> Emojis = new List> diff --git a/telegram/tgcli.cs b/telegram/tgcli.cs index b663353..14d8ed9 100644 --- a/telegram/tgcli.cs +++ b/telegram/tgcli.cs @@ -14,6 +14,8 @@ namespace telegram { /* * TODO: + * fuzzy matching for replies? + * unreads are unreliable in secret chats! * mute,unmute chats * photo & document download & show externally * publish AUR package @@ -212,7 +214,7 @@ namespace telegram else output += "]"; output += " > "; - output += TruncateMessageStart(currentInputLine, Console.LargestWindowWidth - output.Length); + output += TruncateMessageStart(currentInputLine, Console.LargestWindowWidth - GetActualStringWidth(output)); Console.Write(output); } }