input refactor
This commit is contained in:
parent
e6c53e6a72
commit
f0fb725e02
|
@ -194,9 +194,15 @@ namespace telegram
|
|||
|
||||
public static void ClearCurrentConsoleLine()
|
||||
{
|
||||
Console.SetCursorPosition(0, Console.WindowHeight);
|
||||
Console.Write(new string(' ', Console.WindowWidth));
|
||||
Console.SetCursorPosition(0, Console.WindowHeight);
|
||||
do
|
||||
{
|
||||
Console.Write("\b \b");
|
||||
} while (Console.CursorLeft > 0);
|
||||
//TODO is there a better solution?
|
||||
|
||||
//Console.SetCursorPosition(0, Console.WindowHeight);
|
||||
//Console.Write(new string(' ', Console.WindowWidth));
|
||||
//Console.SetCursorPosition(0, Console.WindowHeight);
|
||||
}
|
||||
|
||||
public static string ReadConsolePassword()
|
||||
|
@ -388,6 +394,15 @@ namespace telegram
|
|||
return input.Length <= maxLen ? input : input.Substring(0, maxLen - 1) + "~";
|
||||
}
|
||||
|
||||
public static string TruncateMessageStart(string input, int maxLen)
|
||||
{
|
||||
if (maxLen < 2)
|
||||
maxLen = 2;
|
||||
if (input.Contains("⏎"))
|
||||
input = "⏎" + input.Split("⏎").Last();
|
||||
return input.Length <= maxLen ? input : "<" + input.Substring(input.Length - maxLen + 1);
|
||||
}
|
||||
|
||||
public static readonly List<ConsoleKey> SpecialKeys = new List<ConsoleKey>
|
||||
{
|
||||
ConsoleKey.Backspace,
|
||||
|
|
|
@ -14,21 +14,18 @@ namespace telegram
|
|||
{
|
||||
/*
|
||||
* TODO:
|
||||
* make commands & keybinds more consistent (maybe configurable?)
|
||||
* replace emoji on send & un-replace on edit, two-way dictionary!!
|
||||
* replace more emojis on send (is there a lib for that)
|
||||
* make typing newlines actually good (inputline as list?)
|
||||
* waaay more error messages instead of just doing nothing or crashing
|
||||
* refactor everything
|
||||
* waaay more error messages instead of just doing nothing or crashing (search for "do something")
|
||||
* add option to disable terminal bell
|
||||
* make commands & keybinds more consistent (maybe configurable?)
|
||||
* for commands with query, if query starting with @ only match where username matches *exactly*
|
||||
* command /sg -> search globally, some way to add contacts?
|
||||
* command /sc -> search in chat list & list matching chats, archived, muted indicator
|
||||
* mute,unmute chats
|
||||
* fix issues when current_input message is longer than term width (only show as much as fits?)
|
||||
* photo & document download & show externally
|
||||
* publish AUR package
|
||||
* maybe cursor input nav (cmd+del, left/right, up for last inputs, etc)
|
||||
* refactor everything
|
||||
*/
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
|
@ -203,9 +200,16 @@ namespace telegram
|
|||
Console.Write("\a"); //ring terminal bell
|
||||
messageQueue.Clear();
|
||||
var status = GetFormattedStatus(currentUserRead);
|
||||
Console.Write(prefix
|
||||
+ (connectionState == "Ready" ? "" : $" | {connectionState}")
|
||||
+ (currentChatUserId != 0 ? status : "]") + " > " + currentInputLine);
|
||||
var output = prefix;
|
||||
if (connectionState != "Ready")
|
||||
output += $" | {connectionState}";
|
||||
if (currentChatUserId != 0)
|
||||
output += status;
|
||||
else
|
||||
output += "]";
|
||||
output += " > ";
|
||||
output += TruncateMessageStart(currentInputLine, Console.LargestWindowWidth - output.Length);
|
||||
Console.Write(output);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue