natty-ui 0.7.0 → 0.9.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 +7 -3
- data/README.md +25 -47
- data/examples/24bit-colors.rb +27 -0
- data/examples/3bit-colors.rb +14 -0
- data/examples/8bit-colors.rb +31 -0
- data/examples/animate.rb +24 -0
- data/examples/attributes.rb +25 -159
- data/examples/demo.rb +53 -0
- data/examples/illustration.png +0 -0
- data/examples/illustration.rb +29 -0
- data/examples/{list_in_columns.rb → ls.rb} +13 -20
- data/examples/message.rb +30 -0
- data/examples/progress.rb +25 -30
- data/examples/query.rb +26 -28
- data/examples/read_key.rb +13 -0
- data/examples/table.rb +36 -0
- data/lib/natty-ui/ansi.rb +351 -305
- data/lib/natty-ui/ansi_constants.rb +73 -0
- data/lib/natty-ui/ansi_wrapper.rb +136 -162
- data/lib/natty-ui/features.rb +11 -18
- data/lib/natty-ui/key_map.rb +119 -0
- data/lib/natty-ui/line_animation/default.rb +35 -0
- data/lib/natty-ui/line_animation/matrix.rb +28 -0
- data/lib/natty-ui/line_animation/rainbow.rb +30 -0
- data/lib/natty-ui/line_animation/test.rb +29 -0
- data/lib/natty-ui/line_animation/type_writer.rb +64 -0
- data/lib/natty-ui/line_animation.rb +54 -0
- data/lib/natty-ui/version.rb +2 -2
- data/lib/natty-ui/wrapper/animate.rb +17 -0
- data/lib/natty-ui/wrapper/ask.rb +21 -21
- data/lib/natty-ui/wrapper/element.rb +19 -23
- data/lib/natty-ui/wrapper/framed.rb +29 -19
- data/lib/natty-ui/wrapper/heading.rb +26 -53
- data/lib/natty-ui/wrapper/horizontal_rule.rb +37 -0
- data/lib/natty-ui/wrapper/list_in_columns.rb +71 -12
- data/lib/natty-ui/wrapper/message.rb +20 -27
- data/lib/natty-ui/wrapper/progress.rb +40 -13
- data/lib/natty-ui/wrapper/query.rb +34 -31
- data/lib/natty-ui/wrapper/quote.rb +25 -0
- data/lib/natty-ui/wrapper/request.rb +21 -10
- data/lib/natty-ui/wrapper/section.rb +55 -39
- data/lib/natty-ui/wrapper/table.rb +298 -0
- data/lib/natty-ui/wrapper/task.rb +6 -7
- data/lib/natty-ui/wrapper.rb +123 -41
- data/lib/natty-ui.rb +65 -40
- metadata +28 -9
- data/examples/basic.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05a38cff2c6416d6d7832c3c053d63ebf23977a67abf485e555c35e206fe768b
|
4
|
+
data.tar.gz: 14363fcea12c6dbb45ce7e7b8dec8d68668f5faa4a8f20793b212e9bb9bd5905
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e5031c308e7f63c4f99ba4d6558cf3a3effab04f475f568054c079b6da3908c47df2581259a6c93f661c51e623baafeed61c91e6fe0c025f55bc0adf2b18d17
|
7
|
+
data.tar.gz: 6275cb88ce6f4822b57debd98a9b8c560198fb3c48028768fd39401320339561b777512d3e0ddbc15a14dd250ef60b592777453f7733156925f525755e4e1678
|
data/.yardopts
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
--readme README.md
|
2
1
|
--title 'NattyUI Documentation'
|
3
2
|
--charset utf-8
|
4
3
|
--markup markdown
|
4
|
+
--readme README.md
|
5
|
+
--no-private
|
6
|
+
--embed-mixins
|
5
7
|
--tag comment
|
6
8
|
--hide-tag comment
|
7
|
-
--embed-mixins
|
8
9
|
--exclude lib/natty-ui/ansi_wrapper.rb
|
9
|
-
|
10
|
+
lib/**/*.rb
|
11
|
+
-
|
12
|
+
README.md
|
13
|
+
LICENSE
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# NattyUI 
|
2
2
|
|
3
|
-
This is the beautiful, nice, nifty, fancy, neat, pretty, cool, lovely, natty user interface you like to have for your command line interfaces
|
3
|
+
This is the beautiful, nice, nifty, fancy, neat, pretty, cool, lovely, natty user interface you like to have for your command line applications. It contains elegant, simple and beautiful tools that enhance your command line interfaces functionally and aesthetically.
|
4
4
|
|
5
5
|
- Gem: [rubygems.org](https://rubygems.org/gems/natty-ui)
|
6
6
|
- Source: [github.com](https://github.com/mblumtritt/natty-ui)
|
@@ -13,40 +13,43 @@ Here you find elegant, simple and beautiful tools that enhance your command line
|
|
13
13
|
You can simply decorate your text with named ANSI attributes and colors
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
|
17
|
-
|
18
|
-
UI.puts "[[bold]]Hello [[ff7bfd]]World[[/]]!"
|
16
|
+
ui.puts "[[bold]]Hello [[ff7bfd]]World[[/]]!"
|
19
17
|
```
|
20
18
|
|
21
19
|
or use different types of messages
|
22
20
|
|
23
21
|
```ruby
|
24
|
-
|
25
|
-
|
22
|
+
ui.info 'NattyUI installed'
|
23
|
+
ui.warning 'Nice gem found!'
|
26
24
|
```
|
27
25
|
|
28
|
-
and headings
|
26
|
+
and headings, framed sections, progress bars and tasks, queries, tables and much much more…
|
29
27
|
|
30
|
-
|
31
|
-
UI.h1 'The Main Title (TMT)'
|
32
|
-
UI.h2 'A Subtitle'
|
33
|
-
```
|
28
|
+
🚀 Have a look at the [features](https://rubydoc.info/gems/natty-ui/NattyUI/Features)!
|
34
29
|
|
35
|
-
|
30
|
+

|
36
31
|
|
37
|
-
|
38
|
-
UI.framed 'Text Below In Frame' do |framed|
|
39
|
-
framed.puts 'This is the text'
|
40
|
-
end
|
41
|
-
```
|
32
|
+
## NO_COLOR Convention
|
42
33
|
|
43
|
-
|
34
|
+
NattyUI follows the [NO_COLOR convention](https://no-color.org).
|
44
35
|
|
45
|
-
|
36
|
+
## Help
|
46
37
|
|
47
|
-
📕 See the [online help](https://rubydoc.info/gems/natty-ui/NattyUI)
|
38
|
+
📕 See the [online help](https://rubydoc.info/gems/natty-ui/NattyUI) and have a look at the [examples](./examples/) directory to learn from code.
|
48
39
|
|
49
|
-
|
40
|
+
### Run Examples
|
41
|
+
|
42
|
+
You can execute the examples by
|
43
|
+
|
44
|
+
```sh
|
45
|
+
ruby ./examples/demo.rb
|
46
|
+
```
|
47
|
+
|
48
|
+
or see the non-ANSI version
|
49
|
+
|
50
|
+
```sh
|
51
|
+
NO_COLOR=1 ruby ./examples/demo.rb
|
52
|
+
```
|
50
53
|
|
51
54
|
## Installation
|
52
55
|
|
@@ -59,7 +62,7 @@ gem install natty-ui
|
|
59
62
|
or you can use [Bundler](http://gembundler.com/) to add NattyUI to your own project:
|
60
63
|
|
61
64
|
```shell
|
62
|
-
bundle add
|
65
|
+
bundle add natty-ui
|
63
66
|
```
|
64
67
|
|
65
68
|
After that you only need one line of code to have everything together
|
@@ -67,28 +70,3 @@ After that you only need one line of code to have everything together
|
|
67
70
|
```ruby
|
68
71
|
require 'natty-ui'
|
69
72
|
```
|
70
|
-
|
71
|
-
## Run Examples
|
72
|
-
|
73
|
-
You can execute the examples by
|
74
|
-
|
75
|
-
```sh
|
76
|
-
bundle exec ruby ./examples/basic.rb
|
77
|
-
```
|
78
|
-
|
79
|
-
or see the non-ANSI version
|
80
|
-
|
81
|
-
```sh
|
82
|
-
NO_COLOR=1 bundle exec ruby ./examples/basic.rb
|
83
|
-
```
|
84
|
-
|
85
|
-
## NO_COLOR Convention
|
86
|
-
|
87
|
-
NattyUI follows the [NO_COLOR convention](https://no-color.org).
|
88
|
-
|
89
|
-
## TODO
|
90
|
-
|
91
|
-
Since I did not complete the tests and not all my ideas are already implemented I have this Todo list:
|
92
|
-
|
93
|
-
- add more samples to help
|
94
|
-
- add more tests
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/natty-ui'
|
4
|
+
|
5
|
+
ui.space
|
6
|
+
ui.h1 'NattyUI: 24-bit Color Support'
|
7
|
+
ui.space
|
8
|
+
|
9
|
+
RGB_COLORS = <<~SAMPLES.lines(chomp: true).map!(&:split)
|
10
|
+
#800000 #8b0000 #a52a2a #b22222 #dc143c #ff0000 #ff6347 #ff7f50
|
11
|
+
#cd5c5c #f08080 #e9967a #fa8072 #ffa07a #ff4500 #ff8c00 #ffa500
|
12
|
+
#ffd700 #b8860b #daa520 #eee8aa #bdb76b #f0e68c #808000 #ffff00
|
13
|
+
#9acd32 #556b2f #6b8e23 #7cfc00 #7fff00 #adff2f #006400 #008000
|
14
|
+
#228b22 #00ff00 #32cd32 #90ee90 #98fb98 #8fbc8f #00fa9a #00ff7f
|
15
|
+
#2e8b57 #66cdaa #3cb371 #20b2aa #2f4f4f #008080 #008b8b #00ffff
|
16
|
+
#00ffff #e0ffff #00ced1 #40e0d0 #48d1cc #afeeee #7fffd4 #b0e0e6
|
17
|
+
#5f9ea0 #4682b4 #6495ed #00bfff #1e90ff #add8e6 #87ceeb #87cefa
|
18
|
+
SAMPLES
|
19
|
+
|
20
|
+
RGB_COLORS.each { ui.puts _1.map { |v| " [[#{v}]]#{v}[[/]] " }.join }
|
21
|
+
ui.space
|
22
|
+
RGB_COLORS.each { ui.puts _1.map { |v| " [[on:#{v}]]#{v}[[/]] " }.join }
|
23
|
+
ui.space
|
24
|
+
RGB_COLORS.each do |code|
|
25
|
+
ui.puts code.map { |v| " [[underline ul:#{v}]]#{v}[[/]] " }.join
|
26
|
+
end
|
27
|
+
ui.space
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/natty-ui'
|
4
|
+
|
5
|
+
ui.space
|
6
|
+
ui.h1 'NattyUI: 3/4-bit Color Support'
|
7
|
+
ui.space
|
8
|
+
|
9
|
+
color = ->(n) { "[[#{n}]]#{n.ljust(14)}[[/]] [[on_#{n}]] sample text [[/]]" }
|
10
|
+
%w[black red green yellow blue magenta cyan white].each do |name|
|
11
|
+
ui.puts "#{color[name]} #{color["bright_#{name}"]}"
|
12
|
+
end
|
13
|
+
|
14
|
+
ui.space
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/natty-ui'
|
4
|
+
|
5
|
+
ui.space
|
6
|
+
ui.h1 'NattyUI: 8-bit Color Support'
|
7
|
+
ui.space
|
8
|
+
|
9
|
+
color = ->(i) { "[[bg#{i = i.to_s(16).rjust(2, '0')}]] #{i} " }
|
10
|
+
ui.msg 'System Colors', glyph: '[[27]]◉' do
|
11
|
+
ui.puts "[[#ff]]#{0.upto(7).map(&color).join}"
|
12
|
+
ui.puts "[[#00]]#{8.upto(15).map(&color).join}"
|
13
|
+
ui.space
|
14
|
+
end
|
15
|
+
|
16
|
+
ui.msg '6x6x6 Color Cube', glyph: '[[27]]◉' do
|
17
|
+
[16, 22, 28].each do |b|
|
18
|
+
b.step(b + 185, by: 36) do |i|
|
19
|
+
left = i.upto(i + 5).map(&color).join
|
20
|
+
right = (i + 18).upto(i + 23).map(&color).join
|
21
|
+
ui.puts "[[#ff]]#{left}[[bg_default]] #{right}"
|
22
|
+
end
|
23
|
+
ui.space
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
ui.msg 'Grayscale', glyph: '[[27]]◉' do
|
28
|
+
ui.puts "[[#ff]]#{232.upto(243).map(&color).join}"
|
29
|
+
ui.puts "[[#ff]]#{244.upto(255).map(&color).join}"
|
30
|
+
ui.space
|
31
|
+
end
|
data/examples/animate.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/natty-ui'
|
4
|
+
|
5
|
+
ui.space
|
6
|
+
ui.h1 'NattyUI: Text Line Animation'
|
7
|
+
ui.space
|
8
|
+
|
9
|
+
TEXT = <<~TEXT.tr("\n", ' ')
|
10
|
+
Lorem [[yellow]]ipsum[[/]] dolor sit amet, consectetur adipisicing elit, sed
|
11
|
+
do eiusmod tempor incididunt ut labore et dolore [[red]]magna[[/]] aliqua.
|
12
|
+
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
|
13
|
+
aliquip ex ea commodo [[bold]]consequat[[/]].
|
14
|
+
TEXT
|
15
|
+
|
16
|
+
{
|
17
|
+
default: 'Default Animation',
|
18
|
+
type_writer: 'Typewriter Like',
|
19
|
+
rainbow: 'Shiny Rainbow',
|
20
|
+
matrix: 'Matrix Style'
|
21
|
+
}.each_pair do |type, title|
|
22
|
+
ui.message(title, glyph: '[[27]]◉') { ui.animate TEXT, animation: type }
|
23
|
+
ui.space
|
24
|
+
end
|
data/examples/attributes.rb
CHANGED
@@ -1,161 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
[[
|
23
|
-
|
24
|
-
[[
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
• [[primary_font]]primary_font[[/]]
|
29
|
-
• [[font1]]font1[[/]]
|
30
|
-
• [[font2]]font2[[/]]
|
31
|
-
• [[font3]]font3[[/]]
|
32
|
-
• [[font4]]font4[[/]]
|
33
|
-
• [[font5]]font5[[/]]
|
34
|
-
• [[font6]]font6[[/]]
|
35
|
-
• [[font7]]font7[[/]]
|
36
|
-
• [[font8]]font8[[/]]
|
37
|
-
• [[font9]]font9[[/]]
|
38
|
-
• [[fraktur]]fraktur[[/]]
|
39
|
-
|
40
|
-
TEXT
|
41
|
-
|
42
|
-
UI.h2 '3-bit and 4-bit Colors' do |sec|
|
43
|
-
sec.space
|
44
|
-
colors = %w[black red green yellow blue magenta cyan white].freeze
|
45
|
-
(colors + colors.map { |name| "bright_#{name}" }).each do |name|
|
46
|
-
sec.puts " [[#{name}]]#{name.ljust(14)}[[/]] [[on_#{name}]]sample text"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
UI.space
|
50
|
-
|
51
|
-
UI.h2 '8-bit Colors' do |sec|
|
52
|
-
sec.space
|
53
|
-
sec.puts 'There are 256 pre-defined color which can be used by their index:'
|
54
|
-
sec.space
|
55
|
-
|
56
|
-
# helper:
|
57
|
-
colors_std = 0.upto(15)
|
58
|
-
colors216 = 16.upto(231).lazy
|
59
|
-
colors_gray1 = 232.upto(243)
|
60
|
-
colors_gray2 = 244.upto(255)
|
61
|
-
as_color = ->(i) { "[[#{i = i.to_s(16).rjust(2, '0')}]] #{i} [[/]]" }
|
62
|
-
as_bgcolor = ->(i) { "[[on:#{i.to_s(16).rjust(2, '0')}]] #{i} [[/]]" }
|
63
|
-
|
64
|
-
sec.puts colors_std.map(&as_color).join
|
65
|
-
colors216.each_slice(18) { |slice| sec.puts slice.map(&as_color).join }
|
66
|
-
sec.puts colors_gray1.map(&as_color).join
|
67
|
-
sec.puts colors_gray2.map(&as_color).join
|
68
|
-
|
69
|
-
sec.space
|
70
|
-
sec.puts colors_std.map(&as_bgcolor).join
|
71
|
-
colors216.each_slice(18) { |slice| sec.puts slice.map(&as_bgcolor).join }
|
72
|
-
sec.puts colors_gray1.map(&as_bgcolor).join
|
73
|
-
sec.puts colors_gray2.map(&as_bgcolor).join
|
74
|
-
end
|
75
|
-
|
76
|
-
UI.space
|
77
|
-
UI.h2 '24-bit colors' do |sec|
|
78
|
-
sec.puts <<~TEXT
|
79
|
-
|
80
|
-
Modern terminal applications support 24-bit colors for foreground and background
|
81
|
-
RGB-color values. Here are just some samples:
|
82
|
-
|
83
|
-
TEXT
|
84
|
-
|
85
|
-
some_rgb = DATA.readlines(chomp: true).lazy.each_slice(8)
|
86
|
-
|
87
|
-
some_rgb.each do |slice|
|
88
|
-
sec.puts slice.map { |v| " [[#{v}]]#{v}[[/]] " }.join
|
89
|
-
end
|
90
|
-
sec.space
|
91
|
-
some_rgb.each do |slice|
|
92
|
-
sec.puts slice.map { |v| " [[on:#{v}]]#{v}[[/]] " }.join
|
93
|
-
end
|
94
|
-
end
|
95
|
-
UI.space
|
96
|
-
|
97
|
-
__END__
|
98
|
-
#800000
|
99
|
-
#8b0000
|
100
|
-
#a52a2a
|
101
|
-
#b22222
|
102
|
-
#dc143c
|
103
|
-
#ff0000
|
104
|
-
#ff6347
|
105
|
-
#ff7f50
|
106
|
-
#cd5c5c
|
107
|
-
#f08080
|
108
|
-
#e9967a
|
109
|
-
#fa8072
|
110
|
-
#ffa07a
|
111
|
-
#ff4500
|
112
|
-
#ff8c00
|
113
|
-
#ffa500
|
114
|
-
#ffd700
|
115
|
-
#b8860b
|
116
|
-
#daa520
|
117
|
-
#eee8aa
|
118
|
-
#bdb76b
|
119
|
-
#f0e68c
|
120
|
-
#808000
|
121
|
-
#ffff00
|
122
|
-
#9acd32
|
123
|
-
#556b2f
|
124
|
-
#6b8e23
|
125
|
-
#7cfc00
|
126
|
-
#7fff00
|
127
|
-
#adff2f
|
128
|
-
#006400
|
129
|
-
#008000
|
130
|
-
#228b22
|
131
|
-
#00ff00
|
132
|
-
#32cd32
|
133
|
-
#90ee90
|
134
|
-
#98fb98
|
135
|
-
#8fbc8f
|
136
|
-
#00fa9a
|
137
|
-
#00ff7f
|
138
|
-
#2e8b57
|
139
|
-
#66cdaa
|
140
|
-
#3cb371
|
141
|
-
#20b2aa
|
142
|
-
#2f4f4f
|
143
|
-
#008080
|
144
|
-
#008b8b
|
145
|
-
#00ffff
|
146
|
-
#00ffff
|
147
|
-
#e0ffff
|
148
|
-
#00ced1
|
149
|
-
#40e0d0
|
150
|
-
#48d1cc
|
151
|
-
#afeeee
|
152
|
-
#7fffd4
|
153
|
-
#b0e0e6
|
154
|
-
#5f9ea0
|
155
|
-
#4682b4
|
156
|
-
#6495ed
|
157
|
-
#00bfff
|
158
|
-
#1e90ff
|
159
|
-
#add8e6
|
160
|
-
#87ceeb
|
161
|
-
#87cefa
|
3
|
+
require_relative '../lib/natty-ui'
|
4
|
+
|
5
|
+
ui.space
|
6
|
+
ui.h2 'NattyUI: ANSI Attributes'
|
7
|
+
ui.space
|
8
|
+
|
9
|
+
ui.puts <<~PARA1.tr("\n", ' '), <<~PARA2.tr("\n", ' ')
|
10
|
+
Some attributes are widely supported, such as [[bold]]bold[[/]],
|
11
|
+
[[italic]]italic[[/]], [[underline]]underline[[/]], [[blink]]blink[[/]],
|
12
|
+
[[invert]]invert[[/]] and [[strike]]strike[[/]], while others are rarely
|
13
|
+
complete or correctly implemented, like [[faint]]faint[[/]],
|
14
|
+
[[double_underline]]double underline[[/]], [[curly_underline]]curly
|
15
|
+
underline[[/]], [[dotted_underline]]dotted underline[[/]],
|
16
|
+
[[dashed_underline]]dashed underline[[/]], [[rapid_blink]]rapid_blink[[/]],
|
17
|
+
[[framed]]framed[[/]], [[encircled]]encircled[[/]],
|
18
|
+
[[overlined]]overlined[[/]] and [[proportional]]proportional[[/]].
|
19
|
+
PARA1
|
20
|
+
Alternative fonts are mostly completely ignored:
|
21
|
+
[[primary_font]]primary_font[[/]], [[fraktur]]fraktur[[/]],
|
22
|
+
[[font1]]font1[[/]], [[font2]]font2[[/]], [[font3]]font3[[/]],
|
23
|
+
[[font4]]font4[[/]], [[font5]]font5[[/]], [[font6]]font6[[/]],
|
24
|
+
[[font7]]font7[[/]], [[font8]]font8[[/]], [[font9]]font9[[/]].
|
25
|
+
PARA2
|
26
|
+
|
27
|
+
ui.space
|
data/examples/demo.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/natty-ui'
|
4
|
+
|
5
|
+
ui.page do
|
6
|
+
ui.space
|
7
|
+
ui.h1 'NattyUI: Examples'
|
8
|
+
ui.space
|
9
|
+
|
10
|
+
ruby =
|
11
|
+
ENV.fetch('RUBY') do
|
12
|
+
require('rbconfig')
|
13
|
+
File.join(
|
14
|
+
RbConfig::CONFIG['bindir'],
|
15
|
+
"#{RbConfig::CONFIG['ruby_install_name']}#{RbConfig::CONFIG['EXEEXT']}"
|
16
|
+
).sub(/.*\s.*/m, '"\&"')
|
17
|
+
end
|
18
|
+
run = ->(name) { system(ruby, File.join(__dir__, "#{name}.rb")) }
|
19
|
+
run['illustration']
|
20
|
+
|
21
|
+
ui.space
|
22
|
+
|
23
|
+
choices = {}
|
24
|
+
examples = {}
|
25
|
+
{
|
26
|
+
'1' => ['attributes', 'ANSI Attributes'],
|
27
|
+
'2' => ['message', 'Message Types'],
|
28
|
+
'3' => ['3bit-colors', '3/4-bit Color Support'],
|
29
|
+
'4' => ['8bit-colors', '8-bit Color Support'],
|
30
|
+
'5' => ['24bit-colors', '24-bit Color Support'],
|
31
|
+
'6' => ['ls', 'Print In Columns'],
|
32
|
+
'7' => %w[table Tables],
|
33
|
+
'8' => ['animate', 'Text Line Animation'],
|
34
|
+
'9' => ['progress', 'Progress Indication'],
|
35
|
+
'0' => ['query', 'User Queries'],
|
36
|
+
'ESC' => [nil, 'Exit Demo']
|
37
|
+
}.each_pair do |key, (name, descr)|
|
38
|
+
examples[key] = name
|
39
|
+
choices[key] = descr
|
40
|
+
end
|
41
|
+
|
42
|
+
loop do
|
43
|
+
choice =
|
44
|
+
ui.query(
|
45
|
+
'Which example do you like to watch?',
|
46
|
+
display: :compact,
|
47
|
+
**choices
|
48
|
+
) or break
|
49
|
+
example = examples[choice] or break
|
50
|
+
ui.cls
|
51
|
+
run[example]
|
52
|
+
end
|
53
|
+
end
|
data/examples/illustration.png
CHANGED
Binary file
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/natty-ui'
|
4
|
+
|
5
|
+
ui.framed do
|
6
|
+
ui.msg('Natty UI', <<~TEXT.tr("\n", ' '), glyph: '⭐️')
|
7
|
+
This is the [[c4]]beautiful[[/]], [[c5]]nice[[/]], [[c6]]nifty[[/]],
|
8
|
+
[[c7]]fancy[[/]], [[c8]]neat[[/]], [[c9]]pretty[[/]], [[ca]]cool[[/]],
|
9
|
+
[[cb]]lovely[[/]], [[cc]]natty[[/]] [[bold]]user interface[[/]] you like to
|
10
|
+
have for your command line applications. It contains [[italic]]elegant[[/]],
|
11
|
+
[[italic]]simple[[/]] and [[italic]]beautiful[[/]] tools that enhance your
|
12
|
+
command line interfaces functionally and aesthetically.
|
13
|
+
TEXT
|
14
|
+
|
15
|
+
ui.msg('Features', glyph: '⭐️') { ui.ls(<<~FEATURES.lines(chomp: true)) }
|
16
|
+
[[bold red]]T[[/]] text attributes
|
17
|
+
🌈 text coloring
|
18
|
+
🔦 text animation
|
19
|
+
🎩 heading elements
|
20
|
+
📏 horizontal rulers
|
21
|
+
📝 messages
|
22
|
+
[[bold blue]]""[[/]] quote blocks
|
23
|
+
[[yellow]]🄵[[/]] framed blocks
|
24
|
+
✅ tasks
|
25
|
+
[[bold green]]…[[/]] progress bars
|
26
|
+
[[blue]]┼┼[[/]] tables
|
27
|
+
[[bold bright_white]]>[[bright_red]]_[[/]] user input
|
28
|
+
FEATURES
|
29
|
+
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../lib/natty-ui'
|
4
4
|
|
5
|
-
|
5
|
+
ui.space
|
6
|
+
ui.h1 'NattyUI: Print In Columns'
|
7
|
+
ui.space
|
6
8
|
|
7
|
-
LOREM = <<~
|
9
|
+
LOREM = <<~IPSUM.lines(chomp: true)
|
8
10
|
Lorem ipsum dolor sit
|
9
11
|
amet, consectetur adipisicing
|
10
12
|
elit, sed do eiusmod tempor
|
@@ -14,7 +16,7 @@ LOREM = <<~LOREM
|
|
14
16
|
nostrud exercitation ullamco
|
15
17
|
laboris nisi ut aliquip ex
|
16
18
|
ea commodo [[bold]]consequat[[/]]. Duis
|
17
|
-
aute irure dolor in
|
19
|
+
aute irure [[bold green]]dolor[[/]] in
|
18
20
|
reprehenderit in voluptate
|
19
21
|
velit [[underline]]esse cillum[[/]] dolore eu
|
20
22
|
fugiat nulla pariatur.
|
@@ -23,21 +25,12 @@ LOREM = <<~LOREM
|
|
23
25
|
sunt in culpa qui officia
|
24
26
|
deserunt mollit anim id
|
25
27
|
est laborum.
|
26
|
-
|
27
|
-
WORDS = LOREM.split(/\W+/).uniq.sort!.freeze
|
28
|
+
IPSUM
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
ui.h2 'Compact Display'
|
31
|
+
ui.ls LOREM, glyph: 1
|
32
|
+
ui.space
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
UI.h3 'Lorem ipsum word list (compact)'
|
38
|
-
UI.ls WORDS
|
39
|
-
UI.space
|
40
|
-
|
41
|
-
UI.h3 'Lorem ipsum word list (row-wise)'
|
42
|
-
UI.ls WORDS, compact: false
|
43
|
-
UI.space
|
34
|
+
ui.h2 'Traditional Display'
|
35
|
+
ui.ls LOREM, glyph: 1, compact: false
|
36
|
+
ui.space
|
data/examples/message.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/natty-ui'
|
4
|
+
|
5
|
+
ui.space
|
6
|
+
ui.h1 'NattyUI: Message Types'
|
7
|
+
ui.space
|
8
|
+
|
9
|
+
TEXT = <<~TEXT.tr("\n", ' ')
|
10
|
+
Lorem [[yellow]]ipsum[[/]] dolor sit amet, consectetur adipisicing elit, sed
|
11
|
+
do eiusmod tempor incididunt ut labore et dolore [[red]]magna[[/]] aliqua.
|
12
|
+
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
|
13
|
+
aliquip ex ea commodo [[bold]]consequat[[/]].
|
14
|
+
TEXT
|
15
|
+
|
16
|
+
IMPORTANT =
|
17
|
+
'[[red]]>>>[[/]] [[italic]]Here some important information[[/]] [[red]]<<<'
|
18
|
+
|
19
|
+
ui.framed do
|
20
|
+
ui.info 'Informative Message', TEXT
|
21
|
+
ui.warning 'Warning Message' do
|
22
|
+
ui.puts TEXT
|
23
|
+
ui.framed { ui.puts IMPORTANT }
|
24
|
+
end
|
25
|
+
ui.error 'Error Message', TEXT
|
26
|
+
ui.failed 'Fail Message', TEXT
|
27
|
+
ui.message '[[italic #fad]]Custom Message', TEXT, glyph: '💡'
|
28
|
+
end
|
29
|
+
|
30
|
+
ui.space
|