natty-ui 0.6.0 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 666f2716f2f1d017789bbbfef2d640b7c89af6d006ea051e8575282c806b88f6
4
- data.tar.gz: 44922a307f8f62e69d3df00ba656be1164ba20234ac12d621df0eb86fa5ce39e
3
+ metadata.gz: 2010faafec270df6749dff93943748316c626939965e501dbe6bdb224514e2dc
4
+ data.tar.gz: 0eecd3c29cc7b90cd70a6d40245b18fdbc8556232b6a3795ba2d92ffbaea5123
5
5
  SHA512:
6
- metadata.gz: 74d474a1f3876ae3825cadc289250a8f3fb545b4147c26c20861a90b3e9665b249cde0075ae9813a1d668c69671540cb332aaf75cae667fc4a9fe5c0d272a88e
7
- data.tar.gz: 4a872db3d8b96ddf6edf42b865eb9dffc8ee87994d6ae6617c842055062eeca4c45f4bac8df644b1e1a0a7b0fd5e4cfd6c53cee88c6a66681657b83879f12c19
6
+ metadata.gz: 6d2939a6c9bd6256a9de3e14b80ab9a67a6fa1108f20f2073e6ef0762789531016ef641bbfd451a0f3ac6c87079bd771a71853043744e481ed867616e392466e
7
+ data.tar.gz: 106fc8ddca80ccf6eb8933fdf835d7373afba963df8625267f37b1a9795ac6be22671123e18baa72ec6b5ded1c3f76f98d5f4dd905de935d465a2751ce690fad
data/.yardopts ADDED
@@ -0,0 +1,12 @@
1
+ --readme README.md
2
+ --title 'NattyUI Documentation'
3
+ --charset utf-8
4
+ --markup markdown
5
+ --tag comment
6
+ --hide-tag comment
7
+ --embed-mixins
8
+ --exclude lib/natty-ui/ansi_wrapper.rb
9
+ lib/**/*.rb
10
+ -
11
+ README.md
12
+ LICENSE
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # NattyUI ![version](https://img.shields.io/gem/v/natty-ui?label=)
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 (CLI).
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
- UI = NattyUI::StdOut
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
- UI.info 'NattyUI installed'
25
- UI.warning 'Nice gem found!'
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
- ```ruby
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
- and framed sections
30
+ ![illustration](https://raw.githubusercontent.com/mblumtritt/natty-ui/main/examples/illustration.png)
36
31
 
37
- ```ruby
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
- or use progression displays like progress bars.
34
+ NattyUI follows the [NO_COLOR convention](https://no-color.org).
44
35
 
45
- 🚀 There are much more [features](https://rubydoc.info/gems/natty-ui/NattyUI/Features)!
36
+ ## Help
46
37
 
47
- 📕 See the [online help](https://rubydoc.info/gems/natty-ui/NattyUI) for more details or have a look at the [examples](./examples/) directory to get an impression of the current feature set.
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
- ![illustration](https://raw.githubusercontent.com/mblumtritt/natty-ui/main/examples/illustration.png)
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 'natty-ui'
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,29 +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
95
- - password prompt
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'natty-ui'
4
+
5
+ RGB_COLORS = <<~RGB_COLORS.lines(chomp: true).map!(&:split)
6
+ #800000 #8b0000 #a52a2a #b22222 #dc143c #ff0000 #ff6347 #ff7f50
7
+ #cd5c5c #f08080 #e9967a #fa8072 #ffa07a #ff4500 #ff8c00 #ffa500
8
+ #ffd700 #b8860b #daa520 #eee8aa #bdb76b #f0e68c #808000 #ffff00
9
+ #9acd32 #556b2f #6b8e23 #7cfc00 #7fff00 #adff2f #006400 #008000
10
+ #228b22 #00ff00 #32cd32 #90ee90 #98fb98 #8fbc8f #00fa9a #00ff7f
11
+ #2e8b57 #66cdaa #3cb371 #20b2aa #2f4f4f #008080 #008b8b #00ffff
12
+ #00ffff #e0ffff #00ced1 #40e0d0 #48d1cc #afeeee #7fffd4 #b0e0e6
13
+ #5f9ea0 #4682b4 #6495ed #00bfff #1e90ff #add8e6 #87ceeb #87cefa
14
+ RGB_COLORS
15
+
16
+ ui.space
17
+ ui.h1 '24-bit Color Support'
18
+ ui.space
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
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'natty-ui'
4
+
5
+ ui.space
6
+ ui.h1 '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
+ ui.space
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'natty-ui'
4
+
5
+ ui.space
6
+ ui.h1 '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
@@ -2,13 +2,9 @@
2
2
 
3
3
  require 'natty-ui'
4
4
 
5
- UI = NattyUI::StdOut
6
-
7
- # helper:
8
- def hex(int) = int.to_s(16).rjust(2, '0')
9
-
10
- UI.space
11
- UI.h1 'NattyUI ANSI Attributes Demo', <<~TEXT
5
+ ui.space
6
+ ui.h1 'NattyUI ANSI Attributes Demo'
7
+ ui.puts <<~TEXT
12
8
 
13
9
  This text contains all supported ANSI attrubtes and explains the available
14
10
  colors.
@@ -19,7 +15,8 @@ UI.h1 'NattyUI ANSI Attributes Demo', <<~TEXT
19
15
 
20
16
  TEXT
21
17
 
22
- UI.h2 'Attributes', <<~TEXT
18
+ ui.h2 'Attributes'
19
+ ui.puts <<~TEXT
23
20
 
24
21
  Some attributes are widely supported, such as [[bold]]bold[[/]], [[italic]]italic[[/]], [[underline]]underline[[/]], [[blink]]blink[[/]],
25
22
  [[invert]]invert[[/]] and [[strike]]strike[[/]], while others are rarely complete or correctly implemented,
@@ -28,138 +25,48 @@ UI.h2 'Attributes', <<~TEXT
28
25
 
29
26
  Different font types are very rarely displayed:
30
27
 
31
- - [[primary_font]]primary_font[[/]]
32
- - [[font1]]font1[[/]]
33
- - [[font2]]font2[[/]]
34
- - [[font3]]font3[[/]]
35
- - [[font4]]font4[[/]]
36
- - [[font5]]font5[[/]]
37
- - [[font6]]font6[[/]]
38
- - [[font7]]font7[[/]]
39
- - [[font8]]font8[[/]]
40
- - [[font9]]font9[[/]]
41
- - [[fraktur]]fraktur[[/]]
28
+ [[primary_font]]primary_font[[/]]
29
+ [[fraktur]]fraktur[[/]]
30
+ [[font1]]font1[[/]] [[font2]]font2[[/]] [[font3]]font3[[/]]
31
+ [[font4]]font4[[/]] [[font5]]font5[[/]] [[font6]]font6[[/]]
32
+ [[font7]]font7[[/]] [[font8]]font8[[/]] [[font9]]font9[[/]]
42
33
 
43
34
  TEXT
44
35
 
45
- UI.h2 '3-bit and 4-bit Colors' do |sec|
46
- sec.space
47
- colors = %w[black red green yellow blue magenta cyan white].freeze
48
- (colors + colors.map { |name| "bright_#{name}" }).each do |name|
49
- sec.puts " [[#{name}]]#{name.ljust(14)}[[/]] [[on_#{name}]]sample text"
50
- end
36
+ ui.h2 '3-bit and 4-bit Colors'
37
+ ui.space
38
+ color = ->(n) { "[[#{n}]]#{n.ljust(14)}[[/]] [[on_#{n}]]sample text[[/]]" }
39
+ %w[black red green yellow blue magenta cyan white].each do |name|
40
+ ui.puts "#{color[name]} #{color["bright_#{name}"]}"
51
41
  end
52
- UI.space
53
-
54
- UI.h2 '8-bit Colors' do |sec|
55
- sec.space
56
- sec.puts 'There are 256 pre-defined color which can be used by their index:'
57
- sec.space
58
-
59
- colors_std = 0.upto(15).map { |i| hex(i) }
60
- colors216 = 16.upto(231).lazy.map { |i| hex(i) }
61
- colors_gray1 = 232.upto(243).map { |i| hex(i) }
62
- colors_gray2 = 244.upto(255).map { |i| hex(i) }
63
-
64
- sec.puts colors_std.map { |i| "[[#{i}]] #{i} [[/]]" }.join
65
- colors216.each_slice(18) do |slice|
66
- sec.puts slice.map { |i| "[[#{i}]] #{i} [[/]]" }.join
67
- end
68
- sec.puts colors_gray1.map { |i| "[[#{i}]] #{i} [[/]]" }.join
69
- sec.puts colors_gray2.map { |i| "[[#{i}]] #{i} [[/]]" }.join
70
-
71
- sec.space
72
- sec.puts colors_std.map { |i| "[[on:#{i}]] #{i} [[/]]" }.join
73
- colors216.each_slice(18) do |slice|
74
- sec.puts slice.map { |i| "[[on:#{i}]] #{i} [[/]]" }.join
75
- end
76
- sec.puts colors_gray1.map { |i| "[[on:#{i}]] #{i} [[/]]" }.join
77
- sec.puts colors_gray2.map { |i| "[[on:#{i}]] #{i} [[/]]" }.join
42
+ ui.space
43
+
44
+ ui.h2 '8-bit Colors'
45
+ ui.space
46
+ ui.puts 'There are 256 pre-defined color which can be used by their index:'
47
+ ui.space
48
+
49
+ color = ->(i) { "[[bg#{i.to_s(16).rjust(2, '0')}]] #{i.to_s.rjust(2)} " }
50
+ ui.msg 'System Colors', glyph: '[[27]]◉' do
51
+ ui.puts "[[#ff]]#{0.upto(7).map(&color).join}"
52
+ ui.puts "[[#00]]#{8.upto(15).map(&color).join}"
53
+ ui.space
78
54
  end
79
55
 
80
- UI.space
81
- UI.h2 '24-bit colors' do |sec|
82
- sec.puts <<~TEXT
83
-
84
- Modern terminal applications support 24-bit colors for foreground and background
85
- RGB-color values. Here are just some samples:
86
-
87
- TEXT
88
-
89
- some_rgb = DATA.readlines(chomp: true).lazy.each_slice(8)
90
-
91
- some_rgb.each do |slice|
92
- sec.puts slice.map { |v| " [[#{v}]]#{v}[[/]] " }.join
56
+ color = ->(i) { "[[bg#{i.to_s(16)}]] #{i.to_s.rjust(3)} " }
57
+ ui.msg '6x6x6 Color Cube', glyph: '[[27]]◉' do
58
+ [16, 22, 28].each do |b|
59
+ b.step(b + 185, by: 36) do |i|
60
+ left = i.upto(i + 5).map(&color).join
61
+ right = (i + 18).upto(i + 23).map(&color).join
62
+ ui.puts "[[#ff]]#{left}[[bg_default]] #{right}"
63
+ end
64
+ ui.space
93
65
  end
94
- sec.space
95
- some_rgb.each do |slice|
96
- sec.puts slice.map { |v| " [[on:#{v}]]#{v}[[/]] " }.join
66
+
67
+ ui.msg 'Grayscale', glyph: '[[27]]◉' do
68
+ ui.puts "[[#ff]]#{232.upto(243).map(&color).join}"
69
+ ui.puts "[[#ff]]#{244.upto(255).map(&color).join}"
70
+ ui.space
97
71
  end
98
72
  end
99
- UI.space
100
-
101
- __END__
102
- #800000
103
- #8b0000
104
- #a52a2a
105
- #b22222
106
- #dc143c
107
- #ff0000
108
- #ff6347
109
- #ff7f50
110
- #cd5c5c
111
- #f08080
112
- #e9967a
113
- #fa8072
114
- #ffa07a
115
- #ff4500
116
- #ff8c00
117
- #ffa500
118
- #ffd700
119
- #b8860b
120
- #daa520
121
- #eee8aa
122
- #bdb76b
123
- #f0e68c
124
- #808000
125
- #ffff00
126
- #9acd32
127
- #556b2f
128
- #6b8e23
129
- #7cfc00
130
- #7fff00
131
- #adff2f
132
- #006400
133
- #008000
134
- #228b22
135
- #00ff00
136
- #32cd32
137
- #90ee90
138
- #98fb98
139
- #8fbc8f
140
- #00fa9a
141
- #00ff7f
142
- #2e8b57
143
- #66cdaa
144
- #3cb371
145
- #20b2aa
146
- #2f4f4f
147
- #008080
148
- #008b8b
149
- #00ffff
150
- #00ffff
151
- #e0ffff
152
- #00ced1
153
- #40e0d0
154
- #48d1cc
155
- #afeeee
156
- #7fffd4
157
- #b0e0e6
158
- #5f9ea0
159
- #4682b4
160
- #6495ed
161
- #00bfff
162
- #1e90ff
163
- #add8e6
164
- #87ceeb
165
- #87cefa
data/examples/demo.rb ADDED
@@ -0,0 +1,217 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'natty-ui'
4
+
5
+ def attributes
6
+ ui.puts <<~TEXT
7
+
8
+ Some attributes are widely supported, such as [[bold]]bold[[/]], [[italic]]italic[[/]], [[underline]]underline[[/]], [[blink]]blink[[/]],
9
+ [[invert]]invert[[/]] and [[strike]]strike[[/]], while others are rarely complete or correctly implemented,
10
+ like [[faint]]faint[[/]], [[rapid_blink]]rapid_blink[[/]], [[double_underline]]double_underline[[/]], [[framed]]framed[[/]], [[encircled]]encircled[[/]], [[overlined]]overlined[[/]],
11
+ [[proportional]]proportional[[/]] and [[spacing]]spacing[[/]].
12
+
13
+ Different font types are very rarely displayed:
14
+
15
+ [[primary_font]]primary_font[[/]]
16
+ [[fraktur]]fraktur[[/]]
17
+ [[font1]]font1[[/]] [[font2]]font2[[/]] [[font3]]font3[[/]]
18
+ [[font4]]font4[[/]] [[font5]]font5[[/]] [[font6]]font6[[/]]
19
+ [[font7]]font7[[/]] [[font8]]font8[[/]] [[font9]]font9[[/]]
20
+
21
+ TEXT
22
+ end
23
+
24
+ def colors_3bit
25
+ color = ->(n) { "[[#{n}]]#{n.ljust(14)}[[/]] [[on_#{n}]]sample text[[/]]" }
26
+ %w[black red green yellow blue magenta cyan white].each do |name|
27
+ ui.puts "#{color[name]} #{color["bright_#{name}"]}"
28
+ end
29
+ end
30
+
31
+ def colors_8bit
32
+ color = ->(i) { "[[bg#{i.to_s(16).rjust(2, '0')}]] #{i.to_s.rjust(2)} " }
33
+ ui.msg 'System Colors', glyph: '[[27]]◉' do
34
+ ui.puts "[[#ff]]#{0.upto(7).map(&color).join}"
35
+ ui.puts "[[#00]]#{8.upto(15).map(&color).join}"
36
+ ui.space
37
+ end
38
+
39
+ color = ->(i) { "[[bg#{i.to_s(16)}]] #{i.to_s.rjust(3)} " }
40
+ ui.msg '6x6x6 Color Cube', glyph: '[[27]]◉' do
41
+ [16, 22, 28].each do |b|
42
+ b.step(b + 185, by: 36) do |i|
43
+ left = i.upto(i + 5).map(&color).join
44
+ right = (i + 18).upto(i + 23).map(&color).join
45
+ ui.puts "[[#ff]]#{left}[[bg_default]] #{right}"
46
+ end
47
+ ui.space
48
+ end
49
+ end
50
+
51
+ ui.msg 'Grayscale', glyph: '[[27]]◉' do
52
+ ui.puts "[[#ff]]#{232.upto(243).map(&color).join}"
53
+ ui.puts "[[#ff]]#{244.upto(255).map(&color).join}"
54
+ ui.space
55
+ end
56
+ end
57
+
58
+ def colors_24bit
59
+ ui.puts <<~TEXT
60
+ Modern terminal applications support 24-bit colors for foreground and background
61
+ RGB-color values. Here are just some samples:
62
+
63
+ TEXT
64
+ RGB_COLORS.each { ui.puts _1.map { |v| " [[#{v}]]#{v}[[/]] " }.join }
65
+ ui.space
66
+ RGB_COLORS.each { ui.puts _1.map { |v| " [[on:#{v}]]#{v}[[/]] " }.join }
67
+ end
68
+
69
+ def sections
70
+ ui.section do
71
+ ui.puts 'Sections can be stacked'
72
+ ui.section do
73
+ ui.puts TEXT_MID
74
+ ui.framed do
75
+ ui.puts TEXT_MID
76
+ next unless block_given?
77
+ ui.space
78
+ ui.hr
79
+ ui.space
80
+ yield
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ def heading
87
+ ui.h1 'This Is A H1 Heading'
88
+ ui.h2 'This Is A H2 Heading'
89
+ ui.h3 'This Is A H3 Heading'
90
+ ui.h4 'This Is A H4 Heading'
91
+ ui.h5 'This Is A H5 Heading'
92
+ end
93
+
94
+ def messages
95
+ ui.info 'Informative Message', TEXT_MID
96
+ ui.warning 'Warning Message', TEXT_MID
97
+ ui.error 'Error Message', TEXT_MID
98
+ ui.message '[[italic #fad]]Custom Message', TEXT_MID, glyph: '💡'
99
+ ui.failed 'Fail Message', TEXT_MID
100
+ end
101
+
102
+ def list_in_columns
103
+ ui.ls TEXT_LINES
104
+ ui.hr
105
+ ui.ls TEXT_LINES, compact: false
106
+ end
107
+
108
+ def tasks
109
+ ui.task('Initialize') { something }
110
+ ui.task('Establish server connection') do
111
+ ui.task('Open connection') { something }
112
+ ui.task('Send HELO') { something }
113
+ ui.task('Receive OLEH') { something }
114
+ ui.task('Send credentials') { something }
115
+ ui.task('Credentials accepted') { something }
116
+ end
117
+ ui.task 'Loading files' do
118
+ %w[readme.txt main.css main.html sub.html].each do |name|
119
+ ui.msg "Load file [[bright_yellow]]./source/#{name}[[/]]..."
120
+ something
121
+ end
122
+ ui.done 'Files loaded'
123
+ end
124
+ progress = ui.progress('Compress files', max_value: 11)
125
+ 11.times do
126
+ progress.step
127
+ something
128
+ end
129
+ progress.done 'All compressed'
130
+ end
131
+
132
+ def table
133
+ ui.table { |tab| TEXT.each_line(chomp: true).each_slice(5) { tab.add(*_1) } }
134
+ end
135
+
136
+ # just simulate some work
137
+ def something = sleep(0.5)
138
+ def some = sleep(0.15)
139
+
140
+ TEXT = <<~LOREM
141
+ Lorem [[yellow]]ipsum[[/]] dolor sit
142
+ amet, consectetur adipisicing
143
+ elit, sed do eiusmod tempor
144
+ incididunt ut labore et
145
+ dolore [[red]]magna[[/]] aliqua. Ut
146
+ enim ad minim veniam, quis
147
+ nostrud exercitation ullamco
148
+ laboris nisi ut aliquip ex
149
+ ea commodo [[bold]]consequat[[/]]. Duis
150
+ aute irure [[bold green]]dolor[[/]] in
151
+ reprehenderit in voluptate
152
+ velit [[underline]]esse cillum[[/]] dolore eu
153
+ fugiat nulla pariatur.
154
+ Excepteur sint occaecat
155
+ cupidatat non proident,
156
+ sunt in culpa qui officia
157
+ deserunt mollit anim id
158
+ est laborum.
159
+ LOREM
160
+ TEXT_LINES = TEXT.lines(chomp: true)
161
+ TEXT_MID = TEXT_LINES.take(8).join(' ')
162
+ TEXT_BIG = TEXT_LINES.join(' ')
163
+ RGB_COLORS = <<~RGB_COLORS.lines(chomp: true).map!(&:split)
164
+ #800000 #8b0000 #a52a2a #b22222 #dc143c #ff0000 #ff6347 #ff7f50
165
+ #cd5c5c #f08080 #e9967a #fa8072 #ffa07a #ff4500 #ff8c00 #ffa500
166
+ #ffd700 #b8860b #daa520 #eee8aa #bdb76b #f0e68c #808000 #ffff00
167
+ #9acd32 #556b2f #6b8e23 #7cfc00 #7fff00 #adff2f #006400 #008000
168
+ #228b22 #00ff00 #32cd32 #90ee90 #98fb98 #8fbc8f #00fa9a #00ff7f
169
+ #2e8b57 #66cdaa #3cb371 #20b2aa #2f4f4f #008080 #008b8b #00ffff
170
+ #00ffff #e0ffff #00ced1 #40e0d0 #48d1cc #afeeee #7fffd4 #b0e0e6
171
+ #5f9ea0 #4682b4 #6495ed #00bfff #1e90ff #add8e6 #87ceeb #87cefa
172
+ RGB_COLORS
173
+
174
+ ui.page do
175
+ ui.h1 'NattyUI Demo'
176
+ loop do
177
+ ui.space
178
+ choice, title =
179
+ ui.query(
180
+ 'Which Demo part do you like to see?',
181
+ :a => 'Attributes',
182
+ '3' => '3-bit and 4-bit Colors',
183
+ '8' => '8-bit Colors',
184
+ '2' => '24-bit colors',
185
+ 'l' => 'List in Columns',
186
+ 's' => 'Sections',
187
+ 'S' => 'Sections with lists',
188
+ 'z' => 'Sections with table',
189
+ 't' => 'Tasks',
190
+ :q => 'Quit Demo',
191
+ :result => :all,
192
+ :display => :compact
193
+ )
194
+ break if choice.nil? || choice == 'q'
195
+ ui.cls.h2(title).space
196
+ case choice
197
+ when 'a'
198
+ attributes
199
+ when '3'
200
+ colors_3bit
201
+ when '8'
202
+ colors_8bit
203
+ when '2'
204
+ colors_24bit
205
+ when 't'
206
+ tasks
207
+ when 'l'
208
+ list_in_columns
209
+ when 's'
210
+ sections { messages }
211
+ when 'S'
212
+ sections { list_in_columns }
213
+ when 'z'
214
+ sections { table }
215
+ end
216
+ end
217
+ end
Binary file
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'natty-ui'
4
+
5
+ ui.space
6
+ ui.msg('Natty UI', glyph: '⭐️') { ui.puts <<~TEXT }
7
+ This is the [[c4]]beautiful[[/]], [[c5]]nice[[/]], [[c6]]nifty[[/]], [[c7]]fancy[[/]], [[c8]]neat[[/]], [[c9]]pretty[[/]], [[ca]]cool[[/]],
8
+ [[cb]]lovely[[/]], [[cc]]natty[[/]] [[bold]]user interface[[/]] you like to have for your command
9
+ line applications. It contains [[italic]]elegant[[/]], [[italic]]simple[[/]] and [[italic]]beautiful[[/]]
10
+ tools that enhance your command line interfaces functionally and
11
+ aesthetically.
12
+ TEXT
13
+ ui.msg('Features', glyph: '⭐️') { ui.ls(<<~FEATURES.lines(chomp: true)) }
14
+ [[bold red]]T[[/]] text attributes
15
+ 🌈 text coloring
16
+ 🎩 heading elements
17
+ 📏 horizontal rulers
18
+ 📝 message blocks
19
+ ✅ task blocks
20
+ [[bold blue]]""[[/]] quote blocks
21
+ 🖼️ framed blocks
22
+ [[yellow]]┼┼[[/]] tables
23
+ 💯 progress bars
24
+ [[bold red]]?[[/]] ask question
25
+ [[bold bright_white]]>[[bright_red]]_[[/]] user input
26
+ FEATURES