Need help setting foreground color #2665
Replies: 6 comments 1 reply
-
As far as I can tell, the color scheme is properly defined. Value : 90
Foreground : BrightGreen
Background : Magenta
Initialized : True
HasValidColors : True But it doesn't render. I'm running this in Windows Terminal. |
Beta Was this translation helpful? Give feedback.
-
The ColorScheme class has various Attributes (Normal, Focus, HotNormal, HotFocus, Disabled). You only defined the Focus attribute and the others aren't valid. |
Beta Was this translation helpful? Give feedback.
-
So I set all attributes to use the same color scheme? I don't think I'm completely understanding the different attributes. |
Beta Was this translation helpful? Give feedback.
-
Hi @jdhitsolutions thanks reaching out. Here is the C# that results in something similar to your screenshot. Hopefully it will give you some insight into your problem. using System.Text;
using Terminal.Gui;
Application.Init();
var w = new Window();
var left = new FrameView() { Width = Dim.Percent(50),Height = Dim.Fill(), Title = "Process List" };
var right = new FrameView() { Width = Dim.Percent(50), Height = Dim.Fill(), Title = "Process Details", X = Pos.Right(left) };
var allGreen = new ColorScheme
{
Normal = new Terminal.Gui.Attribute(Color.BrightGreen, Color.Magenta),
Disabled = new Terminal.Gui.Attribute(Color.BrightGreen, Color.Magenta),
Focus = new Terminal.Gui.Attribute(Color.BrightGreen, Color.Magenta),
HotFocus = new Terminal.Gui.Attribute(Color.BrightGreen, Color.Magenta),
HotNormal = new Terminal.Gui.Attribute(Color.BrightGreen, Color.Magenta),
};
var txtDetail = new TextView()
{
Text = @"This is a test of the emergency
broadcast system.
Zombies are approaching, flee fast!",
ColorScheme = allGreen,
Width = Dim.Fill(),
Height = Dim.Fill(),
ReadOnly = true
};
right.Add(txtDetail);
var listView = new ListView(new List<string> { "Cat", "Dog", "conhost" })
{
Width = Dim.Fill(),
Height = Dim.Fill(),
};
left.Add(listView);
w.Add(left);
w.Add(right);
Application.Run(w);
Application.Shutdown(); |
Beta Was this translation helpful? Give feedback.
-
I found that if I set the Focus and Disabled attributes to my color scheme, I get the desired result. Not intuitive, but I'm used to hacking my way to the end. Thanks for the comments. |
Beta Was this translation helpful? Give feedback.
-
You welcome. I think set the Focus and the Normal you would got the same result. That the way how |
Beta Was this translation helpful? Give feedback.
-
I'm not sure what I'm doing wrong, or perhaps I'm misunderstanding the documentation. I'm doing this in PowerShell in PowerShell 7 and it mostly works. I can define a textview in a frame like this.
I can get the background in the right-hand frame to change.
Is there something I'm missing to get the foreground color applied? Or how would you do it from C#?
Beta Was this translation helpful? Give feedback.
All reactions