Skip to content

Commit

Permalink
Properly fix prompt printing in C# example.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 4a9306738d35a3ba0893ae65922a5bcef7c2f644
  • Loading branch information
levlam committed Mar 20, 2018
1 parent 42d5248 commit cfe4d9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
16 changes: 11 additions & 5 deletions example/csharp/TdExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Example

private static readonly string _newLine = Environment.NewLine;
private static readonly string _commandsLine = "Enter command (gc <chatId> - GetChat, me - GetMe, sm <chatId> <message> - SendMessage, lo - LogOut, q - Quit): ";
private static volatile string _currentPrompt = null;

private static Td.Client CreateTdClient()
{
Expand All @@ -43,19 +44,24 @@ private static Td.Client CreateTdClient()

private static void Print(string str)
{
Console.WriteLine();
if (_currentPrompt != null)
{
Console.WriteLine();
}
Console.WriteLine(str);
if (_haveAuthorization)
if (_currentPrompt != null)
{
Console.Write(_commandsLine);
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)
Expand Down
3 changes: 3 additions & 0 deletions example/java/org/drinkless/tdlib/example/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cfe4d9b

Please sign in to comment.