Bug 19883 - Console (Methods) Behaviors in Mac OS X platform.
Summary: Console (Methods) Behaviors in Mac OS X platform.
Status: CONFIRMED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: unspecified
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-05-19 02:39 UTC by khanbashi.k
Modified: 2014-05-19 14:34 UTC (History)
5 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Sample App (4.87 KB, application/zip)
2014-05-19 08:52 UTC, Udham Singh
Details

Description khanbashi.k 2014-05-19 02:39:08 UTC
Case# 1:
In the following statement:
Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Gray;

You will not get a white text as expected. Instead you will an invisible text that match the background color.

Case# 2:
Console.CursorVisible = false;
Is not working. But it does work in Windows platform (8.1 based on my test).

Case# 3:
SoundPlayer sound = new SoundPlayer();
sound.SoundLocation = "../../Resources/Background.wav";
sound.PlayLooping();
or
sound.Play();
Does not play the music. But it does work in Windows platform (8.1 based on my test).

regards,
Khaled
Comment 1 Udham Singh 2014-05-19 08:52:43 UTC
Created attachment 6836 [details]
Sample App

I have checked this issue by creating a simple console application and here is my observations:

1. When I implemented the below code, it does not change text and background color as expected in both platforms Windows as well as Mac.

Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Gray;

2. After implementing "Console.CursorVisible = false;" , I observed that it is not working in-case of Mac while it is working fine on Windows.

3. When I implemented code below, it does not start music in-case of Mac while it is working fine on Windows.

SoundPlayer sound = new SoundPlayer();
sound.SoundLocation = "/Users/MM/Desktop/WavFiles/DustyF1-break23.wav";
sound.PlayLooping();
or
sound.Play ();


Screencast:
For Windows : http://www.screencast.com/t/m2nsk8wIJNkD
For Mac : http://screencast.com/t/fvF1hCJy2kM

Environment Info:

Mac:

Mac OS X 10.9.2
Xamarin Studio 4.2.5 (build 0)
Xamarin.iOS : 7.2.2.2
Xamarin.Android : 4.12.3

--------------------------
Windows:

Windows 8.1
Xamarin Studio : 4.2.5 (build 0)
Xamarin.Android : 4.12.3
Comment 2 Mike Krüger 2014-05-19 14:07:20 UTC
Console coloring works different than you expect it to do:

using System;

public class Foo
{
	public static void Main (string[] args)
	{
		Console.ForegroundColor = ConsoleColor.White;
		Console.BackgroundColor = ConsoleColor.Gray;
		System.Console.WriteLine ("Hello World");
	}
}

Consoles are terminal based and not a drawing surface. Therefore coloring is only updated after you print something.

Try to do a 'System.Console.Clear ();' to clear the screen & set the bg color.
Comment 3 khanbashi.k 2014-05-19 14:20:09 UTC
In windows platform it will works but Mac it does not. I ran your code above and you can see the result in the following like:

http://www.screencast.com/t/rwPj01oU
Comment 4 Mike Krüger 2014-05-19 14:34:26 UTC
Works on mac as well...

http://screencast.com/t/6P2rFrQcTg

It's just the terminal colors that aren't working as you expect. The OSX Terminal default settings are not built for the DOS ANSI colors.
You need manually tweaking the terminal colors. Terminal colors are not given in RGB ... they're just given as ANSI escape codes in general - and that's the limit.

The same may be for case #2 - I don't know if the os x terminal supports that. The Console API is more or less outdated. I wouldn't expect it to work fully on non DOS shells.

It should be safe to set some foreground colors - but that's it. I wouldn't do any high level ANSI operations with it. The API is too basic for it and you're expecting things that are not doable on console level anyways.

I would say #1 and #2 are invalid/working as expected - but I don't know much about case #3.

Note You need to log in before you can comment on or make changes to this bug.