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

Commit

Permalink
fix: text overriding was only platform specific (check platform)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukáš Jurčík committed Jul 30, 2018
1 parent 5a7e3e2 commit 0d43552
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions LineEditor/getline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
using System.IO;
using System.Threading;
using System.Reflection;
using System.Runtime.InteropServices;

namespace Mono.Terminal {

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

static Handler [] handlers;

private readonly bool isWindows;

/// <summary>
/// Initializes a new instance of the LineEditor, using the specified name for
/// retrieving and storing the history. The history will default to 10 entries.
Expand Down Expand Up @@ -467,6 +470,7 @@ public LineEditor (string name, int histsize)

history = new History (name, histsize);

isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
GetUnixConsoleReset ();
//if (File.Exists ("log"))File.Delete ("log");
//log = File.CreateText ("log");
Expand All @@ -482,9 +486,7 @@ void GetUnixConsoleReset ()
//
// 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
Expand Down Expand Up @@ -770,10 +772,10 @@ void ShowCompletions (string prefix, string [] completions)
// 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);
Expand Down

0 comments on commit 0d43552

Please sign in to comment.