44
44
using System . IO ;
45
45
using System . Threading ;
46
46
using System . Reflection ;
47
+ using System . Runtime . InteropServices ;
47
48
48
49
namespace Mono . Terminal {
49
50
@@ -409,6 +410,8 @@ public static Handler Alt (char c, ConsoleKey k, KeyHandler h)
409
410
410
411
static Handler [ ] handlers ;
411
412
413
+ private readonly bool isWindows ;
414
+
412
415
/// <summary>
413
416
/// Initializes a new instance of the LineEditor, using the specified name for
414
417
/// retrieving and storing the history. The history will default to 10 entries.
@@ -467,6 +470,7 @@ public LineEditor (string name, int histsize)
467
470
468
471
history = new History ( name , histsize ) ;
469
472
473
+ isWindows = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ;
470
474
GetUnixConsoleReset ( ) ;
471
475
//if (File.Exists ("log"))File.Delete ("log");
472
476
//log = File.CreateText ("log");
@@ -482,9 +486,7 @@ void GetUnixConsoleReset ()
482
486
//
483
487
// On Unix, we want to be able to reset the color for the pop-up completion
484
488
//
485
- int p = ( int ) Environment . OSVersion . Platform ;
486
- var is_unix = ( p == 4 ) || ( p == 128 ) ;
487
- if ( ! is_unix )
489
+ if ( isWindows )
488
490
return ;
489
491
490
492
// Sole purpose of this call is to initialize the Terminfo driver
@@ -770,8 +772,7 @@ void ShowCompletions (string prefix, string [] completions)
770
772
// Ensure we have space, determine window size
771
773
int window_height = System . Math . Min ( completions . Length , Console . WindowHeight / 5 ) ;
772
774
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 ) {
775
776
var delta = Console . CursorTop - target_line ;
776
777
Console . CursorLeft = 0 ;
777
778
Console . CursorTop = Console . WindowHeight - 1 ;
0 commit comments