diff --git a/example/csharp/TdExample.cs b/example/csharp/TdExample.cs index c7823bef..be98e1a7 100644 --- a/example/csharp/TdExample.cs +++ b/example/csharp/TdExample.cs @@ -29,6 +29,7 @@ namespace TdExample private static readonly string _newLine = Environment.NewLine; private static readonly string _commandsLine = "Enter command (gc - GetChat, me - GetMe, sm - SendMessage, lo - LogOut, q - Quit): "; + private static volatile string _currentPrompt = null; private static Td.Client CreateTdClient() { @@ -43,19 +44,24 @@ namespace TdExample private static void Print(string str) { - Console.WriteLine(); - Console.WriteLine(str); - if (_haveAuthorization) + if (_currentPrompt != null) { - Console.Write(_commandsLine); + Console.WriteLine(); + } + Console.WriteLine(str); + if (_currentPrompt != null) + { + Console.Write(_currentPrompt); } } private static string ReadLine(string str) { - Console.WriteLine(); Console.Write(str); - return Console.ReadLine(); + _currentPrompt = str; + var result = Console.ReadLine(); + _currentPrompt = null; + return result; } private static void OnAuthorizationStateUpdated(TdApi.AuthorizationState authorizationState) diff --git a/example/java/org/drinkless/tdlib/example/Example.java b/example/java/org/drinkless/tdlib/example/Example.java index c1aad644..831de88f 100644 --- a/example/java/org/drinkless/tdlib/example/Example.java +++ b/example/java/org/drinkless/tdlib/example/Example.java @@ -59,6 +59,9 @@ public final class Example { } private static void print(String str) { + if (currentPrompt != null) { + System.out.println(""); + } System.out.println(str); if (currentPrompt != null) { System.out.print(currentPrompt);