Bug 395689

Summary: konsole ignores .NET color change methods
Product: [Applications] konsole Reporter: egazz
Component: fontAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: normal CC: gassaf, lizhansong
Priority: NOR    
Version: 18.04.2   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:

Description egazz 2018-06-21 10:55:37 UTC
OVERVIEW
=========

I am writing a console application in C# using the .NET framework.  This includes two properties, Console.ForegroundColor and Console.BackgroundColor, which set the output colors for the foreground and background, respectively.  However, konsole ignores them completely.


STEPS TO REPRODUCE
===================

Using System;

namespace test_program {

   class Program {

      static void Main(string[] args) {

         Console.ForegroundColor = ConsoleColor.Red;  // ConsoleColor is an enum, where Red = 12
         Console.WriteLine("this text should be red");

      }

   }

}

EXPECTED RESULTS
==================

The text in the WriteLine method outputs in red.


ACTUAL RESULTS
===============

The text output is in the default color for text (regardless of theme).


ADDITIONAL INFORMATION
=======================

Konsole version is 18.04.2
Plasma-shell version is 5.13.1

The example C# code above works as expected on other terminal emulators (have tried it on xterm and urxvt).  Konsole is in 256 color mode, and things like ls --color=auto also work properly.  So does escaping an ANSI code, e.g.:

> echo -e "\e[0;31mSome red text\e[0m"


Documentation
--------------

ForegroundColor: https://msdn.microsoft.com/en-us/library/system.console.foregroundcolor.aspx
BackgroundColor: https://msdn.microsoft.com/en-us/library/system.console.backgroundcolor.aspx
ConsoleColor (enum): https://docs.microsoft.com/en-us/dotnet/api/system.consolecolor?view=netframework-4.7.1
Comment 1 Christoph Feck 2018-06-21 12:39:35 UTC
I only tried the 'echo' statement from above, and it displayed the text in red. Using Konsole master.
Comment 2 egazz 2018-06-22 12:24:43 UTC
(In reply to Christoph Feck from comment #1)
> I only tried the 'echo' statement from above, and it displayed the text in
> red. Using Konsole master.

Right.  My point is that it's something specific to how Konsole handles the C# properties, given that other commands work in Konsole while my C# example works in other terminal emulators on the same system.
Comment 3 Christoph Feck 2018-07-19 12:38:46 UTC
Are you able to redirect terminal output from the C# program to a file? On UNIX, this is done using the 2> redirection (from stderr), on Windows an equivalent syntax might exist.
Comment 4 Christoph Feck 2018-08-03 11:25:27 UTC
If you can provide the information requested in comment #3, please add it.
Comment 5 Gilbert Assaf 2018-08-17 17:39:15 UTC
I compiled the example with Mono 5.10.1.47 and ran it on konsole 17.12.3 and current master. It did work correctly on both versions.
Comment 6 Christoph Feck 2018-08-31 23:59:53 UTC
To further investigate this issue, KDE developers need the information requested in comment #3. If you can provide it, or need help with finding that information, please add a comment.
Comment 7 egazz 2018-09-17 16:18:52 UTC
I apologize for the delay, somehow I missed the notification of your reply and got involved in other things.  (I'd found a workaround for my program by just using the ASCII escape codes.)

Anyway, it now words properly as of konsole version 18.08.1.  I appreciate your getting back to me!