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