Struct Attribute
Attributes are used as elements that contain both a foreground and a background or platform specific features.
Remarks
Attributes are needed to map colors to terminal capabilities that might lack colors.
They encode both the foreground and the background color and are used in the ColorScheme
class to define color schemes that can be used in an application.
Inherited Members
System.ValueType.Equals(System.Object)
System.ValueType.GetHashCode()
System.ValueType.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: Terminal.Gui
Assembly: Terminal.Gui.dll
Syntax
public struct Attribute
Constructors
| Improve this Doc View SourceAttribute(Int32)
Initializes a new instance of the Attribute struct with only the value passed to
and trying to get the colors if defined.
Declaration
public Attribute(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | Value. |
Attribute(Int32, Color, Color)
Initializes a new instance of the Attribute struct.
Declaration
public Attribute(int value, Color foreground, Color background)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | Value. |
Color | foreground | Foreground |
Color | background | Background |
Attribute(Color)
Initializes a new instance of the Attribute struct
with the same colors for the foreground and background.
Declaration
public Attribute(Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The color. |
Attribute(Color, Color)
Initializes a new instance of the Attribute struct.
Declaration
public Attribute(Color foreground = Color.Black, Color background = Color.Black)
Parameters
Type | Name | Description |
---|---|---|
Color | foreground | Foreground |
Color | background | Background |
Properties
| Improve this Doc View SourceBackground
The background color.
Declaration
public readonly Color Background { get; }
Property Value
Type | Description |
---|---|
Color |
Foreground
The foreground color.
Declaration
public readonly Color Foreground { get; }
Property Value
Type | Description |
---|---|
Color |
HasValidColors
Returns true if the Attribute is valid (both foreground and background have valid color values).
Declaration
public readonly bool HasValidColors { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Initialized
If true the attribute has been initialized by a ConsoleDriver and
thus has Value that is valid for that driver. If false the Foreground
and Background colors may have been set '-1' but
the attribute has not been mapped to a ConsoleDriver specific color value.
Declaration
public bool Initialized { readonly get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Value
The ConsoleDriver-specific color attribute value. If Initialized is false
the value of this property is invalid (typically because the Attribute was created before a driver was loaded)
and the attribute should be re-made (see Make(Color, Color)) before it is used.
Declaration
public readonly int Value { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceGet()
Gets the current Attribute from the driver.
Declaration
public static Attribute Get()
Returns
Type | Description |
---|---|
Attribute | The current attribute. |
Make(Color, Color)
Creates an Attribute from the specified foreground and background colors.
Declaration
public static Attribute Make(Color foreground, Color background)
Parameters
Type | Name | Description |
---|---|---|
Color | foreground | Foreground color to use. |
Color | background | Background color to use. |
Returns
Type | Description |
---|---|
Attribute | The new attribute. |
Operators
| Improve this Doc View SourceImplicit(Int32 to Attribute)
Implicitly convert an driver-specific color value into an Attribute
Declaration
public static implicit operator Attribute(int v)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | v | value |
Returns
Type | Description |
---|---|
Attribute | An attribute with the specified driver-specific color value. |
Implicit(Attribute to Int32)
Implicit conversion from an Attribute to the underlying, driver-specific, Int32 representation
of the color.
Declaration
public static implicit operator int (Attribute c)
Parameters
Type | Name | Description |
---|---|---|
Attribute | c | The attribute to convert |
Returns
Type | Description |
---|---|
System.Int32 | The driver-specific color value stored in the attribute. |