diff --git a/ReadLine.Reboot.Demo/Demonstration/Fixtures/NormalPromptCtrlCAsInput.cs b/ReadLine.Reboot.Demo/Demonstration/Fixtures/NormalPromptCtrlCAsInput.cs index 4a42d9c..3e18d64 100644 --- a/ReadLine.Reboot.Demo/Demonstration/Fixtures/NormalPromptCtrlCAsInput.cs +++ b/ReadLine.Reboot.Demo/Demonstration/Fixtures/NormalPromptCtrlCAsInput.cs @@ -38,7 +38,8 @@ public override void RunFixture() { ReadLine.CtrlCEnabled = true; input = ReadLine.Read("(prompt)> "); - Console.WriteLine($"<< {input}"); + if (ReadLine.ReadRanToCompletion) + Console.WriteLine($"<< {input}"); } } } diff --git a/ReadLine.Reboot/ReadLine.Reboot.csproj b/ReadLine.Reboot/ReadLine.Reboot.csproj index ced1be5..f65d428 100644 --- a/ReadLine.Reboot/ReadLine.Reboot.csproj +++ b/ReadLine.Reboot/ReadLine.Reboot.csproj @@ -3,7 +3,8 @@ ReadLine.Reboot A reboot of tonerdo's ReadLine library for .NET - 3.0.0 + A reboot of tonerdo's ReadLine library for .NET + 3.0.1 Toni Solarin-Sodara,EoflaOE net6.0;netcoreapp3.1;net48 portable @@ -16,7 +17,7 @@ https://github.com/EoflaOE/ReadLine.Reboot True True - 3.0.0 + 3.0.1 EoflaOE Copyright (c) 2022 EoflaOE and its companies. README.md diff --git a/ReadLine.Reboot/ReadLine.cs b/ReadLine.Reboot/ReadLine.cs index 943ccd8..bec3f63 100644 --- a/ReadLine.Reboot/ReadLine.cs +++ b/ReadLine.Reboot/ReadLine.cs @@ -65,6 +65,11 @@ public static class ReadLine /// public static bool CtrlCEnabled { get; set; } + /// + /// Whether the last or request ran to completion + /// + public static bool ReadRanToCompletion { get; private set; } + /// /// The auto completion handler. You need to make a class that implements /// @@ -108,6 +113,9 @@ public static void SetHistory(List history) /// The written text if anything is input from the user, or the default text if nothing if printed public static string Read(string prompt = "", string defaultText = "") { + // Reset the flag + ReadRanToCompletion = false; + // Prepare the prompt WritePrompt.Invoke(prompt); KeyHandler keyHandler = new KeyHandler(new ConsoleWrapper(), _history, AutoCompletionHandler); @@ -139,6 +147,9 @@ public static string Read(string prompt = "", string defaultText = "") /// The written text public static string ReadPassword(string prompt = "", char mask = default) { + // Reset the flag + ReadRanToCompletion = false; + // Prepare the prompt WritePrompt.Invoke(prompt); KeyHandler keyHandler = new KeyHandler(new ConsoleWrapper() { PasswordMode = true, PasswordMaskChar = mask }, null, null); @@ -182,6 +193,7 @@ private static string GetText(KeyHandler keyHandler) { // Write a new line and get the text Console.WriteLine(); + ReadRanToCompletion = true; return keyHandler.Text; } }