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

Commit

Permalink
Merge pull request #1 from VEIT-Electronics/bugfix/ENG-232-line-edito…
Browse files Browse the repository at this point in the history
…r-completions

fix: clearing previous text when showing completions in cmd.exe
  • Loading branch information
dmako committed Jul 30, 2018
2 parents de0e3fc + 0d43552 commit 3d802e7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 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,8 +772,7 @@ 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 saved_left = Console.CursorLeft;
if (!isWindows && Console.CursorTop > target_line){
var delta = Console.CursorTop-target_line;
Console.CursorLeft = 0;
Console.CursorTop = Console.WindowHeight-1;
Expand Down

0 comments on commit 3d802e7

Please sign in to comment.