sai 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/README.md +40 -7
- data/lib/sai/ansi.rb +5 -5
- data/lib/sai/conversion/color_sequence.rb +31 -31
- data/lib/sai/conversion/rgb.rb +17 -17
- data/lib/sai/decorator.rb +201 -171
- data/lib/sai/mode_selector.rb +298 -0
- data/lib/sai/support.rb +99 -98
- data/lib/sai/terminal/capabilities.rb +22 -22
- data/lib/sai/terminal/color_mode.rb +7 -7
- data/lib/sai.rb +106 -77
- data/sig/sai/ansi.rbs +5 -5
- data/sig/sai/conversion/color_sequence.rbs +21 -21
- data/sig/sai/conversion/rgb.rbs +17 -17
- data/sig/sai/decorator.rbs +103 -76
- data/sig/sai/mode_selector.rbs +319 -0
- data/sig/sai/support.rbs +50 -37
- data/sig/sai/terminal/capabilities.rbs +16 -16
- data/sig/sai/terminal/color_mode.rbs +7 -7
- data/sig/sai.rbs +92 -66
- metadata +6 -4
data/sig/sai/decorator.rbs
CHANGED
@@ -4,123 +4,123 @@ module Sai
|
|
4
4
|
# A decorator for applying ANSI styles and colors to text
|
5
5
|
#
|
6
6
|
# @author {https://aaronmallen.me Aaron Allen}
|
7
|
-
# @since
|
7
|
+
# @since 0.1.0
|
8
8
|
#
|
9
9
|
# @api public
|
10
10
|
class Decorator
|
11
11
|
# Initialize a new instance of Decorator
|
12
12
|
#
|
13
13
|
# @author {https://aaronmallen.me Aaron Allen}
|
14
|
-
# @since
|
14
|
+
# @since 0.1.0
|
15
15
|
#
|
16
16
|
# @api private
|
17
17
|
#
|
18
|
-
# @param
|
18
|
+
# @param mode [Integer] the color mode to use
|
19
19
|
#
|
20
20
|
# @return [Decorator] the new instance of Decorator
|
21
|
-
# @rbs (Integer
|
22
|
-
def initialize: (Integer
|
21
|
+
# @rbs (?mode: Integer) -> void
|
22
|
+
def initialize: (?mode: Integer) -> void
|
23
23
|
|
24
|
-
def black: () ->
|
24
|
+
def black: () -> Decorator
|
25
25
|
|
26
|
-
def blue: () ->
|
26
|
+
def blue: () -> Decorator
|
27
27
|
|
28
|
-
def bright_black: () ->
|
28
|
+
def bright_black: () -> Decorator
|
29
29
|
|
30
|
-
def bright_blue: () ->
|
30
|
+
def bright_blue: () -> Decorator
|
31
31
|
|
32
|
-
def bright_cyan: () ->
|
32
|
+
def bright_cyan: () -> Decorator
|
33
33
|
|
34
|
-
def bright_green: () ->
|
34
|
+
def bright_green: () -> Decorator
|
35
35
|
|
36
|
-
def bright_magenta: () ->
|
36
|
+
def bright_magenta: () -> Decorator
|
37
37
|
|
38
|
-
def bright_red: () ->
|
38
|
+
def bright_red: () -> Decorator
|
39
39
|
|
40
|
-
def bright_white: () ->
|
40
|
+
def bright_white: () -> Decorator
|
41
41
|
|
42
|
-
def bright_yellow: () ->
|
42
|
+
def bright_yellow: () -> Decorator
|
43
43
|
|
44
|
-
def cyan: () ->
|
44
|
+
def cyan: () -> Decorator
|
45
45
|
|
46
|
-
def green: () ->
|
46
|
+
def green: () -> Decorator
|
47
47
|
|
48
|
-
def magenta: () ->
|
48
|
+
def magenta: () -> Decorator
|
49
49
|
|
50
|
-
def on_black: () ->
|
50
|
+
def on_black: () -> Decorator
|
51
51
|
|
52
|
-
def on_blue: () ->
|
52
|
+
def on_blue: () -> Decorator
|
53
53
|
|
54
|
-
def on_bright_black: () ->
|
54
|
+
def on_bright_black: () -> Decorator
|
55
55
|
|
56
|
-
def on_bright_blue: () ->
|
56
|
+
def on_bright_blue: () -> Decorator
|
57
57
|
|
58
|
-
def on_bright_cyan: () ->
|
58
|
+
def on_bright_cyan: () -> Decorator
|
59
59
|
|
60
|
-
def on_bright_green: () ->
|
60
|
+
def on_bright_green: () -> Decorator
|
61
61
|
|
62
|
-
def on_bright_magenta: () ->
|
62
|
+
def on_bright_magenta: () -> Decorator
|
63
63
|
|
64
|
-
def on_bright_red: () ->
|
64
|
+
def on_bright_red: () -> Decorator
|
65
65
|
|
66
|
-
def on_bright_white: () ->
|
66
|
+
def on_bright_white: () -> Decorator
|
67
67
|
|
68
|
-
def on_bright_yellow: () ->
|
68
|
+
def on_bright_yellow: () -> Decorator
|
69
69
|
|
70
|
-
def on_cyan: () ->
|
70
|
+
def on_cyan: () -> Decorator
|
71
71
|
|
72
|
-
def on_green: () ->
|
72
|
+
def on_green: () -> Decorator
|
73
73
|
|
74
|
-
def on_magenta: () ->
|
74
|
+
def on_magenta: () -> Decorator
|
75
75
|
|
76
|
-
def on_red: () ->
|
76
|
+
def on_red: () -> Decorator
|
77
77
|
|
78
|
-
def on_white: () ->
|
78
|
+
def on_white: () -> Decorator
|
79
79
|
|
80
|
-
def on_yellow: () ->
|
80
|
+
def on_yellow: () -> Decorator
|
81
81
|
|
82
|
-
def red: () ->
|
82
|
+
def red: () -> Decorator
|
83
83
|
|
84
|
-
def white: () ->
|
84
|
+
def white: () -> Decorator
|
85
85
|
|
86
|
-
def yellow: () ->
|
86
|
+
def yellow: () -> Decorator
|
87
87
|
|
88
|
-
def blink: () ->
|
88
|
+
def blink: () -> Decorator
|
89
89
|
|
90
|
-
def bold: () ->
|
90
|
+
def bold: () -> Decorator
|
91
91
|
|
92
|
-
def conceal: () ->
|
92
|
+
def conceal: () -> Decorator
|
93
93
|
|
94
|
-
def dim: () ->
|
94
|
+
def dim: () -> Decorator
|
95
95
|
|
96
|
-
def italic: () ->
|
96
|
+
def italic: () -> Decorator
|
97
97
|
|
98
|
-
def no_blink: () ->
|
98
|
+
def no_blink: () -> Decorator
|
99
99
|
|
100
|
-
def no_conceal: () ->
|
100
|
+
def no_conceal: () -> Decorator
|
101
101
|
|
102
|
-
def no_italic: () ->
|
102
|
+
def no_italic: () -> Decorator
|
103
103
|
|
104
|
-
def no_reverse: () ->
|
104
|
+
def no_reverse: () -> Decorator
|
105
105
|
|
106
|
-
def no_strike: () ->
|
106
|
+
def no_strike: () -> Decorator
|
107
107
|
|
108
|
-
def no_underline: () ->
|
108
|
+
def no_underline: () -> Decorator
|
109
109
|
|
110
|
-
def normal_intensity: () ->
|
110
|
+
def normal_intensity: () -> Decorator
|
111
111
|
|
112
|
-
def rapid_blink: () ->
|
112
|
+
def rapid_blink: () -> Decorator
|
113
113
|
|
114
|
-
def reverse: () ->
|
114
|
+
def reverse: () -> Decorator
|
115
115
|
|
116
|
-
def strike: () ->
|
116
|
+
def strike: () -> Decorator
|
117
117
|
|
118
|
-
def underline: () ->
|
118
|
+
def underline: () -> Decorator
|
119
119
|
|
120
120
|
# Apply the styles and colors to the text
|
121
121
|
#
|
122
122
|
# @author {https://aaronmallen.me Aaron Allen}
|
123
|
-
# @since
|
123
|
+
# @since 0.1.0
|
124
124
|
#
|
125
125
|
# @api public
|
126
126
|
#
|
@@ -143,7 +143,7 @@ module Sai
|
|
143
143
|
# Apply a hexadecimal color to the foreground
|
144
144
|
#
|
145
145
|
# @author {https://aaronmallen.me Aaron Allen}
|
146
|
-
# @since
|
146
|
+
# @since 0.1.0
|
147
147
|
#
|
148
148
|
# @api public
|
149
149
|
#
|
@@ -153,14 +153,14 @@ module Sai
|
|
153
153
|
# @param code [String] the hex color code
|
154
154
|
#
|
155
155
|
# @raise [ArgumentError] if the hex code is invalid
|
156
|
-
# @return [
|
157
|
-
# @rbs (String code) ->
|
158
|
-
def hex: (String code) ->
|
156
|
+
# @return [Decorator] a new instance of Decorator with the hex color applied
|
157
|
+
# @rbs (String code) -> Decorator
|
158
|
+
def hex: (String code) -> Decorator
|
159
159
|
|
160
160
|
# Apply a hexadecimal color to the background
|
161
161
|
#
|
162
162
|
# @author {https://aaronmallen.me Aaron Allen}
|
163
|
-
# @since
|
163
|
+
# @since 0.1.0
|
164
164
|
#
|
165
165
|
# @api public
|
166
166
|
#
|
@@ -170,14 +170,14 @@ module Sai
|
|
170
170
|
# @param code [String] the hex color code
|
171
171
|
#
|
172
172
|
# @raise [ArgumentError] if the hex code is invalid
|
173
|
-
# @return [
|
174
|
-
# @rbs (String code) ->
|
175
|
-
def on_hex: (String code) ->
|
173
|
+
# @return [Decorator] a new instance of Decorator with the hex color applied
|
174
|
+
# @rbs (String code) -> Decorator
|
175
|
+
def on_hex: (String code) -> Decorator
|
176
176
|
|
177
177
|
# Apply an RGB color to the background
|
178
178
|
#
|
179
179
|
# @author {https://aaronmallen.me Aaron Allen}
|
180
|
-
# @since
|
180
|
+
# @since 0.1.0
|
181
181
|
#
|
182
182
|
# @api public
|
183
183
|
#
|
@@ -189,14 +189,14 @@ module Sai
|
|
189
189
|
# @param blue [Integer] the blue component
|
190
190
|
#
|
191
191
|
# @raise [ArgumentError] if the RGB values are out of range
|
192
|
-
# @return [
|
193
|
-
# @rbs (Integer red, Integer green, Integer blue) ->
|
194
|
-
def on_rgb: (Integer red, Integer green, Integer blue) ->
|
192
|
+
# @return [Decorator] a new instance of Decorator with the RGB color applied
|
193
|
+
# @rbs (Integer red, Integer green, Integer blue) -> Decorator
|
194
|
+
def on_rgb: (Integer red, Integer green, Integer blue) -> Decorator
|
195
195
|
|
196
196
|
# Apply an RGB color to the foreground
|
197
197
|
#
|
198
198
|
# @author {https://aaronmallen.me Aaron Allen}
|
199
|
-
# @since
|
199
|
+
# @since 0.1.0
|
200
200
|
#
|
201
201
|
# @api public
|
202
202
|
#
|
@@ -208,16 +208,32 @@ module Sai
|
|
208
208
|
# @param blue [Integer] the blue component
|
209
209
|
#
|
210
210
|
# @raise [ArgumentError] if the RGB values are out of range
|
211
|
-
# @return [
|
212
|
-
# @rbs (Integer red, Integer green, Integer blue) ->
|
213
|
-
def rgb: (Integer red, Integer green, Integer blue) ->
|
211
|
+
# @return [Decorator] a new instance of Decorator with the RGB color applied
|
212
|
+
# @rbs (Integer red, Integer green, Integer blue) -> Decorator
|
213
|
+
def rgb: (Integer red, Integer green, Integer blue) -> Decorator
|
214
|
+
|
215
|
+
# Apply a specific color mode to the decorator
|
216
|
+
#
|
217
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
218
|
+
# @since 0.2.0
|
219
|
+
#
|
220
|
+
# @api public
|
221
|
+
#
|
222
|
+
# @example
|
223
|
+
# decorator.with_mode(Sai.mode.basic_auto) #=> => #<Sai::Decorator:0x123 @mode=1>
|
224
|
+
#
|
225
|
+
# @param mode [Integer] the color mode to use
|
226
|
+
#
|
227
|
+
# @return [Decorator] a new instance of Decorator with the applied color mode
|
228
|
+
# @rbs (Integer mode) -> Decorator
|
229
|
+
def with_mode: (Integer mode) -> Decorator
|
214
230
|
|
215
231
|
private
|
216
232
|
|
217
233
|
# Apply a named color to the specified style type
|
218
234
|
#
|
219
235
|
# @author {https://aaronmallen.me Aaron Allen}
|
220
|
-
# @since
|
236
|
+
# @since 0.1.0
|
221
237
|
#
|
222
238
|
# @api private
|
223
239
|
#
|
@@ -225,22 +241,33 @@ module Sai
|
|
225
241
|
# @param color [Symbol] the color to apply
|
226
242
|
#
|
227
243
|
# @raise [ArgumentError] if the color is invalid
|
228
|
-
# @return [
|
229
|
-
# @rbs (Conversion::ColorSequence::style_type style_type, Symbol color) ->
|
230
|
-
def apply_named_color: (Conversion::ColorSequence::style_type style_type, Symbol color) ->
|
244
|
+
# @return [Decorator] a new instance of Decorator with the color applied
|
245
|
+
# @rbs (Conversion::ColorSequence::style_type style_type, Symbol color) -> Decorator
|
246
|
+
def apply_named_color: (Conversion::ColorSequence::style_type style_type, Symbol color) -> Decorator
|
231
247
|
|
232
248
|
# Apply a style to the text
|
233
249
|
#
|
234
250
|
# @author {https://aaronmallen.me Aaron Allen}
|
235
|
-
# @since
|
251
|
+
# @since 0.1.0
|
236
252
|
#
|
237
253
|
# @api private
|
238
254
|
#
|
239
255
|
# @param style [String, Symbol] the style to apply
|
240
256
|
#
|
241
257
|
# @raise [ArgumentError] if the style is invalid
|
242
|
-
# @return [
|
258
|
+
# @return [Decorator] a new instance of Decorator with the style applied
|
243
259
|
# @rbs (String | Symbol style) -> self
|
244
260
|
def apply_style: (String | Symbol style) -> self
|
261
|
+
|
262
|
+
# Check if text should be decorated
|
263
|
+
#
|
264
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
265
|
+
# @since 0.2.0
|
266
|
+
#
|
267
|
+
# @api private
|
268
|
+
#
|
269
|
+
# @return [Boolean] `true` if text should be decorated, `false` otherwise
|
270
|
+
# @rbs () -> bool
|
271
|
+
def should_decorate?: () -> bool
|
245
272
|
end
|
246
273
|
end
|
@@ -0,0 +1,319 @@
|
|
1
|
+
# Generated from lib/sai/mode_selector.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Sai
|
4
|
+
# Color mode selection methods
|
5
|
+
#
|
6
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
7
|
+
# @since 0.2.0
|
8
|
+
#
|
9
|
+
# @api public
|
10
|
+
module ModeSelector
|
11
|
+
# Set the color mode to 256 color (8-bit) mode
|
12
|
+
#
|
13
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
14
|
+
# @since 0.2.0
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# Sai.mode.advanced #=> 3
|
20
|
+
# Sai.mode.eight_bit #=> 3
|
21
|
+
# Sai.mode.color256 #=> 3
|
22
|
+
#
|
23
|
+
# @return [Integer] the color mode
|
24
|
+
# @rbs () -> Integer
|
25
|
+
def self.advanced: () -> Integer
|
26
|
+
|
27
|
+
alias self.color256 self.advanced
|
28
|
+
|
29
|
+
alias self.colour256 self.advanced
|
30
|
+
|
31
|
+
alias self.eight_bit self.advanced
|
32
|
+
|
33
|
+
alias self.two_hundred_fifty_six_color self.advanced
|
34
|
+
|
35
|
+
alias self.two_hundred_fifty_six_colour self.advanced
|
36
|
+
|
37
|
+
# Automatically set the color mode to advanced (8-bit) or lower
|
38
|
+
#
|
39
|
+
# Sets the terminal color mode to advanced (8-bit) support, which provides 256 colors
|
40
|
+
# The mode will automatically downgrade to 4-bit, 3-bit, or NO_COLOR if the terminal doesn't support
|
41
|
+
# advanced colors
|
42
|
+
#
|
43
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
44
|
+
# @since 0.2.0
|
45
|
+
#
|
46
|
+
# @api public
|
47
|
+
#
|
48
|
+
# @example With color support enabled
|
49
|
+
# ENV['COLORTERM'] #=> nil
|
50
|
+
# ENV['TERM'] #=> 'xterm-256color'
|
51
|
+
# Sai.mode.ansi_auto #=> 3
|
52
|
+
# Sai.mode.four_bit_auto #=> 3
|
53
|
+
# Sai.mode.color_16_auto #=> 3
|
54
|
+
#
|
55
|
+
# @example With only 4-bit color support
|
56
|
+
# ENV['NO_COLOR'] #=> nil
|
57
|
+
# ENV['TERM'] #=> 'ansi'
|
58
|
+
# Sai.mode.ansi_auto #=> 2
|
59
|
+
# Sai.mode.four_bit_auto #=> 2
|
60
|
+
# Sai.mode.color_16_auto #=> 2
|
61
|
+
#
|
62
|
+
# @example With only 3-bit color support
|
63
|
+
# ENV['TERM'] #=> nil
|
64
|
+
# ENV['NO_COLOR'] #=> nil
|
65
|
+
# Sai.mode.ansi_auto #=> 1
|
66
|
+
# Sai.mode.four_bit_auto #=> 1
|
67
|
+
# Sai.mode.color16_auto #=> 1
|
68
|
+
#
|
69
|
+
# @example With color support disabled
|
70
|
+
# ENV['NO_COLOR'] #=> 'true'
|
71
|
+
# Sai.mode.ansi_auto #=> 0
|
72
|
+
# Sai.mode.four_bit_auto #=> 0
|
73
|
+
# Sai.mode.color16_auto #=> 0
|
74
|
+
#
|
75
|
+
# @return [Integer] the color mode
|
76
|
+
# @rbs () -> Integer
|
77
|
+
def self.advanced_auto: () -> Integer
|
78
|
+
|
79
|
+
alias self.color256_auto self.advanced_auto
|
80
|
+
|
81
|
+
alias self.colour256_auto self.advanced_auto
|
82
|
+
|
83
|
+
alias self.eight_bit_auto self.advanced_auto
|
84
|
+
|
85
|
+
alias self.two_hundred_fifty_six_color_auto self.advanced_auto
|
86
|
+
|
87
|
+
alias self.two_hundred_fifty_six_colour_auto self.advanced_auto
|
88
|
+
|
89
|
+
# Set the color mode to 16 color (4-bit) mode
|
90
|
+
#
|
91
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
92
|
+
# @since 0.2.0
|
93
|
+
#
|
94
|
+
# @api public
|
95
|
+
#
|
96
|
+
# @example
|
97
|
+
# Sai.mode.ansi #=> 2
|
98
|
+
# Sai.mode.color16 #=> 2
|
99
|
+
# Sai.mode.four_bit #=> 2
|
100
|
+
#
|
101
|
+
# @return [Integer] the color mode
|
102
|
+
# @rbs () -> Integer
|
103
|
+
def self.ansi: () -> Integer
|
104
|
+
|
105
|
+
alias self.color16 self.ansi
|
106
|
+
|
107
|
+
alias self.colour16 self.ansi
|
108
|
+
|
109
|
+
alias self.four_bit self.ansi
|
110
|
+
|
111
|
+
alias self.sixteen_color self.ansi
|
112
|
+
|
113
|
+
alias self.sixteen_colour self.ansi
|
114
|
+
|
115
|
+
# Automatically set the color mode to ansi (4-bit) or lower
|
116
|
+
#
|
117
|
+
# Sets the terminal color mode to ansi (4-bit) support, which provides 8 colors
|
118
|
+
# The mode will automatically downgrade to 3-bit or NO_COLOR if the terminal doesn't support
|
119
|
+
# ansi colors
|
120
|
+
#
|
121
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
122
|
+
# @since 0.2.0
|
123
|
+
#
|
124
|
+
# @api public
|
125
|
+
#
|
126
|
+
# @example With color support enabled
|
127
|
+
# ENV['NO_COLOR'] #=> nil
|
128
|
+
# ENV['TERM'] #=> 'ansi'
|
129
|
+
# Sai.mode.ansi_auto #=> 2
|
130
|
+
# Sai.mode.four_bit_auto #=> 2
|
131
|
+
# Sai.mode.color_16_auto #=> 2
|
132
|
+
#
|
133
|
+
# @example With only 3-bit color support
|
134
|
+
# ENV['TERM'] #=> nil
|
135
|
+
# ENV['NO_COLOR'] #=> nil
|
136
|
+
# Sai.mode.ansi_auto #=> 1
|
137
|
+
# Sai.mode.four_bit_auto #=> 1
|
138
|
+
# Sai.mode.color16_auto #=> 1
|
139
|
+
#
|
140
|
+
# @example With color support disabled
|
141
|
+
# ENV['NO_COLOR'] #=> 'true'
|
142
|
+
# Sai.mode.ansi_auto #=> 0
|
143
|
+
# Sai.mode.four_bit_auto #=> 0
|
144
|
+
# Sai.mode.color16_auto #=> 0
|
145
|
+
#
|
146
|
+
# @return [Integer] the color mode
|
147
|
+
# @rbs () -> Integer
|
148
|
+
def self.ansi_auto: () -> Integer
|
149
|
+
|
150
|
+
alias self.color16_auto self.ansi_auto
|
151
|
+
|
152
|
+
alias self.colour16_auto self.ansi_auto
|
153
|
+
|
154
|
+
alias self.four_bit_auto self.ansi_auto
|
155
|
+
|
156
|
+
alias self.sixteen_color_auto self.ansi_auto
|
157
|
+
|
158
|
+
alias self.sixteen_colour_auto self.ansi_auto
|
159
|
+
|
160
|
+
# Set the color mode based on the current Terminal's capabilities
|
161
|
+
#
|
162
|
+
# This is the default color mode for {Sai}
|
163
|
+
#
|
164
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
165
|
+
# @since 0.2.0
|
166
|
+
#
|
167
|
+
# @api public
|
168
|
+
#
|
169
|
+
# @example With 24-bit color support enabled
|
170
|
+
# ENV['COLORTERM'] #=> 'truecolor'
|
171
|
+
# Sai.node.auto #=> 4
|
172
|
+
#
|
173
|
+
# @example With only 8-bit color support enabled
|
174
|
+
# ENV['COLORTERM'] #=> nil
|
175
|
+
# ENV['TERM'] #=> 'xterm-256color'
|
176
|
+
# Sai.mode.auto #=> 3
|
177
|
+
#
|
178
|
+
# @example With only 4-bit color support
|
179
|
+
# ENV['NO_COLOR'] #=> nil
|
180
|
+
# ENV['TERM'] #=> 'ansi'
|
181
|
+
# Sai.mode.auto #=> 2
|
182
|
+
#
|
183
|
+
# @example With only 3-bit color support
|
184
|
+
# ENV['TERM'] #=> nil
|
185
|
+
# ENV['NO_COLOR'] #=> nil
|
186
|
+
# Sai.mode.auto #=> 1
|
187
|
+
#
|
188
|
+
# @example With color support disabled
|
189
|
+
# ENV['NO_COLOR'] #=> 'true'
|
190
|
+
# Sai.mode.auto #=> 0
|
191
|
+
#
|
192
|
+
# @return [Integer] the color mode
|
193
|
+
# @rbs () -> Integer
|
194
|
+
def self.auto: () -> Integer
|
195
|
+
|
196
|
+
alias self.color16m_auto self.auto
|
197
|
+
|
198
|
+
alias self.colour16m_auto self.auto
|
199
|
+
|
200
|
+
alias self.enabled self.auto
|
201
|
+
|
202
|
+
alias self.sixteen_million_color_auto self.auto
|
203
|
+
|
204
|
+
alias self.sixteen_million_colour_auto self.auto
|
205
|
+
|
206
|
+
alias self.twenty_for_bit_auto self.auto
|
207
|
+
|
208
|
+
# Set the color mode to 8 color (3-bit) mode
|
209
|
+
#
|
210
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
211
|
+
# @since 0.2.0
|
212
|
+
#
|
213
|
+
# @api public
|
214
|
+
#
|
215
|
+
# @example
|
216
|
+
# Sai.mode.basic #=> 1
|
217
|
+
# Sai.mode.color8 #=> 1
|
218
|
+
# Sai.mode.three_bit #=> 1
|
219
|
+
#
|
220
|
+
# @return [Integer] the 4 color (3-bit) mode
|
221
|
+
# @rbs () -> Integer
|
222
|
+
def self.basic: () -> Integer
|
223
|
+
|
224
|
+
alias self.color8 self.basic
|
225
|
+
|
226
|
+
alias self.colour8 self.basic
|
227
|
+
|
228
|
+
alias self.eight_color self.basic
|
229
|
+
|
230
|
+
alias self.eight_colour self.basic
|
231
|
+
|
232
|
+
alias self.three_bit self.basic
|
233
|
+
|
234
|
+
# Automatically set the color mode to basic (3-bit) or lower
|
235
|
+
#
|
236
|
+
# Sets the terminal color mode to basic (3-bit) support, which provides 8 colors
|
237
|
+
# The mode will automatically downgrade to NO_COLOR if the terminal doesn't support
|
238
|
+
# basic colors
|
239
|
+
#
|
240
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
241
|
+
# @since 0.2.0
|
242
|
+
#
|
243
|
+
# @api public
|
244
|
+
#
|
245
|
+
# @example With color support enabled
|
246
|
+
# ENV['NO_COLOR'] #=> nil
|
247
|
+
# Sai.mode.basic_auto #=> 1
|
248
|
+
# Sai.mode.three_bit_auto #=> 1
|
249
|
+
# Sai.mode.color8_auto #=> 1
|
250
|
+
#
|
251
|
+
# @example With color support disabled
|
252
|
+
# ENV['NO_COLOR'] #=> 'true'
|
253
|
+
# Sai.mode.basic_auto #=> 0
|
254
|
+
# Sai.mode.three_bit_auto #=> 0
|
255
|
+
# Sai.mode.color8_auto #=> 0
|
256
|
+
#
|
257
|
+
# @return [Integer] the color mode
|
258
|
+
# @rbs () -> Integer
|
259
|
+
def self.basic_auto: () -> Integer
|
260
|
+
|
261
|
+
alias self.color8_auto self.basic_auto
|
262
|
+
|
263
|
+
alias self.colour8_auto self.basic_auto
|
264
|
+
|
265
|
+
alias self.eight_color_auto self.basic_auto
|
266
|
+
|
267
|
+
alias self.eight_colour_auto self.basic_auto
|
268
|
+
|
269
|
+
alias self.three_bit_auto self.basic_auto
|
270
|
+
|
271
|
+
# Set the color mode to disable all color and styling
|
272
|
+
#
|
273
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
274
|
+
# @since 0.2.0
|
275
|
+
#
|
276
|
+
# @api public
|
277
|
+
#
|
278
|
+
# @example
|
279
|
+
# Sai.mode.no_color #=> 0
|
280
|
+
# Sai.mode.disabled #=> 0
|
281
|
+
# Sai.mode.mono #=> 0
|
282
|
+
#
|
283
|
+
# @return [Integer] the color mode
|
284
|
+
# @rbs () -> Integer
|
285
|
+
def self.no_color: () -> Integer
|
286
|
+
|
287
|
+
alias self.disabled self.no_color
|
288
|
+
|
289
|
+
alias self.mono self.no_color
|
290
|
+
|
291
|
+
alias self.no_colour self.no_color
|
292
|
+
|
293
|
+
# Set the color mode to 16-million color (24-bit) mode
|
294
|
+
#
|
295
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
296
|
+
# @since 0.2.0
|
297
|
+
#
|
298
|
+
# @api private
|
299
|
+
#
|
300
|
+
# @example
|
301
|
+
# Sai.mode.true_color #=> 4
|
302
|
+
# Sai.mode.twenty_four_bit #=> 4
|
303
|
+
# Sai.mode.color_16m #=> 4
|
304
|
+
#
|
305
|
+
# @return [Integer] the color mode
|
306
|
+
# @rbs () -> Integer
|
307
|
+
def self.true_color: () -> Integer
|
308
|
+
|
309
|
+
alias self.color16m self.true_color
|
310
|
+
|
311
|
+
alias self.colour16m self.true_color
|
312
|
+
|
313
|
+
alias self.sixteen_million_color self.true_color
|
314
|
+
|
315
|
+
alias self.sixteen_million_colour self.true_color
|
316
|
+
|
317
|
+
alias self.twenty_for_bit self.true_color
|
318
|
+
end
|
319
|
+
end
|