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

Fixed text clearing in cmd.exe #2

Merged
merged 4 commits into from
Aug 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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