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

Commit 0d43552

Browse files
author
Lukáš Jurčík
committed
fix: text overriding was only platform specific (check platform)
1 parent 5a7e3e2 commit 0d43552

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎LineEditor/getline.cs‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
usingSystem.IO;
4545
usingSystem.Threading;
4646
usingSystem.Reflection;
47+
usingSystem.Runtime.InteropServices;
4748

4849
namespaceMono.Terminal{
4950

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

410411
staticHandler[]handlers;
411412

413+
privatereadonlyboolisWindows;
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=newHistory(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-
intp=(int)Environment.OSVersion.Platform;
486-
varis_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,10 +772,10 @@ void ShowCompletions (string prefix, string [] completions)
770772
// Ensure we have space, determine window size
771773
intwindow_height=System.Math.Min(completions.Length,Console.WindowHeight/5);
772774
inttarget_line=Console.WindowHeight-window_height-1;
773-
if(Console.CursorTop>target_line){
774-
vardelta=Console.CursorTop-target_line+window_height;
775+
if(!isWindows&&Console.CursorTop>target_line){
776+
vardelta=Console.CursorTop-target_line;
775777
Console.CursorLeft=0;
776-
Console.CursorTop=target_line;
778+
Console.CursorTop=Console.WindowHeight-1;
777779
for(inti=0;i<delta+1;i++){
778780
for(intc=Console.WindowWidth;c>0;c--)
779781
Console.Write(" ");// To debug use ("{0}", i%10);

0 commit comments

Comments
 (0)