4444using System . IO ;
4545using System . Threading ;
4646using System . Reflection ;
47+ using System . Runtime . InteropServices ;
4748
4849namespace 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,10 +772,10 @@ 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 delta = Console . CursorTop - target_line + window_height ;
775+ if ( ! isWindows && Console . CursorTop > target_line ) {
776+ var delta = Console . CursorTop - target_line ;
775777 Console . CursorLeft = 0 ;
776- Console . CursorTop = target_line ;
778+ Console . CursorTop = Console . WindowHeight - 1 ;
777779 for ( int i = 0 ; i < delta + 1 ; i ++ ) {
778780 for ( int c = Console . WindowWidth ; c > 0 ; c -- )
779781 Console . Write ( " " ) ; // To debug use ("{0}", i%10);
0 commit comments