Class Parameter
- Namespace
- Microlithix.Text.Ansi.Element
- Assembly
- AnsiParser.dll
Represents a single parameter in a control sequence.
public record Parameter : IEquatable<Parameter>
- Inheritance
-
Parameter
- Implements
- Inherited Members
Remarks
As defined in ECMA-48, a control sequence may contain a string of
characters in the range 0x30
...0x3f
representing one or more
parameters for the control function. Such a string is referred to as the
parameter string.
If the parameter string begins with a character in the range
<code>0x3c</code>...<code>0x3f</code>, then it is for private or experimental use
and not defined in ECMA-48. If, on the other hand, the parameter string
begins with a character in the range <code>0x30</code>...<code>0x3b</code>, then it
is a standardized parameter string.
A standardized parameter string may be divided into parameter sub-strings
by the semi-colon (;) character, with each parameter sub-string
representing one parameter for the control function. Each parameter
sub-string will be parsed into one <xref href="Microlithix.Text.Ansi.Element.Parameter" data-throw-if-not-resolved="false"></xref> instance.
Each parameter sub-string may be further divided into parts separated
by the colon (:) character, where each part consists of a sequence of
decimal digits representing a positive integer value.
A <xref href="Microlithix.Text.Ansi.Element.Parameter" data-throw-if-not-resolved="false"></xref> instance represents a single parameter parsed
from a single parameter sub-string into its separate integer parts.
Control sequences can contain multiple parameters
separated by the semi-colon (;) character. For example,
"<code>1;5:4;32</code>" is a valid sequence of three parameters,
with the second parameter having two parts (5 and 4).
</p>
Although the specification allows for a parameter to have multiple parts, such use is rare. In most cases, a parameter will consist of a single sequence of decimal digits representing a single integer value.
Any part missing from the control sequence should be interpreted as having an application-defined default value. Such missing parts are represented in the Parameter instance with a value of -1.
Note that ECMA-48 refers to the parameter sub-parts as "parameter sub-strings".
Constructors
- Parameter()
Creates a new Parameter instance with a single part having a value of -1, indicating that the parameter should be interpreted as having an application-defined default value.
- Parameter(params int[])
Creates a new Parameter instance from a specified list of parts, where each part is either a positive integer, or a value of -1 indicating that the part should be interpreted as having an application-defined default value.
Properties
- Parts
In most cases, a parameter consists of a single integer value that can be accessed via the Value property. When a parameter consists of multiple integer values, you can use the Parts property to access all of them. Any part with a negative value indicates that the part should be interpreted as having an application-defined default value.
- Value
Returns the integer value of the first part of the parameter. In almost all cases, parameters have only one part and you can use this property to access the parameter's value. A value of -1 indicates that the parameter should be interpreted as having an application-defined default value.
Methods
- GetPart(int)
Returns one integer part of the Parameter.
- GetPartOrDefault(int, int)
Returns one integer part of the Parameter, or a default value if the part doesn't exist.
- IsLegacySGRParameter()
Checks if the parameter is a SetForegroundColor or SetBackgroundColor parameter in legacy format.
- ToString()
Returns a string representation of the Parameter.