Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 410ca3d

Browse files
Merge pull request #2 from VEIT-Electronics/master
Fixed text clearing in cmd.exe
2 parents de0e3fc + 3d802e7 commit 410ca3d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

LineEditor/getline.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
using System.IO;
4545
using System.Threading;
4646
using System.Reflection;
47+
using System.Runtime.InteropServices;
4748

4849
namespace Mono.Terminal {
4950

@@ -409,6 +410,8 @@ public static Handler Alt (char c, ConsoleKey k, KeyHandler h)
409410

410411
static Handler [] handlers;
411412

413+
private readonly bool isWindows;
414+
412415
/// <summary>
413416
/// Initializes a new instance of the LineEditor, using the specified name for
414417
/// retrieving and storing the history. The history will default to 10 entries.
@@ -467,6 +470,7 @@ public LineEditor (string name, int histsize)
467470

468471
history = new History (name, histsize);
469472

473+
isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
470474
GetUnixConsoleReset ();
471475
//if (File.Exists ("log"))File.Delete ("log");
472476
//log = File.CreateText ("log");
@@ -482,9 +486,7 @@ void GetUnixConsoleReset ()
482486
//
483487
// On Unix, we want to be able to reset the color for the pop-up completion
484488
//
485-
int p = (int) Environment.OSVersion.Platform;
486-
var is_unix = (p == 4) || (p == 128);
487-
if (!is_unix)
489+
if (isWindows)
488490
return;
489491

490492
// Sole purpose of this call is to initialize the Terminfo driver
@@ -770,8 +772,7 @@ void ShowCompletions (string prefix, string [] completions)
770772
// Ensure we have space, determine window size
771773
int window_height = System.Math.Min (completions.Length, Console.WindowHeight/5);
772774
int target_line = Console.WindowHeight-window_height-1;
773-
if (Console.CursorTop > target_line){
774-
var saved_left = Console.CursorLeft;
775+
if (!isWindows && Console.CursorTop > target_line){
775776
var delta = Console.CursorTop-target_line;
776777
Console.CursorLeft = 0;
777778
Console.CursorTop = Console.WindowHeight-1;

0 commit comments

Comments
 (0)