1package ansi
2
3// Select Graphic Rendition (SGR) is a command that sets display attributes.
4//
5// Default is 0.
6//
7// CSI Ps ; Ps ... m
8//
9// See: https://vt100.net/docs/vt510-rm/SGR.html
10func SelectGraphicRendition(ps ...Attr) string {
11 if len(ps) == 0 {
12 return ResetStyle
13 }
14
15 return NewStyle(ps...).String()
16}
17
18// SGR is an alias for [SelectGraphicRendition].
19func SGR(ps ...Attr) string {
20 return SelectGraphicRendition(ps...)
21}
22
23var attrStrings = map[int]string{
24 ResetAttr: resetAttr,
25 BoldAttr: boldAttr,
26 FaintAttr: faintAttr,
27 ItalicAttr: italicAttr,
28 UnderlineAttr: underlineAttr,
29 SlowBlinkAttr: slowBlinkAttr,
30 RapidBlinkAttr: rapidBlinkAttr,
31 ReverseAttr: reverseAttr,
32 ConcealAttr: concealAttr,
33 StrikethroughAttr: strikethroughAttr,
34 NormalIntensityAttr: normalIntensityAttr,
35 NoItalicAttr: noItalicAttr,
36 NoUnderlineAttr: noUnderlineAttr,
37 NoBlinkAttr: noBlinkAttr,
38 NoReverseAttr: noReverseAttr,
39 NoConcealAttr: noConcealAttr,
40 NoStrikethroughAttr: noStrikethroughAttr,
41 BlackForegroundColorAttr: blackForegroundColorAttr,
42 RedForegroundColorAttr: redForegroundColorAttr,
43 GreenForegroundColorAttr: greenForegroundColorAttr,
44 YellowForegroundColorAttr: yellowForegroundColorAttr,
45 BlueForegroundColorAttr: blueForegroundColorAttr,
46 MagentaForegroundColorAttr: magentaForegroundColorAttr,
47 CyanForegroundColorAttr: cyanForegroundColorAttr,
48 WhiteForegroundColorAttr: whiteForegroundColorAttr,
49 ExtendedForegroundColorAttr: extendedForegroundColorAttr,
50 DefaultForegroundColorAttr: defaultForegroundColorAttr,
51 BlackBackgroundColorAttr: blackBackgroundColorAttr,
52 RedBackgroundColorAttr: redBackgroundColorAttr,
53 GreenBackgroundColorAttr: greenBackgroundColorAttr,
54 YellowBackgroundColorAttr: yellowBackgroundColorAttr,
55 BlueBackgroundColorAttr: blueBackgroundColorAttr,
56 MagentaBackgroundColorAttr: magentaBackgroundColorAttr,
57 CyanBackgroundColorAttr: cyanBackgroundColorAttr,
58 WhiteBackgroundColorAttr: whiteBackgroundColorAttr,
59 ExtendedBackgroundColorAttr: extendedBackgroundColorAttr,
60 DefaultBackgroundColorAttr: defaultBackgroundColorAttr,
61 ExtendedUnderlineColorAttr: extendedUnderlineColorAttr,
62 DefaultUnderlineColorAttr: defaultUnderlineColorAttr,
63 BrightBlackForegroundColorAttr: brightBlackForegroundColorAttr,
64 BrightRedForegroundColorAttr: brightRedForegroundColorAttr,
65 BrightGreenForegroundColorAttr: brightGreenForegroundColorAttr,
66 BrightYellowForegroundColorAttr: brightYellowForegroundColorAttr,
67 BrightBlueForegroundColorAttr: brightBlueForegroundColorAttr,
68 BrightMagentaForegroundColorAttr: brightMagentaForegroundColorAttr,
69 BrightCyanForegroundColorAttr: brightCyanForegroundColorAttr,
70 BrightWhiteForegroundColorAttr: brightWhiteForegroundColorAttr,
71 BrightBlackBackgroundColorAttr: brightBlackBackgroundColorAttr,
72 BrightRedBackgroundColorAttr: brightRedBackgroundColorAttr,
73 BrightGreenBackgroundColorAttr: brightGreenBackgroundColorAttr,
74 BrightYellowBackgroundColorAttr: brightYellowBackgroundColorAttr,
75 BrightBlueBackgroundColorAttr: brightBlueBackgroundColorAttr,
76 BrightMagentaBackgroundColorAttr: brightMagentaBackgroundColorAttr,
77 BrightCyanBackgroundColorAttr: brightCyanBackgroundColorAttr,
78 BrightWhiteBackgroundColorAttr: brightWhiteBackgroundColorAttr,
79}