just-ansi 0.2.1 → 1.0.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 +12 -0
- data/README.md +29 -4
- data/examples/24bit-colors.rb +20 -0
- data/examples/3bit-colors.rb +18 -0
- data/examples/8bit-colors.rb +32 -0
- data/examples/attributes.rb +16 -0
- data/examples/bbcode.rb +28 -0
- data/lib/just-ansi/version.rb +1 -1
- data/lib/just-ansi.rb +41 -5
- data/lib/no-ansi.rb +95 -0
- metadata +14 -7
- data/lib/just-ansi/string.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 294e05aacfb98dbb9f9dfbb88059945d50b6f3bcc7660dbac93bfaab3aa10b9d
|
4
|
+
data.tar.gz: df553573277036702cb2056074c84400432da4a37eb240c996810b2b9b1ba53a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b80bbf875d910786941cf5c6fdd8118af22ba69a9f304c4bcfabf09dbb70f62d9e1b3ae45fd2f2cb1e43e103ae5e271507912c0fa2fd5648d57792d39cc5970
|
7
|
+
data.tar.gz: 8189df038c0b01a3f1327c7c27085097182dd1f6ef0475bd3bcc434d743fcbba744acbeb10dc47e6fcd67b612f789d425b00982e755aeaf9cc261b0a935bade1
|
data/.yardopts
ADDED
data/README.md
CHANGED
@@ -1,13 +1,38 @@
|
|
1
|
-
# JustAnsi
|
1
|
+
# JustAnsi 
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Simple and fast ANSI control code processing.
|
3
|
+
Simple and fast ANSI control code processing. <!-- Without BS. -->
|
6
4
|
|
7
5
|
- Gem: [rubygems.org](https://rubygems.org/gems/just-ansi)
|
8
6
|
- Source: [github.com](https://github.com/mblumtritt/just-ansi)
|
9
7
|
- Help: [rubydoc.info](https://rubydoc.info/gems/just-ansi/JustAnsi)
|
10
8
|
|
9
|
+
## Description
|
10
|
+
|
11
|
+
JustAnsi provides a rich set of methods to generate ANSI control codes for attributes, colors, cursor movement and much more. It supports most control codes, all attributes, 3/4bit-, 8bit- and 24bit-colors.
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
hello = JustAnsi.decorate('Hello World!', :bold, :red)
|
15
|
+
# => "\e[1;31mHello World!\e[m"
|
16
|
+
|
17
|
+
JustAnsi.undecorate(hello)
|
18
|
+
# => 'Hello World!'
|
19
|
+
|
20
|
+
JustAnsi.bbcode('[b]Hello [red]World[/fg]![/b]')
|
21
|
+
# => "\e[1mHello \e[31mWorld\e[39m!\e[22m"
|
22
|
+
```
|
23
|
+
|
24
|
+
## Help
|
25
|
+
|
26
|
+
📕 See the [online help](https://rubydoc.info/gems/just-ansi/JustAnsi) and have a look at the [examples](./examples/) directory.
|
27
|
+
|
28
|
+
### Run Examples
|
29
|
+
|
30
|
+
You can execute the examples by
|
31
|
+
|
32
|
+
```sh
|
33
|
+
ruby ./examples/bbcode.rb
|
34
|
+
```
|
35
|
+
|
11
36
|
## Installation
|
12
37
|
|
13
38
|
You can install the gem in your system with
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/just-ansi'
|
4
|
+
|
5
|
+
colors =
|
6
|
+
JustAnsi
|
7
|
+
.named_colors
|
8
|
+
.delete_if { /\d/.match?(_1) }
|
9
|
+
.map! { "[on_#{_1}] [/] [#{_1}]#{_1.to_s.ljust(22)}[/]" }
|
10
|
+
.each_slice(3)
|
11
|
+
.map(&:join)
|
12
|
+
.join("\n")
|
13
|
+
|
14
|
+
puts JustAnsi.bbcode <<~TEXT
|
15
|
+
|
16
|
+
✅ [b 2]Just Ansi[/b] — 24bit-Colors:[/]
|
17
|
+
|
18
|
+
#{colors}
|
19
|
+
|
20
|
+
TEXT
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/just-ansi'
|
4
|
+
|
5
|
+
puts JustAnsi.bbcode <<~TEXT
|
6
|
+
|
7
|
+
✅ [b 2]Just Ansi[/b] — 3bit-Colors:[/]
|
8
|
+
|
9
|
+
[on_black] [/] [black]black[/] [on_bright_black] [/] [bright_black]bright_black[/]
|
10
|
+
[on_red] [/] [red]red[/] [on_bright_red] [/] [bright_red]bright_red[/]
|
11
|
+
[on_green] [/] [green]green[/] [on_bright_green] [/] [bright_green]bright_green[/]
|
12
|
+
[on_yellow] [/] [yellow]yellow[/] [on_bright_yellow] [/] [bright_yellow]bright_yellow[/]
|
13
|
+
[on_blue] [/] [blue]blue[/] [on_bright_blue] [/] [bright_blue]bright_blue[/]
|
14
|
+
[on_magenta] [/] [magenta]magenta[/] [on_bright_magenta] [/] [bright_magenta]bright_magenta[/]
|
15
|
+
[on_cyan] [/] [cyan]cyan[/] [on_bright_cyan] [/] [bright_cyan]bright_cyan[/]
|
16
|
+
[on_white] [/] [white]white[/] [on_bright_white] [/] [bright_white]bright_white[/]
|
17
|
+
|
18
|
+
TEXT
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/just-ansi'
|
4
|
+
|
5
|
+
puts JustAnsi.bbcode <<~TEXT
|
6
|
+
|
7
|
+
✅ [b 2]Just Ansi[/b] — 8bit-Colors:[/]
|
8
|
+
|
9
|
+
System Colors
|
10
|
+
[on_0] 00 [on_1] 01 [on_2] 02 [on_3] 03 [on_4] 04 [on_5] 05 [on_6] 06 [on_7] 07 [/]
|
11
|
+
[on_8] 08 [on_9] 09 [on_a] 0a [on_b] 0b [on_c] 0c [on_d] 0d [on_e] 0e [on_e] 0f [/]
|
12
|
+
|
13
|
+
Grayscale
|
14
|
+
[on_e8] e8 [on_e9] e9 [on_ea] ea [on_eb] eb [on_ec] ec [on_ed] ed [on_ee] ee [on_ef] ef [on_f0] f0 [on_f1] f1 [on_f2] f2 [on_f3] f3 [/]
|
15
|
+
[on_f4] f4 [on_f5] f5 [on_f6] f6 [on_f7] f7 [on_f8] f8 [on_f9] f9 [on_fa] fa [on_fb] fb [on_fc] fc [on_fd] fd [on_fe] fe [on_ff] ff [/]
|
16
|
+
|
17
|
+
6x6 Color Cubes
|
18
|
+
[on_10] 10 [on_11] 11 [on_12] 12 [on_13] 13 [on_14] 14 [on_15] 15 [/] [on_16] 16 [on_17] 17 [on_18] 18 [on_19] 19 [on_1a] 1a [on_1b] 1b [/] [on_1c] 1c [on_1d] 1d [on_1e] 1e [on_1f] 1f [on_20] 20 [on_21] 21 [/]
|
19
|
+
[on_34] 34 [on_35] 35 [on_36] 36 [on_37] 37 [on_38] 38 [on_39] 39 [/] [on_3a] 3a [on_3b] 3b [on_3c] 3c [on_3d] 3d [on_3e] 3e [on_3f] 3f [/] [on_40] 40 [on_41] 41 [on_42] 42 [on_43] 43 [on_44] 44 [on_45] 45 [/]
|
20
|
+
[on_58] 58 [on_59] 59 [on_5a] 5a [on_5b] 5b [on_5c] 5c [on_5d] 5d [/] [on_5e] 5e [on_5f] 5f [on_60] 60 [on_61] 61 [on_62] 62 [on_63] 63 [/] [on_64] 64 [on_65] 65 [on_66] 66 [on_67] 67 [on_68] 68 [on_69] 69 [/]
|
21
|
+
[on_7c] 7c [on_7d] 7d [on_7e] 7e [on_7f] 7f [on_80] 80 [on_81] 81 [/] [on_82] 82 [on_83] 83 [on_84] 84 [on_85] 85 [on_86] 86 [on_87] 87 [/] [on_88] 88 [on_89] 89 [on_8a] 8a [on_8b] 8b [on_8c] 8c [on_8d] 8d [/]
|
22
|
+
[on_a0] a0 [on_a1] a1 [on_a2] a2 [on_a3] a3 [on_a4] a4 [on_a5] a5 [/] [on_a6] a6 [on_a7] a7 [on_a8] a8 [on_a9] a9 [on_aa] aa [on_ab] ab [/] [on_ac] ac [on_ad] ad [on_ae] ae [on_af] af [on_b0] b0 [on_b1] b1 [/]
|
23
|
+
[on_c4] c4 [on_c5] c5 [on_c6] c6 [on_c7] c7 [on_c8] c8 [on_c9] c9 [/] [on_ca] ca [on_cb] cb [on_cc] cc [on_cd] cd [on_ce] ce [on_cf] cf [/] [on_d0] d0 [on_d1] d1 [on_d2] d2 [on_d3] d3 [on_d4] d4 [on_d5] d5 [/]
|
24
|
+
|
25
|
+
[on_22] 22 [on_23] 23 [on_24] 24 [on_25] 25 [on_26] 26 [on_27] 27 [/] [on_28] 28 [on_29] 29 [on_2a] 2a [on_2b] 2b [on_2c] 2c [on_2d] 2d [/] [on_2e] 2e [on_2f] 2f [on_30] 30 [on_31] 31 [on_32] 32 [on_33] 33 [/]
|
26
|
+
[on_46] 46 [on_47] 47 [on_48] 48 [on_49] 49 [on_4a] 4a [on_4b] 4b [/] [on_4c] 4c [on_4d] 4d [on_4e] 4e [on_4f] 4f [on_50] 50 [on_51] 51 [/] [on_52] 52 [on_53] 53 [on_54] 54 [on_55] 55 [on_56] 56 [on_57] 57 [/]
|
27
|
+
[on_6a] 6a [on_6b] 6b [on_6c] 6c [on_6d] 6d [on_6e] 6e [on_6f] 6f [/] [on_70] 70 [on_71] 71 [on_72] 72 [on_73] 73 [on_74] 74 [on_75] 75 [/] [on_76] 76 [on_77] 77 [on_78] 78 [on_79] 79 [on_7a] 7a [on_7b] 7b [/]
|
28
|
+
[on_8e] 8e [on_8f] 8f [on_90] 90 [on_91] 91 [on_92] 92 [on_93] 93 [/] [on_94] 94 [on_95] 95 [on_96] 96 [on_97] 97 [on_98] 98 [on_99] 99 [/] [on_9a] 9a [on_9b] 9b [on_9c] 9c [on_9d] 9d [on_9e] 9e [on_9f] 9f [/]
|
29
|
+
[on_b2] b2 [on_b3] b3 [on_b4] b4 [on_b5] b5 [on_b6] b6 [on_b7] b7 [/] [on_b8] b8 [on_b9] b9 [on_ba] ba [on_bb] bb [on_bc] bc [on_bd] bd [/] [on_be] be [on_bf] bf [on_c0] c0 [on_c1] c1 [on_c2] c2 [on_c3] c3 [/]
|
30
|
+
[on_d6] d6 [on_d7] d7 [on_d8] d8 [on_d9] d9 [on_da] da [on_db] db [/] [on_dc] dc [on_dd] dd [on_de] de [on_df] df [on_e0] e0 [on_e1] e1 [/] [on_e2] e2 [on_e3] e3 [on_e4] e4 [on_e5] e5 [on_e6] e6 [on_e7] e7 [/]
|
31
|
+
|
32
|
+
TEXT
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/just-ansi'
|
4
|
+
|
5
|
+
puts JustAnsi.bbcode <<~TEXT
|
6
|
+
|
7
|
+
✅ [b 2]Just Ansi[/b] — Attributes:[/]
|
8
|
+
|
9
|
+
JustAnsi supports all well known attributes like [b]bold[/b], [i]italic[/i], [u]underline[/u], [blink]blink[/blink],
|
10
|
+
[inv]invert[/inv] and [strike]strike[/strike]. Other attributes like [faint]faint[/faint], [double_underline]double underline[/], [curly_underline]curly
|
11
|
+
underline[/], [dotted_underline]dotted underline[/], [dashed_underline]dashed underline[/], [rapid_blink]rapid_blink[/], [framed]framed[/], [encircled]encircled[/],
|
12
|
+
[overlined]overlined[/] and [proportional]proportional[/] are not widely used but also supported.
|
13
|
+
Alternative fonts are mostly completely ignored by terminal emulators:
|
14
|
+
[primary_font]primary_font[/], [fraktur]fraktur[/], [font1]font1[/] ... [font9]font9[/].
|
15
|
+
|
16
|
+
TEXT
|
data/examples/bbcode.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/just-ansi'
|
4
|
+
|
5
|
+
puts JustAnsi.bbcode <<~TEXT
|
6
|
+
|
7
|
+
✅ [b 2]Just Ansi[/b] — BBCode:[/]
|
8
|
+
|
9
|
+
[b]Bold[/b] [\\b]...[\\/b] or [\\bold]...[\\/bold]
|
10
|
+
[faint]Faint[/faint] [\\faint]...[\\/faint]
|
11
|
+
[i]Italic[/i] [\\i]...[\\/i] or [\|italic]...[\\/italic]
|
12
|
+
[inv]Invert[/inv] [\\inv]...[\\/inv] or [\\invert]...[\\/invert]
|
13
|
+
[strike]Strike[/strike] [\\strike]...[\\/strike]
|
14
|
+
[h]Hide[/h] [\\h]...[\\/h] or [\\hide]...[\\/hide] or [\\conceal]...[\\/conceal]
|
15
|
+
[blink]Slow blink[/blink] [\\blink]...[\\/blink] or [\\slow_blink]...[\\/slow_blink]
|
16
|
+
[u]Underline[/u] [\\u]...[\\/u] or [\\underline]...[\\/underline]
|
17
|
+
[uu]Double underline[/uu] [\\uu]...[\\/uu] or [\\double_underline]...[\\/double_underline]
|
18
|
+
[cu]Curly underline[/cu] [\\cu]...[\\/cu] or [\\curly_underline]...[\\/curly_underline]
|
19
|
+
[dau]Dashed underline[/dau] [\\dau]...[\\/dau] or [\\dashed_underline]...[\\/dashed_underline]
|
20
|
+
[dou]Dotted underline[/dou] [\\dou]...[\\/dou] or [\\dotted_underline]...[\\/dotted_underline]
|
21
|
+
[fraktur]Fraktur[/fraktur] [\\fraktur]...[\\/fraktur]
|
22
|
+
[framed]Framed[/framed] [\\framed]...[\\/framed]
|
23
|
+
[encircled]Encircled[/encircled] [\\encircled]...[\\/encircled]
|
24
|
+
[ovr]Overlined[/ovr] [\\ovr]...[\\/ovr] or [\\overlined]...[\\/overlined]
|
25
|
+
[sub]Subscript[/sub] [\\sub]...[\\/sub] or [\\subscript]...[\\/subscript]
|
26
|
+
[sup]Superscript[/sup] [\\sup]...[\\/sup] or [\\superscript]...[\\/superscript]
|
27
|
+
|
28
|
+
TEXT
|
data/lib/just-ansi/version.rb
CHANGED
data/lib/just-ansi.rb
CHANGED
@@ -230,6 +230,27 @@ module JustAnsi
|
|
230
230
|
# @return [String] string without BBCode and ANSI control codes.
|
231
231
|
def plain(str) = unbbcode(str).gsub(TEST, '')
|
232
232
|
|
233
|
+
# Create nice colored text.
|
234
|
+
#
|
235
|
+
# @param str [#to_s] string to enrich with color
|
236
|
+
# @param frequence [Float] color change frequency
|
237
|
+
# @param spread [Float] number of chars with same color
|
238
|
+
# @param seed [Float] start index on sinus curve
|
239
|
+
# @return [String] fancy text
|
240
|
+
def rainbow(str, frequence: 0.3, spread: 0.8, seed: 1.1)
|
241
|
+
pos = -1
|
242
|
+
str
|
243
|
+
.to_s
|
244
|
+
.chars
|
245
|
+
.map! do |char|
|
246
|
+
i = (seed + ((pos += 1) / spread)) * frequence
|
247
|
+
"\e[38;2;#{(Math.sin(i) * 255).abs.to_i};" \
|
248
|
+
"#{(Math.sin(i + PI2_THIRD) * 255).abs.to_i};" \
|
249
|
+
"#{(Math.sin(i + PI4_THIRD) * 255).abs.to_i}m#{char}"
|
250
|
+
end
|
251
|
+
.join << RESET
|
252
|
+
end
|
253
|
+
|
233
254
|
# @!group Control functions
|
234
255
|
|
235
256
|
# Move cursor given lines up.
|
@@ -360,6 +381,18 @@ module JustAnsi
|
|
360
381
|
# @return (see cursor_up)
|
361
382
|
def line_erase = _line_erase(2)
|
362
383
|
|
384
|
+
# Insert given numbers of lines.
|
385
|
+
#
|
386
|
+
# @param (see cursor_up)
|
387
|
+
# @return (see cursor_up)
|
388
|
+
def line_insert(lines = 1) = "\e[#{lines}L"
|
389
|
+
|
390
|
+
# Delete given numbers of lines.
|
391
|
+
#
|
392
|
+
# @param (see cursor_up)
|
393
|
+
# @return (see cursor_up)
|
394
|
+
def line_delete(lines = 1) = "\e[#{lines}M"
|
395
|
+
|
363
396
|
# Scroll window given lines up.
|
364
397
|
#
|
365
398
|
# @param lines [Integer] number of lines to scroll
|
@@ -390,8 +423,6 @@ module JustAnsi
|
|
390
423
|
# This is not widely supported.
|
391
424
|
def link(url, text) = "\e]8;;#{url}\a#{text}\e]8;;\a"
|
392
425
|
|
393
|
-
# @comment simple def notify(title) = "\e]9;#{title}\a"
|
394
|
-
|
395
426
|
# @!endgroup
|
396
427
|
|
397
428
|
# @comment seems not widely supported:
|
@@ -401,10 +432,9 @@ module JustAnsi
|
|
401
432
|
# @comment def cursor_row_rel(rows = 1) = "\e[#{rows}e"
|
402
433
|
# @comment def cursor_tab(count = 1) = "\e[#{column}I"
|
403
434
|
# @comment def cursor_reverse_tab(count = 1) = "\e[#{count}Z"
|
404
|
-
# @comment def line_insert(lines = 1) = "\e[#{lines}L"
|
405
|
-
# @comment def line_delete(lines = 1) = "\e[#{lines}M"
|
406
435
|
# @comment def chars_delete(count = 1) = "\e[#{count}P"
|
407
436
|
# @comment def chars_erase(count = 1) = "\e[#{count}X"
|
437
|
+
# @comment simple def notify(title) = "\e]9;#{title}\a"
|
408
438
|
|
409
439
|
private
|
410
440
|
|
@@ -456,9 +486,15 @@ module JustAnsi
|
|
456
486
|
|
457
487
|
BBCODE = /(?:\[((?~[\[\]]))\])/
|
458
488
|
|
489
|
+
PI2_THIRD = 2 * Math::PI / 3
|
490
|
+
PI4_THIRD = 4 * Math::PI / 3
|
491
|
+
|
492
|
+
private_constant :TEST, :BBCODE, :PI2_THIRD, :PI4_THIRD
|
493
|
+
|
459
494
|
require_relative 'just-ansi/attributes'
|
495
|
+
|
460
496
|
autoload :NAMED_COLORS, File.join(__dir__, 'just-ansi', 'named_colors')
|
461
|
-
private_constant :
|
497
|
+
private_constant :NAMED_COLORS
|
462
498
|
|
463
499
|
# @!visibility private
|
464
500
|
RESET = self[:reset].freeze
|
data/lib/no-ansi.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'just-ansi'
|
4
|
+
|
5
|
+
#
|
6
|
+
# Shadow to {JustAnsi} but does **not** use ANSI codes.
|
7
|
+
# It can be used as a compatible {JustAnsi} replacement.
|
8
|
+
#
|
9
|
+
# @example Define global Ansi module depending on `NO_COLOR` environment variable
|
10
|
+
# Ansi = ENV.key?('NO_COLOR') ? NoAnsi : JustAnsi
|
11
|
+
#
|
12
|
+
# puts Ansi.bbcode('[b]Hello World![/b]')
|
13
|
+
# # => prints bold text when 'NO_COLOR' was not defined
|
14
|
+
#
|
15
|
+
# @see JustAnsi
|
16
|
+
#
|
17
|
+
module NoAnsi
|
18
|
+
class << self
|
19
|
+
# @!visibility private
|
20
|
+
def attributes = JustAnsi.attributes
|
21
|
+
# @!visibility private
|
22
|
+
def colors = JustAnsi.colors
|
23
|
+
# @!visibility private
|
24
|
+
def named_colors = JustAnsi.named_colors
|
25
|
+
# @!visibility private
|
26
|
+
def valid?(*attributes) = JustAnsi.valid?(*attributes)
|
27
|
+
# @!visibility private
|
28
|
+
def ansi?(str) = JustAnsi.ansi?(str)
|
29
|
+
# @!visibility private
|
30
|
+
def decorate(str, *_, **_) = JustAnsi.undecorate(str)
|
31
|
+
# @!visibility private
|
32
|
+
def undecorate(str) = JustAnsi.undecorate(str)
|
33
|
+
# @!visibility private
|
34
|
+
def bbcode(str) = JustAnsi.unbbcode(str)
|
35
|
+
# @!visibility private
|
36
|
+
def unbbcode(str) = JustAnsi.unbbcode(str)
|
37
|
+
# @!visibility private
|
38
|
+
def plain(str) = JustAnsi.plain(str)
|
39
|
+
|
40
|
+
# @!visibility private
|
41
|
+
def try_convert(attributes, seperator: ' ')
|
42
|
+
return unless attributes
|
43
|
+
return if (attributes = attributes.to_s.split(seperator)).empty?
|
44
|
+
+'' if JustAnsi.valid?(*attributes)
|
45
|
+
end
|
46
|
+
|
47
|
+
# @!visibility private
|
48
|
+
def [](*_) = +''
|
49
|
+
# @!visibility private
|
50
|
+
def rainbow(str, **_) = "#{str}"
|
51
|
+
# @!visibility private
|
52
|
+
def cursor_pos(_row, _column = nil) = +''
|
53
|
+
# @!visibility private
|
54
|
+
def link(_url, text) = "#{text}"
|
55
|
+
|
56
|
+
# @!visibility private
|
57
|
+
def dummy0 = +''
|
58
|
+
# @!visibility private
|
59
|
+
def dummy1(_ = 1) = +''
|
60
|
+
|
61
|
+
alias cursor_up dummy1
|
62
|
+
alias cursor_down dummy1
|
63
|
+
alias cursor_forward dummy1
|
64
|
+
alias cursor_back dummy1
|
65
|
+
alias cursor_next_line dummy1
|
66
|
+
alias cursor_previous_line dummy1
|
67
|
+
alias cursor_prev_line cursor_previous_line
|
68
|
+
alias cursor_column dummy1
|
69
|
+
alias cursor_show dummy0
|
70
|
+
alias cursor_hide dummy0
|
71
|
+
alias cursor_pos_safe dummy0
|
72
|
+
alias cursor_pos_restore dummy0
|
73
|
+
alias screen_erase_below dummy0
|
74
|
+
alias screen_erase_above dummy0
|
75
|
+
alias screen_erase dummy0
|
76
|
+
alias screen_erase_scrollback dummy0
|
77
|
+
alias screen_save dummy0
|
78
|
+
alias screen_restore dummy0
|
79
|
+
alias screen_alternate dummy0
|
80
|
+
alias screen_alternate_off dummy0
|
81
|
+
alias line_erase_to_end dummy0
|
82
|
+
alias line_erase_to_start dummy0
|
83
|
+
alias line_erase dummy0
|
84
|
+
alias line_insert dummy1
|
85
|
+
alias line_delete dummy1
|
86
|
+
alias scroll_up dummy1
|
87
|
+
alias scroll_down dummy1
|
88
|
+
alias window_title dummy1
|
89
|
+
alias tab_title dummy1
|
90
|
+
|
91
|
+
private :dummy0, :dummy1
|
92
|
+
end
|
93
|
+
|
94
|
+
JustAnsi.constants.each { const_set(_1, _1 == 'VERSION' ? _1 : '') }
|
95
|
+
end
|
metadata
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: just-ansi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Blumtritt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
15
|
-
|
13
|
+
description: |
|
14
|
+
JustAnsi provides a rich set of methods to generate ANSI control codes for
|
15
|
+
attributes, colors, cursor movement and much more. It supports most control
|
16
|
+
codes, all attributes, 3/4bit-, 8bit- and 24bit-colors.
|
16
17
|
email:
|
17
18
|
executables: []
|
18
19
|
extensions: []
|
@@ -20,14 +21,20 @@ extra_rdoc_files:
|
|
20
21
|
- README.md
|
21
22
|
- LICENSE
|
22
23
|
files:
|
24
|
+
- ".yardopts"
|
23
25
|
- LICENSE
|
24
26
|
- README.md
|
27
|
+
- examples/24bit-colors.rb
|
28
|
+
- examples/3bit-colors.rb
|
29
|
+
- examples/8bit-colors.rb
|
30
|
+
- examples/attributes.rb
|
31
|
+
- examples/bbcode.rb
|
25
32
|
- lib/just-ansi.rb
|
26
33
|
- lib/just-ansi/attributes.rb
|
27
34
|
- lib/just-ansi/named_colors.rb
|
28
|
-
- lib/just-ansi/string.rb
|
29
35
|
- lib/just-ansi/version.rb
|
30
36
|
- lib/just_ansi.rb
|
37
|
+
- lib/no-ansi.rb
|
31
38
|
homepage: https://github.com/mblumtritt/just-ansi
|
32
39
|
licenses:
|
33
40
|
- MIT
|
@@ -51,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
58
|
- !ruby/object:Gem::Version
|
52
59
|
version: '0'
|
53
60
|
requirements: []
|
54
|
-
rubygems_version: 3.5.
|
61
|
+
rubygems_version: 3.5.21
|
55
62
|
signing_key:
|
56
63
|
specification_version: 4
|
57
64
|
summary: Simple fast ANSI
|
data/lib/just-ansi/string.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../just-ansi'
|
4
|
-
|
5
|
-
#
|
6
|
-
# Ruby String class ANSI extension.
|
7
|
-
#
|
8
|
-
# This extension is not load by default but you need to require it.
|
9
|
-
#
|
10
|
-
# @example
|
11
|
-
# require 'just-ansi/string'
|
12
|
-
#
|
13
|
-
class String
|
14
|
-
# Test if String contains ANSI codes.
|
15
|
-
#
|
16
|
-
# @see JustAnsi.ansi?
|
17
|
-
#
|
18
|
-
# @return [true, false] whether if attributes are found
|
19
|
-
def ansi? = JustAnsi.ansi?(self)
|
20
|
-
|
21
|
-
# Decorate self with ANSI attributes and colors.
|
22
|
-
#
|
23
|
-
# @see JustAnsi.decorate
|
24
|
-
#
|
25
|
-
# @param attributes [Array<Symbol, String>] attribute names to be used
|
26
|
-
# @param reset [true, false] whether to include reset code for ANSI attributes
|
27
|
-
# @return [String] `str` converted and decorated with the ANSI `attributes`
|
28
|
-
def ansi(*attributes, reset: true)
|
29
|
-
JustAnsi.decorate(self, *attributes, reset: reset)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Remove ANSI functions, attributes and colors from self.
|
33
|
-
#
|
34
|
-
# @see JustAnsi.undecorate
|
35
|
-
#
|
36
|
-
# @return [String] string without ANSI attributes
|
37
|
-
def unansi = JustAnsi.undecorate(self)
|
38
|
-
|
39
|
-
if defined?(:bbcode)
|
40
|
-
def bbcode = JustAnsi.bbcode(super)
|
41
|
-
else
|
42
|
-
# Replace embedded BBCode-like attributes with ANSI codes.
|
43
|
-
#
|
44
|
-
# @see JustAnsi.bbcode
|
45
|
-
#
|
46
|
-
# @return [String] string with ANSI attributes
|
47
|
-
def bbcode = JustAnsi.bbcode(self)
|
48
|
-
end
|
49
|
-
|
50
|
-
if defined?(:unbbcode)
|
51
|
-
def unbbcode = JustAnsi.unbbcode(super)
|
52
|
-
else
|
53
|
-
# Remove embedded BBCode-like attributes.
|
54
|
-
#
|
55
|
-
# @see JustAnsi.unbbcode
|
56
|
-
#
|
57
|
-
# @return [String] string without BBCode
|
58
|
-
def unbbcode = JustAnsi.unbbcode(self)
|
59
|
-
end
|
60
|
-
|
61
|
-
if defined?(:plain)
|
62
|
-
def plain = JustAnsi.plain(super)
|
63
|
-
else
|
64
|
-
# Remove any BBCode-like and/or ANSI attributes.
|
65
|
-
#
|
66
|
-
# @see JustAnsi.plain
|
67
|
-
#
|
68
|
-
# @return [String] string without BBCode and ANSI control codes.
|
69
|
-
def plain = JustAnsi.plain(self)
|
70
|
-
end
|
71
|
-
end
|