From 33493119d313786f8792834fddce48224abff283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Jur=C4=8D=C3=ADk?= Date: Mon, 30 Jul 2018 10:49:07 +0200 Subject: [PATCH 1/3] fix: clear previous text when show completions --- LineEditor/getline.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/LineEditor/getline.cs b/LineEditor/getline.cs index 6d1ebe9..2c47320 100644 --- a/LineEditor/getline.cs +++ b/LineEditor/getline.cs @@ -771,10 +771,9 @@ namespace Mono.Terminal { int window_height = System.Math.Min (completions.Length, Console.WindowHeight/5); int target_line = Console.WindowHeight-window_height-1; if (Console.CursorTop > target_line){ - var saved_left = Console.CursorLeft; - var delta = Console.CursorTop-target_line; + var delta = Console.CursorTop-target_line+window_height; Console.CursorLeft = 0; - Console.CursorTop = Console.WindowHeight-1; + Console.CursorTop = target_line; for (int i = 0; i < delta+1; i++){ for (int c = Console.WindowWidth; c > 0; c--) Console.Write (" "); // To debug use ("{0}", i%10); From 5a7e3e24730e5392e2c37eddea3f0833bab5d18f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Makovsk=C3=BD?= Date: Mon, 30 Jul 2018 11:33:54 +0200 Subject: [PATCH 2/3] style: use tabs instead of spaces --- LineEditor/getline.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LineEditor/getline.cs b/LineEditor/getline.cs index 2c47320..f1d5119 100644 --- a/LineEditor/getline.cs +++ b/LineEditor/getline.cs @@ -773,7 +773,7 @@ namespace Mono.Terminal { if (Console.CursorTop > target_line){ var delta = Console.CursorTop-target_line+window_height; Console.CursorLeft = 0; - Console.CursorTop = target_line; + Console.CursorTop = target_line; for (int i = 0; i < delta+1; i++){ for (int c = Console.WindowWidth; c > 0; c--) Console.Write (" "); // To debug use ("{0}", i%10); From 0d435525e1e939f7786c3f636db21ce5f680a7d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Jur=C4=8D=C3=ADk?= Date: Mon, 30 Jul 2018 14:40:25 +0200 Subject: [PATCH 3/3] fix: text overriding was only platform specific (check platform) --- LineEditor/getline.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/LineEditor/getline.cs b/LineEditor/getline.cs index f1d5119..bc10e0a 100644 --- a/LineEditor/getline.cs +++ b/LineEditor/getline.cs @@ -44,6 +44,7 @@ using System.Text; using System.IO; using System.Threading; using System.Reflection; +using System.Runtime.InteropServices; namespace Mono.Terminal { @@ -409,6 +410,8 @@ namespace Mono.Terminal { static Handler [] handlers; + private readonly bool isWindows; + /// /// Initializes a new instance of the LineEditor, using the specified name for /// retrieving and storing the history. The history will default to 10 entries. @@ -467,6 +470,7 @@ namespace Mono.Terminal { history = new History (name, histsize); + isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); GetUnixConsoleReset (); //if (File.Exists ("log"))File.Delete ("log"); //log = File.CreateText ("log"); @@ -482,9 +486,7 @@ namespace Mono.Terminal { // // On Unix, we want to be able to reset the color for the pop-up completion // - int p = (int) Environment.OSVersion.Platform; - var is_unix = (p == 4) || (p == 128); - if (!is_unix) + if (isWindows) return; // Sole purpose of this call is to initialize the Terminfo driver @@ -770,10 +772,10 @@ namespace Mono.Terminal { // Ensure we have space, determine window size int window_height = System.Math.Min (completions.Length, Console.WindowHeight/5); int target_line = Console.WindowHeight-window_height-1; - if (Console.CursorTop > target_line){ - var delta = Console.CursorTop-target_line+window_height; + if (!isWindows && Console.CursorTop > target_line){ + var delta = Console.CursorTop-target_line; Console.CursorLeft = 0; - Console.CursorTop = target_line; + Console.CursorTop = Console.WindowHeight-1; for (int i = 0; i < delta+1; i++){ for (int c = Console.WindowWidth; c > 0; c--) Console.Write (" "); // To debug use ("{0}", i%10);