sai 0.1.0 → 0.3.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/.yardopts +1 -1
- data/CHANGELOG.md +32 -1
- data/README.md +32 -209
- data/docs/USAGE.md +303 -0
- data/lib/sai/ansi/sequence_processor.rb +380 -0
- data/lib/sai/ansi/sequenced_string.rb +475 -0
- 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 +256 -240
- 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 +128 -77
- data/sig/manifest.yaml +3 -0
- data/sig/sai/ansi/sequence_processor.rbs +253 -0
- data/sig/sai/ansi/sequenced_string.rbs +380 -0
- 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 +111 -87
- 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 +109 -66
- metadata +12 -4
@@ -0,0 +1,380 @@
|
|
1
|
+
# Generated from lib/sai/ansi/sequenced_string.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Sai
|
4
|
+
module ANSI
|
5
|
+
# A representation of a ANSI encoded string and its individual {SequencedString::Segment segments}
|
6
|
+
#
|
7
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
8
|
+
# @since 0.3.0
|
9
|
+
#
|
10
|
+
# @api public
|
11
|
+
class SequencedString
|
12
|
+
include Enumerable[Segment]
|
13
|
+
|
14
|
+
def each: () { (Segment) -> void } -> SequencedString
|
15
|
+
|
16
|
+
def empty?: () -> bool
|
17
|
+
|
18
|
+
def map: () { (Segment) -> untyped } -> Array[untyped]
|
19
|
+
|
20
|
+
def size: () -> Integer
|
21
|
+
|
22
|
+
# Initialize a new instance of SequencedString
|
23
|
+
#
|
24
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
25
|
+
# @since 0.3.0
|
26
|
+
#
|
27
|
+
# @api private
|
28
|
+
#
|
29
|
+
# @param string [String] the sequenced string to Segment
|
30
|
+
#
|
31
|
+
# @return [SequencedString] the new instance of SequencedString
|
32
|
+
# @rbs (String string) -> void
|
33
|
+
def initialize: (String string) -> void
|
34
|
+
|
35
|
+
# Fetch a segment by index
|
36
|
+
#
|
37
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
38
|
+
# @since 0.3.0
|
39
|
+
#
|
40
|
+
# @api public
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# string = SequencedString.new("\e[31mred\e[0m")
|
44
|
+
# string[0] #=> #<SequencedString::Segment:0x00007f9b3b8b3e10>
|
45
|
+
#
|
46
|
+
# @param index [Integer] the index of the segment to fetch
|
47
|
+
#
|
48
|
+
# @return [Segment, nil] the segment at the index
|
49
|
+
# @rbs (Integer index) -> Segment?
|
50
|
+
def []: (Integer index) -> Segment?
|
51
|
+
|
52
|
+
# Compare the SequencedString to another object
|
53
|
+
#
|
54
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
55
|
+
# @since 0.3.0
|
56
|
+
#
|
57
|
+
# @api public
|
58
|
+
#
|
59
|
+
# @example
|
60
|
+
# string = "\e[31mred\e[0m"
|
61
|
+
# SequencedString.new(string) == string #=> true
|
62
|
+
#
|
63
|
+
# @param other [Object] the object to compare to
|
64
|
+
#
|
65
|
+
# @return [Boolean] `true` if the SequencedString is equal to the other object, `false` otherwise
|
66
|
+
# @rbs (untyped other) -> bool
|
67
|
+
def ==: (untyped other) -> bool
|
68
|
+
|
69
|
+
# Combine a sequenced string with another object
|
70
|
+
#
|
71
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
72
|
+
# @since 0.3.0
|
73
|
+
#
|
74
|
+
# @api public
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# sequenced_string = SequencedString.new("\e[31mred\e[0m")
|
78
|
+
# sequenced_string + " is a color" #=> "\e[31mred\e[0m is a color"
|
79
|
+
#
|
80
|
+
# @param other [Object] the object to combine with
|
81
|
+
#
|
82
|
+
# @return [SequencedString] the combined string
|
83
|
+
# @rbs (untyped other) -> SequencedString
|
84
|
+
def +: (untyped other) -> SequencedString
|
85
|
+
|
86
|
+
# Return just the raw text content with **no ANSI sequences**
|
87
|
+
#
|
88
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
89
|
+
# @since 0.3.0
|
90
|
+
#
|
91
|
+
# @api public
|
92
|
+
#
|
93
|
+
# @example
|
94
|
+
# string = SequencedString.new("Normal \e[31mred\e[0m")
|
95
|
+
# string.stripped #=> "Normal red"
|
96
|
+
#
|
97
|
+
# @return [String] the concatenation of all segment text without color or style
|
98
|
+
def stripped: () -> untyped
|
99
|
+
|
100
|
+
# Return the fully reconstructed string with **all ANSI sequences** (foreground, background, style)
|
101
|
+
#
|
102
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
103
|
+
# @since 0.3.0
|
104
|
+
#
|
105
|
+
# @api public
|
106
|
+
#
|
107
|
+
# @example
|
108
|
+
# string = SequencedString.new("\e[31mred\e[0m")
|
109
|
+
# string.to_s #=> "\e[31mred\e[0m"
|
110
|
+
#
|
111
|
+
# @return [String]
|
112
|
+
def to_s: () -> untyped
|
113
|
+
|
114
|
+
alias to_str to_s
|
115
|
+
|
116
|
+
# Return a string with everything except **background** color sequences removed
|
117
|
+
#
|
118
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
119
|
+
# @since 0.3.0
|
120
|
+
#
|
121
|
+
# @api public
|
122
|
+
#
|
123
|
+
# @example Remove all background colors
|
124
|
+
# string = SequencedString.new("\e[41mBack\e[0m \e[1mBold\e[0m")
|
125
|
+
# string.without_background #=> "\e[1mBold\e[0m"
|
126
|
+
#
|
127
|
+
# @return [SequencedString] new instance with background colors removed
|
128
|
+
# @rbs () -> SequencedString
|
129
|
+
def without_background: () -> SequencedString
|
130
|
+
|
131
|
+
# Return a string containing *style* sequences but **no foreground or background colors**
|
132
|
+
#
|
133
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
134
|
+
# @since 0.3.0
|
135
|
+
#
|
136
|
+
# @api public
|
137
|
+
#
|
138
|
+
# @example Remove all colors
|
139
|
+
# string = SequencedString.new("\e[31mred\e[0m \e[1mbold\e[0m")
|
140
|
+
# string.without_color #=> "\e[1mbold\e[0m"
|
141
|
+
#
|
142
|
+
# @return [SequencedString] new instance with all colors removed
|
143
|
+
# @rbs () -> SequencedString
|
144
|
+
def without_color: () -> SequencedString
|
145
|
+
|
146
|
+
# Return a string with everything except **foreground** color sequences removed
|
147
|
+
#
|
148
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
149
|
+
# @since 0.3.0
|
150
|
+
#
|
151
|
+
# @api public
|
152
|
+
#
|
153
|
+
# @example Remove all foreground colors
|
154
|
+
# string = SequencedString.new("\e[41mBack\e[0m \e[1mBold\e[0m")
|
155
|
+
# string.without_foreground #=> "\e[41mBack\e[0m \e[1mBold\e[0m"
|
156
|
+
#
|
157
|
+
# @return [SequencedString] new instance with foreground colors removed
|
158
|
+
# @rbs () -> SequencedString
|
159
|
+
def without_foreground: () -> SequencedString
|
160
|
+
|
161
|
+
# Return a string with specified styles removed
|
162
|
+
#
|
163
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
164
|
+
# @since 0.3.0
|
165
|
+
#
|
166
|
+
# @api public
|
167
|
+
#
|
168
|
+
# @example Remove all styles
|
169
|
+
# string = SequencedString.new("\e[31mred\e[0m \e[1mbold\e[0m")
|
170
|
+
# string.without_style #=> "\e[31mred\e[0m"
|
171
|
+
#
|
172
|
+
# @example Remove specific style
|
173
|
+
# string = SequencedString.new("\e[1;4mBold and Underlined\e[0m")
|
174
|
+
# string.without_style(:bold) #=> "\e[4mUnderlined\e[0m"
|
175
|
+
#
|
176
|
+
# @param styles [Array<Symbol>] specific styles to remove (default: all)
|
177
|
+
#
|
178
|
+
# @return [SequencedString] new instance with specified styles removed
|
179
|
+
def without_style: (*untyped styles) -> untyped
|
180
|
+
|
181
|
+
private
|
182
|
+
|
183
|
+
# Build the color sequences for a segment
|
184
|
+
#
|
185
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
186
|
+
# @since 0.3.0
|
187
|
+
#
|
188
|
+
# @api private
|
189
|
+
#
|
190
|
+
# @param segment [Segment] the segment to build color sequences for
|
191
|
+
# @param skip_background [Boolean] whether to skip background colors
|
192
|
+
# @param skip_foreground [Boolean] whether to skip foreground colors
|
193
|
+
#
|
194
|
+
# @return [Array<String>] the color sequences
|
195
|
+
# @rbs (Segment segment, ?skip_background: bool, ?skip_foreground: bool) -> Array[String]
|
196
|
+
def build_color_sequences: (Segment segment, ?skip_background: bool, ?skip_foreground: bool) -> Array[String]
|
197
|
+
|
198
|
+
# Build a string with specified parts skipped
|
199
|
+
#
|
200
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
201
|
+
# @since 0.3.0
|
202
|
+
#
|
203
|
+
# @api private
|
204
|
+
#
|
205
|
+
# @param skip_background [Boolean] whether to skip background colors
|
206
|
+
# @param skip_foreground [Boolean] whether to skip foreground colors
|
207
|
+
# @param skip_styles [Array<Symbol>] styles to skip
|
208
|
+
#
|
209
|
+
# @return [String] the built string
|
210
|
+
# @rbs (?skip_background: bool, ?skip_foreground: bool, ?skip_styles: Array[Symbol]) -> String
|
211
|
+
def build_string: (?skip_background: bool, ?skip_foreground: bool, ?skip_styles: Array[Symbol]) -> String
|
212
|
+
|
213
|
+
# Build the style sequences for a segment
|
214
|
+
#
|
215
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
216
|
+
# @since 0.3.0
|
217
|
+
#
|
218
|
+
# @api private
|
219
|
+
#
|
220
|
+
# @param segment [Segment] the segment to build style sequences for
|
221
|
+
# @param skip_styles [Array<Symbol>] styles to skip
|
222
|
+
#
|
223
|
+
# @return [Array<String>] the style sequences
|
224
|
+
# @rbs (Segment segment, ?skip_styles: Array[Symbol]) -> Array[String]
|
225
|
+
def build_style_sequences: (Segment segment, ?skip_styles: Array[Symbol]) -> Array[String]
|
226
|
+
|
227
|
+
# A segment of an ANSI encoded string
|
228
|
+
#
|
229
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
230
|
+
# @since 0.3.0
|
231
|
+
#
|
232
|
+
# @api public
|
233
|
+
class Segment
|
234
|
+
# The background color sequences for the Segment
|
235
|
+
#
|
236
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
237
|
+
# @since 0.3.0
|
238
|
+
#
|
239
|
+
# @api public
|
240
|
+
#
|
241
|
+
# @return [String, nil] the background color sequences
|
242
|
+
attr_reader background: String?
|
243
|
+
|
244
|
+
# The foreground color sequences for the Segment
|
245
|
+
#
|
246
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
247
|
+
# @since 0.3.0
|
248
|
+
#
|
249
|
+
# @api public
|
250
|
+
#
|
251
|
+
# @return [String, nil] the foreground color sequences
|
252
|
+
attr_reader foreground: String?
|
253
|
+
|
254
|
+
# The {Location} of the encoded string within the {SequencedString}
|
255
|
+
#
|
256
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
257
|
+
# @since 0.3.0
|
258
|
+
#
|
259
|
+
# @api public
|
260
|
+
#
|
261
|
+
# @return [Location] the {Location}
|
262
|
+
attr_reader encoded_location: Location
|
263
|
+
|
264
|
+
alias encoded_loc encoded_location
|
265
|
+
|
266
|
+
# The {Location} of the encoded string without it's encoding within the {SequencedString}
|
267
|
+
#
|
268
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
269
|
+
# @since 0.3.0
|
270
|
+
#
|
271
|
+
# @api public
|
272
|
+
#
|
273
|
+
# @return [Location] the {Location}
|
274
|
+
attr_reader stripped_location: Location
|
275
|
+
|
276
|
+
alias stripped_loc stripped_location
|
277
|
+
|
278
|
+
# The style sequences (bold, underline, etc...) for the segment
|
279
|
+
#
|
280
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
281
|
+
# @since 0.3.0
|
282
|
+
#
|
283
|
+
# @api public
|
284
|
+
#
|
285
|
+
# @return [Array<String>] the style sequences
|
286
|
+
attr_reader styles: Array[String]
|
287
|
+
|
288
|
+
# The raw text of the Segment without any of its ANSI sequences
|
289
|
+
#
|
290
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
291
|
+
# @since 0.3.0
|
292
|
+
#
|
293
|
+
# @api public
|
294
|
+
#
|
295
|
+
# @return [String]
|
296
|
+
attr_reader text: String
|
297
|
+
|
298
|
+
# Initialize a new instance of Segment
|
299
|
+
#
|
300
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
301
|
+
# @since 0.3.0
|
302
|
+
#
|
303
|
+
# @api private
|
304
|
+
#
|
305
|
+
# @param options [Hash{Symbol => Object}] the options to initialize the Segment with
|
306
|
+
# @option options background [String, nil] the Segment {#background}
|
307
|
+
# @option options foreground [String, nil] the Segment {#foreground}
|
308
|
+
# @option options encoded_end [Integer] the {Location#end_position end_position} of the Segment
|
309
|
+
# {#encoded_location}
|
310
|
+
# @option options encoded_start [Integer] the {Location#start_position start_position} of the Segment
|
311
|
+
# {#encoded_location}
|
312
|
+
# @option options stripped_end [Integer] the {Location#end_position end_position} of the Segment
|
313
|
+
# {#stripped_location}
|
314
|
+
# @option options stripped_start [Integer] the {Location#start_position start_position} of the Segment
|
315
|
+
# {#stripped_location}
|
316
|
+
# @option options styles [Array<String>] the Segment {#styles}
|
317
|
+
# @option options text [String] the Segment {#text}
|
318
|
+
#
|
319
|
+
# @return [Segment] the new instance of Segment
|
320
|
+
# @rbs (
|
321
|
+
# ?background: String?,
|
322
|
+
# ?foreground: String?,
|
323
|
+
# encoded_end: Integer,
|
324
|
+
# encoded_start: Integer,
|
325
|
+
# stripped_end: Integer,
|
326
|
+
# stripped_start: Integer,
|
327
|
+
# ?styles: Array[String],
|
328
|
+
# text: String
|
329
|
+
# ) -> void
|
330
|
+
def initialize: (encoded_end: Integer, encoded_start: Integer, stripped_end: Integer, stripped_start: Integer, text: String, ?background: String?, ?foreground: String?, ?styles: Array[String]) -> void
|
331
|
+
|
332
|
+
# The location of the {Segment} within a {SequencedString}
|
333
|
+
#
|
334
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
335
|
+
# @since 0.3.0
|
336
|
+
#
|
337
|
+
# @api public
|
338
|
+
class Location
|
339
|
+
# The ending position of the Location
|
340
|
+
#
|
341
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
342
|
+
# @since 0.3.0
|
343
|
+
#
|
344
|
+
# @api public
|
345
|
+
#
|
346
|
+
# @return [Integer] the end position
|
347
|
+
attr_reader end_position: Integer
|
348
|
+
|
349
|
+
alias end_pos end_position
|
350
|
+
|
351
|
+
# The starting position of the Location
|
352
|
+
#
|
353
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
354
|
+
# @since 0.3.0
|
355
|
+
#
|
356
|
+
# @api public
|
357
|
+
#
|
358
|
+
# @return [Integer] the start position
|
359
|
+
attr_reader start_position: Integer
|
360
|
+
|
361
|
+
alias start_pos start_position
|
362
|
+
|
363
|
+
# Initialize a new instance of Location
|
364
|
+
#
|
365
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
366
|
+
# @since 0.3.0
|
367
|
+
#
|
368
|
+
# @api private
|
369
|
+
#
|
370
|
+
# @param end_position [Integer] the {#end_position} of the location
|
371
|
+
# @param start_position [Integer] the {#start_position} of the location
|
372
|
+
#
|
373
|
+
# @return [Location] the new instance of Location
|
374
|
+
# @rbs (end_position: Integer, start_position: Integer) -> void
|
375
|
+
def initialize: (end_position: Integer, start_position: Integer) -> void
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|
380
|
+
end
|
data/sig/sai/ansi.rbs
CHANGED
@@ -4,14 +4,14 @@ module Sai
|
|
4
4
|
# ANSI constants for encoding text styles and colors
|
5
5
|
#
|
6
6
|
# @author {https://aaronmallen.me Aaron Allen}
|
7
|
-
# @since
|
7
|
+
# @since 0.1.0
|
8
8
|
#
|
9
9
|
# @api private
|
10
10
|
module ANSI
|
11
11
|
# ANSI color code mappings
|
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
|
#
|
@@ -21,7 +21,7 @@ module Sai
|
|
21
21
|
# Standard ANSI color names and their RGB values
|
22
22
|
#
|
23
23
|
# @author {https://aaronmallen.me Aaron Allen}
|
24
|
-
# @since
|
24
|
+
# @since 0.1.0
|
25
25
|
#
|
26
26
|
# @api private
|
27
27
|
#
|
@@ -31,7 +31,7 @@ module Sai
|
|
31
31
|
# ANSI escape sequence for resetting text formatting
|
32
32
|
#
|
33
33
|
# @author {https://aaronmallen.me Aaron Allen}
|
34
|
-
# @since
|
34
|
+
# @since 0.1.0
|
35
35
|
#
|
36
36
|
# @api private
|
37
37
|
#
|
@@ -41,7 +41,7 @@ module Sai
|
|
41
41
|
# Standard ANSI style codes
|
42
42
|
#
|
43
43
|
# @author {https://aaronmallen.me Aaron Allen}
|
44
|
-
# @since
|
44
|
+
# @since 0.1.0
|
45
45
|
#
|
46
46
|
# @api private
|
47
47
|
#
|
@@ -5,7 +5,7 @@ module Sai
|
|
5
5
|
# ANSI escape sequence utilities
|
6
6
|
#
|
7
7
|
# @author {https://aaronmallen.me Aaron Allen}
|
8
|
-
# @since
|
8
|
+
# @since 0.1.0
|
9
9
|
#
|
10
10
|
# @api private
|
11
11
|
module ColorSequence
|
@@ -14,7 +14,7 @@ module Sai
|
|
14
14
|
# Convert a color to the appropriate ANSI escape sequence
|
15
15
|
#
|
16
16
|
# @author {https://aaronmallen.me Aaron Allen}
|
17
|
-
# @since
|
17
|
+
# @since 0.1.0
|
18
18
|
#
|
19
19
|
# @api private
|
20
20
|
#
|
@@ -26,10 +26,24 @@ module Sai
|
|
26
26
|
# @rbs (Array[Integer] | String | Symbol color, Integer mode, ?style_type style_type) -> String
|
27
27
|
def self.resolve: (Array[Integer] | String | Symbol color, Integer mode, ?style_type style_type) -> String
|
28
28
|
|
29
|
+
# Convert RGB values to an 8-bit color sequence
|
30
|
+
#
|
31
|
+
# @author {https://aaronmallen.me Aaron Allen}
|
32
|
+
# @since 0.1.0
|
33
|
+
#
|
34
|
+
# @api private
|
35
|
+
#
|
36
|
+
# @param rgb [Array<Integer>] the RGB components
|
37
|
+
# @param style_type [Symbol] the type of color (foreground or background)
|
38
|
+
#
|
39
|
+
# @return [String] the ANSI escape sequence
|
40
|
+
# @rbs (Array[Integer] rgb, style_type type) -> String
|
41
|
+
private def self.advanced: (Array[Integer] rgb, style_type type) -> String
|
42
|
+
|
29
43
|
# Convert RGB values to a 4-bit ANSI color sequence
|
30
44
|
#
|
31
45
|
# @author {https://aaronmallen.me Aaron Allen}
|
32
|
-
# @since
|
46
|
+
# @since 0.1.0
|
33
47
|
#
|
34
48
|
# @api private
|
35
49
|
#
|
@@ -43,7 +57,7 @@ module Sai
|
|
43
57
|
# Convert a base color to a foreground or background sequence
|
44
58
|
#
|
45
59
|
# @author {https://aaronmallen.me Aaron Allen}
|
46
|
-
# @since
|
60
|
+
# @since 0.1.0
|
47
61
|
#
|
48
62
|
# @api private
|
49
63
|
#
|
@@ -57,7 +71,7 @@ module Sai
|
|
57
71
|
# Convert RGB values to a 3-bit basic color sequence
|
58
72
|
#
|
59
73
|
# @author {https://aaronmallen.me Aaron Allen}
|
60
|
-
# @since
|
74
|
+
# @since 0.1.0
|
61
75
|
#
|
62
76
|
# @api private
|
63
77
|
#
|
@@ -68,24 +82,10 @@ module Sai
|
|
68
82
|
# @rbs (Array[Integer] rgb, style_type style_type) -> String
|
69
83
|
private def self.basic: (Array[Integer] rgb, style_type style_type) -> String
|
70
84
|
|
71
|
-
# Convert RGB values to an 8-bit color sequence
|
72
|
-
#
|
73
|
-
# @author {https://aaronmallen.me Aaron Allen}
|
74
|
-
# @since unreleased
|
75
|
-
#
|
76
|
-
# @api private
|
77
|
-
#
|
78
|
-
# @param rgb [Array<Integer>] the RGB components
|
79
|
-
# @param style_type [Symbol] the type of color (foreground or background)
|
80
|
-
#
|
81
|
-
# @return [String] the ANSI escape sequence
|
82
|
-
# @rbs (Array[Integer] rgb, style_type type) -> String
|
83
|
-
private def self.bit8: (Array[Integer] rgb, style_type type) -> String
|
84
|
-
|
85
85
|
# Convert RGB values to a true color (24-bit) sequence
|
86
86
|
#
|
87
87
|
# @author {https://aaronmallen.me Aaron Allen}
|
88
|
-
# @since
|
88
|
+
# @since 0.1.0
|
89
89
|
#
|
90
90
|
# @api private
|
91
91
|
#
|
@@ -99,7 +99,7 @@ module Sai
|
|
99
99
|
# Validate a color style type
|
100
100
|
#
|
101
101
|
# @author {https://aaronmallen.me Aaron Allen}
|
102
|
-
# @since
|
102
|
+
# @since 0.1.0
|
103
103
|
#
|
104
104
|
# @api private
|
105
105
|
#
|
data/sig/sai/conversion/rgb.rbs
CHANGED
@@ -5,14 +5,14 @@ module Sai
|
|
5
5
|
# RGB color conversion utilities
|
6
6
|
#
|
7
7
|
# @author {https://aaronmallen.me Aaron Allen}
|
8
|
-
# @since
|
8
|
+
# @since 0.1.0
|
9
9
|
#
|
10
10
|
# @api private
|
11
11
|
module RGB
|
12
12
|
# Get closest ANSI color for RGB values
|
13
13
|
#
|
14
14
|
# @author {https://aaronmallen.me Aaron Allen}
|
15
|
-
# @since
|
15
|
+
# @since 0.1.0
|
16
16
|
#
|
17
17
|
# @api private
|
18
18
|
#
|
@@ -27,7 +27,7 @@ module Sai
|
|
27
27
|
# Determine if a color is dark
|
28
28
|
#
|
29
29
|
# @author {https://aaronmallen.me Aaron Allen}
|
30
|
-
# @since
|
30
|
+
# @since 0.1.0
|
31
31
|
#
|
32
32
|
# @api private
|
33
33
|
#
|
@@ -42,7 +42,7 @@ module Sai
|
|
42
42
|
# Determine if a color is grayscale
|
43
43
|
#
|
44
44
|
# @author {https://aaronmallen.me Aaron Allen}
|
45
|
-
# @since
|
45
|
+
# @since 0.1.0
|
46
46
|
#
|
47
47
|
# @api private
|
48
48
|
#
|
@@ -57,7 +57,7 @@ module Sai
|
|
57
57
|
# Convert a color value to RGB components
|
58
58
|
#
|
59
59
|
# @author {https://aaronmallen.me Aaron Allen}
|
60
|
-
# @since
|
60
|
+
# @since 0.1.0
|
61
61
|
#
|
62
62
|
# @api private
|
63
63
|
#
|
@@ -71,7 +71,7 @@ module Sai
|
|
71
71
|
# Convert RGB values to 256-color cube index
|
72
72
|
#
|
73
73
|
# @author {https://aaronmallen.me Aaron Allen}
|
74
|
-
# @since
|
74
|
+
# @since 0.1.0
|
75
75
|
#
|
76
76
|
# @api private
|
77
77
|
#
|
@@ -84,7 +84,7 @@ module Sai
|
|
84
84
|
# Convert RGB values to grayscale index
|
85
85
|
#
|
86
86
|
# @author {https://aaronmallen.me Aaron Allen}
|
87
|
-
# @since
|
87
|
+
# @since 0.1.0
|
88
88
|
#
|
89
89
|
# @api private
|
90
90
|
#
|
@@ -97,7 +97,7 @@ module Sai
|
|
97
97
|
# Check if RGB values represent cyan
|
98
98
|
#
|
99
99
|
# @author {https://aaronmallen.me Aaron Allen}
|
100
|
-
# @since
|
100
|
+
# @since 0.1.0
|
101
101
|
#
|
102
102
|
# @api private
|
103
103
|
#
|
@@ -112,7 +112,7 @@ module Sai
|
|
112
112
|
# Convert a hex string to RGB values
|
113
113
|
#
|
114
114
|
# @author {https://aaronmallen.me Aaron Allen}
|
115
|
-
# @since
|
115
|
+
# @since 0.1.0
|
116
116
|
#
|
117
117
|
# @api private
|
118
118
|
#
|
@@ -125,7 +125,7 @@ module Sai
|
|
125
125
|
# Check if RGB values represent magenta
|
126
126
|
#
|
127
127
|
# @author {https://aaronmallen.me Aaron Allen}
|
128
|
-
# @since
|
128
|
+
# @since 0.1.0
|
129
129
|
#
|
130
130
|
# @api private
|
131
131
|
#
|
@@ -140,7 +140,7 @@ module Sai
|
|
140
140
|
# Convert a named color to RGB values
|
141
141
|
#
|
142
142
|
# @author {https://aaronmallen.me Aaron Allen}
|
143
|
-
# @since
|
143
|
+
# @since 0.1.0
|
144
144
|
#
|
145
145
|
# @api private
|
146
146
|
#
|
@@ -154,7 +154,7 @@ module Sai
|
|
154
154
|
# Determine if RGB values represent a primary color
|
155
155
|
#
|
156
156
|
# @author {https://aaronmallen.me Aaron Allen}
|
157
|
-
# @since
|
157
|
+
# @since 0.1.0
|
158
158
|
#
|
159
159
|
# @api private
|
160
160
|
#
|
@@ -169,7 +169,7 @@ module Sai
|
|
169
169
|
# Get the closest primary color
|
170
170
|
#
|
171
171
|
# @author {https://aaronmallen.me Aaron Allen}
|
172
|
-
# @since
|
172
|
+
# @since 0.1.0
|
173
173
|
#
|
174
174
|
# @api private
|
175
175
|
#
|
@@ -184,7 +184,7 @@ module Sai
|
|
184
184
|
# Determine if RGB values represent a secondary color
|
185
185
|
#
|
186
186
|
# @author {https://aaronmallen.me Aaron Allen}
|
187
|
-
# @since
|
187
|
+
# @since 0.1.0
|
188
188
|
#
|
189
189
|
# @api private
|
190
190
|
#
|
@@ -199,7 +199,7 @@ module Sai
|
|
199
199
|
# Get the closest secondary color
|
200
200
|
#
|
201
201
|
# @author {https://aaronmallen.me Aaron Allen}
|
202
|
-
# @since
|
202
|
+
# @since 0.1.0
|
203
203
|
#
|
204
204
|
# @api private
|
205
205
|
#
|
@@ -214,7 +214,7 @@ module Sai
|
|
214
214
|
# Validate RGB values
|
215
215
|
#
|
216
216
|
# @author {https://aaronmallen.me Aaron Allen}
|
217
|
-
# @since
|
217
|
+
# @since 0.1.0
|
218
218
|
#
|
219
219
|
# @api private
|
220
220
|
#
|
@@ -227,7 +227,7 @@ module Sai
|
|
227
227
|
# Check if RGB values represent yellow
|
228
228
|
#
|
229
229
|
# @author {https://aaronmallen.me Aaron Allen}
|
230
|
-
# @since
|
230
|
+
# @since 0.1.0
|
231
231
|
#
|
232
232
|
# @api private
|
233
233
|
#
|