StyleCharacteristics overview
This module implements a type that defines all the characteristics of a style, e.g. the foreground and background colors, whether it’s bold or not,… These characteristics are those of the Select Graphic Rendition subset for which info can be found at https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences. Each characteristic is defined as an option, none
meaning that the corresponding characteristic has not been set. It is important to note that although dim and bold use the same reset sequence (i.e. 22), they are completely different characteristics (i.e. a style can be bold and dim at the same time, or just bold, or just dim).
Table of contents
Constructors
fromColorAsBackgroundColor
Builds a StyleCharacteristics that applies color
as background color
Signature
export declare const fromColorAsBackgroundColor: (color: ASColor.Type) => Type
fromColorAsForegroundColor
Builds a StyleCharacteristics that applies color
as foreground color
Signature
export declare const fromColorAsForegroundColor: (color: ASColor.Type) => Type
Destructors
bgColor
Returns the bgColor
property of self
Signature
export declare const bgColor: MTypes.OneArgFunction<Type, ColorOption.Type>
blinkingState
Returns the blinkingState
property of self
Signature
export declare const blinkingState: MTypes.OneArgFunction<Type, BoolOption.Type>
boldState
Returns the boldState
property of self
Signature
export declare const boldState: MTypes.OneArgFunction<Type, BoolOption.Type>
dimState
Returns the dimState
property of self
Signature
export declare const dimState: MTypes.OneArgFunction<Type, BoolOption.Type>
fgColor
Returns the fgColor
property of self
Signature
export declare const fgColor: MTypes.OneArgFunction<Type, ColorOption.Type>
hiddenState
Returns the hiddenState
property of self
Signature
export declare const hiddenState: MTypes.OneArgFunction<Type, BoolOption.Type>
inversedState
Returns the inversedState
property of self
Signature
export declare const inversedState: MTypes.OneArgFunction<Type, BoolOption.Type>
italicState
Returns the italicState
property of self
Signature
export declare const italicState: MTypes.OneArgFunction<Type, BoolOption.Type>
overlinedState
Returns the overlinedState
property of self
Signature
export declare const overlinedState: MTypes.OneArgFunction<Type, BoolOption.Type>
struckThroughState
Returns the struckThroughState
property of self
Signature
export declare const struckThroughState: MTypes.OneArgFunction<Type, BoolOption.Type>
toAnsiString
Returns the ANSI string corresponding to self
Signature
export declare const toAnsiString: MTypes.OneArgFunction<Type, string>
toId
Returns the id of self
Signature
export declare const toId: (self: Type) => string
toSequence
Returns the sequence corresponding to self
Signature
export declare const toSequence: (self: Type) => ASAnsiString.Sequence
underlinedState
Returns the underlinedState
property of self
Signature
export declare const underlinedState: MTypes.OneArgFunction<Type, BoolOption.Type>
Equivalences
equivalence
Equivalence
Signature
export declare const equivalence: Equivalence.Equivalence<Type>
Guards
has
Type guard
Signature
export declare const has: (u: unknown) => u is Type
Instances
bgDefaultColor
Default foreground color StyleCharacteristics
Signature
export declare const bgDefaultColor: Type
blinking
Blinking StyleCharacteristics
Signature
export declare const blinking: Type
bold
Bold StyleCharacteristics
Signature
export declare const bold: Type
defaults
Default StyleCharacteristics
Signature
export declare const defaults: Type
dim
Dim StyleCharacteristics
Signature
export declare const dim: Type
fgDefaultColor
Default foreground color StyleCharacteristics
Signature
export declare const fgDefaultColor: Type
hidden
Hidden StyleCharacteristics
Signature
export declare const hidden: Type
inversed
Inversed StyleCharacteristics
Signature
export declare const inversed: Type
italic
Italic StyleCharacteristics
Signature
export declare const italic: Type
none
Empty StyleCharacteristics
Signature
export declare const none: Type
notBlinking
NotBlinking StyleCharacteristics
Signature
export declare const notBlinking: Type
notBold
NotBold StyleCharacteristics
Signature
export declare const notBold: Type
notDim
NotDim StyleCharacteristics
Signature
export declare const notDim: Type
notHidden
NotHidden StyleCharacteristics
Signature
export declare const notHidden: Type
notInversed
NotInversed StyleCharacteristics
Signature
export declare const notInversed: Type
notItalic
NotItalic StyleCharacteristics
Signature
export declare const notItalic: Type
notOverlined
NotOverlined StyleCharacteristics
Signature
export declare const notOverlined: Type
notStruckThrough
NotStruckThrough StyleCharacteristics
Signature
export declare const notStruckThrough: Type
notUnderlined
NotUnderlined StyleCharacteristics
Signature
export declare const notUnderlined: Type
overlined
Overlined StyleCharacteristics
Signature
export declare const overlined: Type
struckThrough
StruckThrough StyleCharacteristics
Signature
export declare const struckThrough: Type
underlined
Underlined StyleCharacteristics
Signature
export declare const underlined: Type
Models
Type (interface)
Type of a StyleCharacteristics
Signature
export interface Type extends Equal.Equal, MInspectable.Inspectable, Pipeable.Pipeable {
/** BoldState of this style */
readonly boldState: BoolOption.Type
/** DimState of this style */
readonly dimState: BoolOption.Type
/** ItalicState of this style */
readonly italicState: BoolOption.Type
/** UnderlinedState of this style */
readonly underlinedState: BoolOption.Type
/** StruckThroughState of this style */
readonly struckThroughState: BoolOption.Type
/** OverlinedState of this style */
readonly overlinedState: BoolOption.Type
/** InversedState of this style */
readonly inversedState: BoolOption.Type
/** HiddenState of this style */
readonly hiddenState: BoolOption.Type
/** BlinkingState of this style */
readonly blinkingState: BoolOption.Type
/** Foreground color of this style. */
readonly fgColor: ColorOption.Type
/** Background color of this style. */
readonly bgColor: ColorOption.Type
/** @internal */
readonly [_TypeId]: _TypeId
}
moduleTag
Module tag
Signature
export declare const moduleTag: "@parischap/ansi-styles/StyleCharacteristics/"
Predicates
hasBold
Returns true if self
has the bold state
Signature
export declare const hasBold: Predicate.Predicate<Type>
hasDim
Returns true if self
has the dim state
Signature
export declare const hasDim: Predicate.Predicate<Type>
hasNotBold
Returns true if self
has the notBold state
Signature
export declare const hasNotBold: Predicate.Predicate<Type>
hasNotDim
Returns true if self
has the notDim state
Signature
export declare const hasNotDim: Predicate.Predicate<Type>
Utils
difference
Builds a new StyleCharacteristics by removing from self
the StyleCharacteristic’s of that
.
Signature
export declare const difference: (that: Type) => (self: Type) => Type
mergeOver
Builds a new StyleCharacteristics by merging self
and that
. In case of conflict (e.g self
contains Bold
and that
contains NotBold
), the characteristics in that
will prevail.
Signature
export declare const mergeOver: (that: Type) => (self: Type) => Type
mergeUnder
Builds a new StyleCharacteristics by merging self
and that
. In case of conflict (e.g self
contains Bold
and that
contains NotBold
), the characteristics in self
will prevail.
Signature
export declare const mergeUnder: (that: Type) => (self: Type) => Type
substractContext
Builds a new StyleCharacteristics by removing from self
the StyleCharacteristic’s of context
. Same as difference above but:
- If
self
andcontext
containbold
andself
also containsnotDim
andcontext
does not containnotdim
, then do not removebold
. - If
self
andcontext
containdim
andself
also containsnotBold
andcontext
does not containnotBold
, then do not removedim
Signature
export declare const substractContext: (context: Type) => (self: Type) => Type