natty-ui 0.12.0 → 0.25.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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +23 -24
  4. data/examples/24bit-colors.rb +4 -9
  5. data/examples/3bit-colors.rb +28 -8
  6. data/examples/8bit-colors.rb +18 -23
  7. data/examples/attributes.rb +30 -25
  8. data/examples/cols.rb +40 -0
  9. data/examples/elements.rb +31 -0
  10. data/examples/examples.rb +45 -0
  11. data/examples/illustration.rb +56 -54
  12. data/examples/ls.rb +16 -18
  13. data/examples/named-colors.rb +23 -0
  14. data/examples/sections.rb +29 -0
  15. data/examples/tables.rb +62 -0
  16. data/examples/tasks.rb +52 -0
  17. data/lib/natty-ui/attributes.rb +604 -0
  18. data/lib/natty-ui/choice.rb +56 -0
  19. data/lib/natty-ui/dumb_choice.rb +45 -0
  20. data/lib/natty-ui/element.rb +78 -0
  21. data/lib/natty-ui/features.rb +798 -0
  22. data/lib/natty-ui/framed.rb +51 -0
  23. data/lib/natty-ui/ls_renderer.rb +93 -0
  24. data/lib/natty-ui/progress.rb +187 -0
  25. data/lib/natty-ui/section.rb +69 -0
  26. data/lib/natty-ui/table.rb +241 -0
  27. data/lib/natty-ui/table_renderer.rb +147 -0
  28. data/lib/natty-ui/task.rb +44 -0
  29. data/lib/natty-ui/temporary.rb +38 -0
  30. data/lib/natty-ui/theme.rb +303 -0
  31. data/lib/natty-ui/utils.rb +79 -0
  32. data/lib/natty-ui/version.rb +1 -1
  33. data/lib/natty-ui/width_finder.rb +125 -0
  34. data/lib/natty-ui.rb +89 -147
  35. metadata +47 -56
  36. data/examples/animate.rb +0 -44
  37. data/examples/attributes_list.rb +0 -14
  38. data/examples/demo.rb +0 -53
  39. data/examples/message.rb +0 -32
  40. data/examples/progress.rb +0 -68
  41. data/examples/query.rb +0 -41
  42. data/examples/read_key.rb +0 -13
  43. data/examples/table.rb +0 -41
  44. data/lib/natty-ui/animation/binary.rb +0 -36
  45. data/lib/natty-ui/animation/default.rb +0 -38
  46. data/lib/natty-ui/animation/matrix.rb +0 -51
  47. data/lib/natty-ui/animation/rainbow.rb +0 -28
  48. data/lib/natty-ui/animation/type_writer.rb +0 -44
  49. data/lib/natty-ui/animation.rb +0 -69
  50. data/lib/natty-ui/ansi/constants.rb +0 -75
  51. data/lib/natty-ui/ansi.rb +0 -521
  52. data/lib/natty-ui/ansi_wrapper.rb +0 -199
  53. data/lib/natty-ui/frame.rb +0 -53
  54. data/lib/natty-ui/glyph.rb +0 -64
  55. data/lib/natty-ui/key_map.rb +0 -142
  56. data/lib/natty-ui/preload.rb +0 -12
  57. data/lib/natty-ui/spinner.rb +0 -120
  58. data/lib/natty-ui/text/east_asian_width.rb +0 -2529
  59. data/lib/natty-ui/text.rb +0 -203
  60. data/lib/natty-ui/wrapper/animate.rb +0 -17
  61. data/lib/natty-ui/wrapper/ask.rb +0 -78
  62. data/lib/natty-ui/wrapper/element.rb +0 -79
  63. data/lib/natty-ui/wrapper/features.rb +0 -21
  64. data/lib/natty-ui/wrapper/framed.rb +0 -45
  65. data/lib/natty-ui/wrapper/heading.rb +0 -60
  66. data/lib/natty-ui/wrapper/horizontal_rule.rb +0 -37
  67. data/lib/natty-ui/wrapper/list_in_columns.rb +0 -138
  68. data/lib/natty-ui/wrapper/message.rb +0 -109
  69. data/lib/natty-ui/wrapper/mixins.rb +0 -67
  70. data/lib/natty-ui/wrapper/progress.rb +0 -74
  71. data/lib/natty-ui/wrapper/query.rb +0 -89
  72. data/lib/natty-ui/wrapper/quote.rb +0 -25
  73. data/lib/natty-ui/wrapper/request.rb +0 -54
  74. data/lib/natty-ui/wrapper/section.rb +0 -118
  75. data/lib/natty-ui/wrapper/table.rb +0 -551
  76. data/lib/natty-ui/wrapper/task.rb +0 -55
  77. data/lib/natty-ui/wrapper.rb +0 -230
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0aa357f7937c367ecc77396e7241f33a774973d773b99c6923cc975199755a14
4
- data.tar.gz: '060778aaca552a23c57e39e4efd8adf3eff07658e6a712708b6c8e46c5077bc1'
3
+ metadata.gz: 23eed1ba95aaecb2555dfeed5a6fedbcd827299d1e4a64c91952953b3d36d787
4
+ data.tar.gz: 53380e5ebe647a96abbc24baecd1f24a7a3290544ac10e34e3aa8b1e8dba1e17
5
5
  SHA512:
6
- metadata.gz: c79a14e0f8b02181a19268958c8784e306f66853e0e09f40ae630043a3f89b699aaaaee72622d06fff43df0eab9814908b5d692f748df0c7ff5f67d4cac1b460
7
- data.tar.gz: 7b27b83b5592b3ec556e640d7d583983ec42615ac036c40a0f5b2a305616e3df846f292aae191952e312aeaf6d9e4be99ab84ed123c1853acbf055c515b9335f
6
+ metadata.gz: 56c829ee249c7cecce24bb9b88c131e8fdaaec20aff2f0340b16d701c77907805f7595d38cfe0e122d4f7365d6ae6babfccdd680b9754de283c7e63c944e78ea
7
+ data.tar.gz: 9964afa255fe3a76d59727f13edcafa31429768729e3b14408f6142f6af17236c7831836857897a0e860044732ad5a347c6bc4efb06ef277412d73d67167519d
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  BSD 3-Clause License
2
2
 
3
- Copyright (c) 2017-2021, Mike Blumtritt. All rights reserved.
3
+ Copyright (c) 2017-2025, Mike Blumtritt. All rights reserved.
4
4
 
5
5
  Redistribution and use in source and binary forms, with or without
6
6
  modification, are permitted provided that the following conditions are met:
data/README.md CHANGED
@@ -1,30 +1,29 @@
1
- # NattyUI ![version](https://img.shields.io/gem/v/natty-ui?label=)
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 applications. It contains elegant, simple and beautiful tools that enhance your command line interfaces functionally and aesthetically.
3
+ This is the beautiful, nice, nifty, fancy, neat, pretty, cool, rich, 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)
7
7
  - Help: [rubydoc.info](https://rubydoc.info/gems/natty-ui/NattyUI)
8
8
 
9
- ## Description
10
-
11
- Here you find elegant, simple and beautiful tools that enhance your command line application functionally and look.
12
-
13
- You can style your text using a [BBCode](https://en.wikipedia.org/wiki/BBCode)-like syntax
14
-
15
- ```ruby
16
- ui.puts '[bold underline bright_white]Hello [ff7bfd]World!'
17
- ```
18
-
19
- which supports all ANSI attributes, colors in 3/4-bit, 8-bit and Truecolor. There are headers, rulers, diverse message types, framed blocks and tables to layout your text. You can organize the output of tasks, use progress bars and request and handle user input. And there are text animations for fame and fun!
20
-
21
- 🚀 Have a look at the [features](https://rubydoc.info/gems/natty-ui/NattyUI/Features) or check the code [examples](./examples/)!
22
-
23
- ![illustration](https://raw.githubusercontent.com/mblumtritt/natty-ui/main/examples/illustration.png)
24
-
25
- ## NO_COLOR Convention
26
-
27
- NattyUI follows the [NO_COLOR convention](https://no-color.org).
9
+ ## Features
10
+
11
+ ![illustration](./examples/illustration.png)
12
+
13
+ - automatic line break of all text output
14
+ - markup of text attributes and colors using a [BBCode](https://en.wikipedia.org/wiki/BBCode) like syntax
15
+ - automatic detection if ANSI is available
16
+ - support of [NO_COLOR convention](https://no-color.org)
17
+ - support of [CSIu input protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol)
18
+ - headings
19
+ - text separators
20
+ - lists
21
+ - various types of text blocks with automatic alignment
22
+ - text columns
23
+ - tables
24
+ - task lists
25
+ - progress indicators
26
+ - and more!
28
27
 
29
28
  ## Help
30
29
 
@@ -32,16 +31,16 @@ NattyUI follows the [NO_COLOR convention](https://no-color.org).
32
31
 
33
32
  ### Run Examples
34
33
 
35
- You can execute the examples by
34
+ You can execute all examples by
36
35
 
37
36
  ```sh
38
- ruby ./examples/demo.rb
37
+ ruby ./examples/examples.rb
39
38
  ```
40
39
 
41
40
  or see the non-ANSI version
42
41
 
43
42
  ```sh
44
- NO_COLOR=1 ruby ./examples/demo.rb
43
+ NO_COLOR=1 ruby ./examples/examples.rb
45
44
  ```
46
45
 
47
46
  ## Installation
@@ -2,18 +2,13 @@
2
2
 
3
3
  require_relative '../lib/natty-ui'
4
4
 
5
- ui.space
6
- ui.h1 'NattyUI: 24-bit Color Support'
7
- ui.space
8
-
9
- ui.section do
10
- bar = '█' * ui.available_width
5
+ ui.message '[b]​ᓚᕠᗢ NattyUI[/b] [i green]24-bit Color Support[/]' do
6
+ ui.space
7
+ bar = '█' * ui.columns
11
8
  rainbow =
12
9
  (7..17).map do |i|
13
- NattyUI::Ansi.rainbow(bar, seed: 3, spread: 3.25, frequence: i / 100.0)
10
+ NattyUI::Ansi.rainbow(bar, seed: 3, spread: 3.25, frequency: i / 100.0)
14
11
  end
15
12
 
16
13
  ui.puts(*rainbow)
17
14
  end
18
-
19
- ui.space
@@ -2,13 +2,33 @@
2
2
 
3
3
  require_relative '../lib/natty-ui'
4
4
 
5
- ui.space
6
- ui.h1 'NattyUI: 3/4-bit Color Support'
7
- ui.space
5
+ ui.message '[b]​ᓚᕠᗢ NattyUI[/b] [i green]3/4bit Color Support[/]' do
6
+ ui.space
7
+ ui.puts <<~INFO, ignore_newline: true
8
+ Terminals may support colors. You can colorize foreground text and
9
+ background. The very basic color palette consists of eight colors and may
10
+ be extended with eight colors which are much brighter.
11
+ INFO
8
12
 
9
- color = ->(n, j) { "[#{n}]#{n.ljust(j)}[/] [on_#{n}] sample text [/]" }
10
- %w[black red green yellow blue magenta cyan white].each do |name|
11
- ui.puts "#{color[name, 7]} #{color["bright_#{name}", 14]}"
13
+ ui.space
14
+ ui.ls(
15
+ %w[
16
+ black
17
+ red
18
+ green
19
+ yellow
20
+ blue
21
+ magenta
22
+ cyan
23
+ white
24
+ bright_black
25
+ bright_red
26
+ bright_green
27
+ bright_yellow
28
+ bright_blue
29
+ bright_magenta
30
+ bright_cyan
31
+ bright_white
32
+ ].map { |name| "[bg_#{name}]  [/bg] [#{name}]#{name}[/fg]" }
33
+ )
12
34
  end
13
-
14
- ui.space
@@ -2,34 +2,29 @@
2
2
 
3
3
  require_relative '../lib/natty-ui'
4
4
 
5
- ui.space
6
- ui.h1 'NattyUI: 8-bit Color Support'
7
- ui.space
5
+ ui.message '[b]​ᓚᕠᗢ NattyUI[/b] [i green]8bit Color Support[/]' do
6
+ color = ->(i) { "[bg#{i = i.to_s(16).rjust(2, '0')}] #{i} " }
8
7
 
9
- color = ->(i) { "[bg#{i = i.to_s(16).rjust(2, '0')}] #{i} " }
10
- ui.msg 'System Colors' do
11
- ui.puts <<~COLORS
8
+ ui.space
9
+ ui.message('System Colors', <<~COLORS.chomp)
12
10
  [#ff]#{0.upto(7).map(&color).join}
13
11
  [#00]#{8.upto(15).map(&color).join}
14
-
15
12
  COLORS
16
- end
17
13
 
18
- ui.msg '6x6x6 Color Cube' do
19
- [16, 22, 28].each do |b|
20
- b.step(b + 185, by: 36) do |i|
21
- left = i.upto(i + 5).map(&color).join
22
- right = (i + 18).upto(i + 23).map(&color).join
23
- ui.puts "[#ff]#{left}[bg_default] #{right}"
14
+ ui.space
15
+ ui.message('Grayscale', <<~GRAYSCALE.chomp)
16
+ [#ff]#{0xe8.upto(0xf3).map(&color).join}
17
+ [#ff]#{0xf4.upto(0xff).map(&color).join}
18
+ GRAYSCALE
19
+
20
+ ui.space
21
+ ui.message '6x6x6 Color Cube' do
22
+ [16, 22, 28].each do |b|
23
+ b.step(b + 185, by: 36) do |i|
24
+ left = i.upto(i + 5).map(&color).join
25
+ right = (i + 18).upto(i + 23).map(&color).join
26
+ ui.puts "[#ff]#{left}[bg_default]#{right}"
27
+ end
24
28
  end
25
- ui.space
26
29
  end
27
30
  end
28
-
29
- ui.msg 'Grayscale' do
30
- ui.puts <<~GRAYSCALE
31
- [#ff]#{232.upto(243).map(&color).join}
32
- [#ff]#{244.upto(255).map(&color).join}
33
-
34
- GRAYSCALE
35
- end
@@ -2,28 +2,33 @@
2
2
 
3
3
  require_relative '../lib/natty-ui'
4
4
 
5
- ui.space
6
- ui.h2 'NattyUI: ANSI Attributes'
7
- ui.space
8
-
9
- ui.puts <<~PARA1.tr("\n", ' ')
10
- Some attributes are widely supported, such as [b]bold[/b],
11
- [i]italic[/i], [u]underline[/u], [blink]blink[/blink],
12
- [invert]invert[/invert] and [strike]strike[/strike], while others are rarely
13
- complete or correctly implemented, like [faint]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
-
21
- ui.puts <<~PARA2.tr("\n", ' ')
22
- Alternative fonts are mostly completely ignored:
23
- [primary_font]primary_font[/], [fraktur]fraktur[/],
24
- [font1]font1[/], [font2]font2[/], [font3]font3[/],
25
- [font4]font4[/], [font5]font5[/], [font6]font6[/],
26
- [font7]font7[/], [font8]font8[/], [font9]font9[/].
27
- PARA2
28
-
29
- ui.space
5
+ ui.message '[b]​ᓚᕠᗢ NattyUI[/b] [i green]ANSI Attributes[/]' do
6
+ ui.space
7
+ ui.puts <<~INFO_1, <<~INFO_2, ignore_newline: true
8
+ NattyUI supports all well known attributes like
9
+ [b]bold[/b],
10
+ [i]italic[/i],
11
+ [u]underline[/u],
12
+ [blink]blink[/blink],
13
+ [inv]invert[/inv]
14
+ and [strike]strike[/strike].
15
+ Other attributes like
16
+ [faint]faint[/faint],
17
+ [double_underline]double underline[/],
18
+ [curly_underline]curly underline[/],
19
+ [dotted_underline]dotted underline[/],
20
+ [dashed_underline]dashed underline[/],
21
+ [rapid_blink]rapid_blink[/],
22
+ [framed]framed[/],
23
+ [encircled]encircled[/],
24
+ [overlined]overlined[/]
25
+ and [proportional]proportional[/]
26
+ are not widely used but also supported.
27
+ INFO_1
28
+ Alternative fonts are mostly completely ignored:
29
+ [primary_font]primary_font[/], [fraktur]fraktur[/],
30
+ [font1]font1[/], [font2]font2[/], [font3]font3[/],
31
+ [font4]font4[/], [font5]font5[/], [font6]font6[/],
32
+ [font7]font7[/], [font8]font8[/], [font9]font9[/].
33
+ INFO_2
34
+ end
data/examples/cols.rb ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/natty-ui'
4
+
5
+ ui.message '[b]​ᓚᕠᗢ NattyUI[/b] [i green]Print Columns[/]' do
6
+ ui.space
7
+ ui.cols(
8
+ 'Here we',
9
+ 'have some',
10
+ 'columns',
11
+ 'which are',
12
+ 'arranged',
13
+ 'and centered',
14
+ align: :centered,
15
+ border: :default
16
+ )
17
+
18
+ ui.space
19
+ ui.cols do |cc|
20
+ cc.add(
21
+ "This is a left aligned blue column with some text but also with with\n" \
22
+ 'a forced line break.',
23
+ style: 'bright_white on_blue',
24
+ align: :left
25
+ )
26
+ cc.add(
27
+ 'This is the middle red column.',
28
+ style: 'bright_white on_red',
29
+ align: :centered,
30
+ vertical: :middle
31
+ )
32
+ cc.add(
33
+ 'This is a right aligned blue column vertically bottom aligned.',
34
+ style: 'bright_white on_blue',
35
+ align: :right,
36
+ vertical: :bottom
37
+ )
38
+ cc.padding = [1, 2]
39
+ end
40
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/natty-ui'
4
+
5
+ ui.message '[b]​ᓚᕠᗢ NattyUI[/b] [i green]Simple Elements[/]' do
6
+ ui.space
7
+ ui.h1('This is a [b]H1[/b] heading element')
8
+
9
+ ui.space
10
+ ui.h2('This is a [b]H2[/b] heading element')
11
+
12
+ ui.space
13
+ ui.quote "This is a\nmulti-line quotation"
14
+
15
+ ui.space
16
+ ui.h3('This is a [b]H3[/b] heading element')
17
+ ui.mark(
18
+ 'This is a multi-line message',
19
+ 'with a leading checkmark.',
20
+ mark: :checkmark
21
+ )
22
+
23
+ ui.space
24
+ ui.h4('This is a [b]H4[/b] heading element')
25
+
26
+ ui.space
27
+ ui.h5('This is a [b]H5[/b] heading element')
28
+
29
+ ui.space
30
+ ui.h6('This is a [b]H6[/b] heading element')
31
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/natty-ui'
4
+
5
+ EXAMPLES = {
6
+ 'attributes' => 'ANSI Attributes',
7
+ '3bit-colors' => '3/4bit Color Support',
8
+ '8bit-colors' => '8bit Color Support',
9
+ '24bit-colors' => '24bit Color Support',
10
+ 'named-colors' => 'Named Colors Support',
11
+ 'elements' => 'Simple Elements',
12
+ 'ls' => 'Print Lists',
13
+ 'tables' => 'Print Tables',
14
+ 'cols' => 'Print Columns',
15
+ 'sections' => 'Sections',
16
+ 'tasks' => 'Tasks'
17
+ }.freeze
18
+
19
+ DEFAULT_MODE = NattyUI.input_mode == :default
20
+
21
+ ui.space
22
+
23
+ while true
24
+ selected =
25
+ ui.choice(**EXAMPLES, abortable: true) do
26
+ ui.cols(
27
+ "[red] /\\_/\\\n( o.o )\n > ^ <",
28
+ '[bright_green b]Select a natty example:',
29
+ width: 8
30
+ )
31
+ ui.div('[faint](Abort with [\\ESC])', padding: [1, 0, 1])
32
+ end
33
+
34
+ ui.space unless DEFAULT_MODE
35
+ break unless selected
36
+
37
+ ui.temporary do
38
+ load("#{__dir__}/#{selected}.rb")
39
+ if DEFAULT_MODE
40
+ ui.await { ui.puts '[faint][\\Press ENTER to continue...]' }
41
+ else
42
+ ui.space
43
+ end
44
+ end
45
+ end
@@ -2,58 +2,60 @@
2
2
 
3
3
  require_relative '../lib/natty-ui'
4
4
 
5
- ui.space
6
-
7
- ui.table(type: :undecorated) do |table|
8
- table.add(
9
- 'Styles',
10
- "Support of all ANSI styles like #{
11
- %w[
12
- bold
13
- italic
14
- underline
15
- invert
16
- strike
17
- faint
18
- double_underline
19
- curly_underline
20
- dotted_underline
21
- dashed_underline
22
- blink
23
- ].map { "[#{_1}]#{_1.tr('_', ' ')}[/]" }.join(', ')
24
- }, and even rarely supported like [fraktur]fraktur[/fraktur]."
25
- )
26
-
27
- table.add('Colors', <<~TEXT)
28
- ✓ [green]3/4-bit color[/] ✓ [ff7f50]Truecolor (16.7 million)
29
- ✓ [1b]8-bit color[/] ✓ [bright_yellow]Dumb terminals
30
- ✓ [bright_blue]NO_COLOR convention
31
- TEXT
32
-
33
- table.add(
34
- 'Markup',
35
- '[0c]You can style your text using a [i]BBCode[/i]-like syntax.'
36
- )
37
-
38
- table.add('Layout', <<~TEXT)
39
- 🎩 heading elements 📏 horizontal rulers
40
- 📝 messages [yellow]🄵[/] framed blocks
41
- [blue]┼┼[/] tables
42
- TEXT
43
-
44
- table.add('Tools', <<~TEXT)
45
- ✅ tasks [bold green]…[/] progress bars
46
- [bold bright_white]>[bright_red]_[/] user input 🔦 text animation
47
- TEXT
48
-
49
- table.add("Asian\nlanguage\nsupport", <<~TEXT)
50
- [0a]🇨🇳 该库支持中文,日文和韩文文本!
51
- [0a]🇯🇵 ライブラリは中国語、日本語、韓国語のテキストをサポートしています
52
- [0a]🇰🇷 이 라이브러리는 중국어, 일본어 및 한국어 텍스트를 지원합니다
53
- TEXT
54
-
55
- table.align_column(0, :center)
56
- table.style_column(0, :red)
5
+ ui.message '[b]​ᓚᕠᗢ NattyUI[/b]' do
6
+ ui.table(border: :defaulth, border_style: 'bright_blue') do |table|
7
+ table.add do |row|
8
+ row.add 'Styles'
9
+ row.add <<~TEXT.tr("\n", ' ')
10
+ Support of all ANSI styles like
11
+ [bold]bold[/bold],
12
+ [italic]italic[/italic],
13
+ [underline]underline[/underline],
14
+ [invert]invert[/invert],
15
+ [strike]strike[/strike],
16
+ [faint]faint[/faint],
17
+ [double_underline]double underline[/double_underline],
18
+ [curly_underline]curly underline[/curly_underline],
19
+ [dotted_underline]dotted underline[/dotted_underline],
20
+ [dashed_underline]dashed underline[/dashed_underline]
21
+ and even rarely supported like [fraktur]fraktur[/fraktur].
22
+ TEXT
23
+ end
24
+
25
+ table.add do |row|
26
+ row.add 'Colors'
27
+ row.add <<~TEXT.chomp
28
+ ✓ [palegreen]3/4-bit color[/fg]         ✓ [ff7f50]Truecolor (16.7 million)
29
+ ✓ [skyblue]8-bit color[/fg]           ✓ [gold]Dumb terminals
30
+ ✓ [tan1]NO_COLOR convention
31
+ TEXT
32
+ end
33
+
34
+ table.add do |row|
35
+ row.add 'Markup'
36
+ row.add '[0c]You can style your text using a [i]BBCode[/i]-like syntax.'
37
+ end
38
+
39
+ table.add do |row|
40
+ row.add 'Layout'
41
+ row.add <<~TEXT.chomp
42
+ 🎩 heading elements     📝 messages
43
+ 📏 horizontal rulers    [blue]┼┼[/] tables
44
+ 📋 lists                [b green]✓✓[/] tasks
45
+ TEXT
46
+ end
47
+
48
+ table.add do |row|
49
+ row.add 'Asian', 'language', 'support'
50
+ row.add <<~TEXT.chomp
51
+ [bright_green]🇨🇳 该库支持中文,日文和韩文文本!
52
+ [bright_green]🇯🇵 ライブラリは中国語、日本語、韓国語のテキストをサポートしています
53
+ [bright_green]🇰🇷 이 라이브러리는 중국어, 일본어 및 한국어 텍스트를 지원합니다
54
+ TEXT
55
+ end
56
+
57
+ table.columns[0].style = 'bold red'
58
+ table.columns[0].width = 10
59
+ table.columns[1].padding_right = 2
60
+ end
57
61
  end
58
-
59
- ui.space
data/examples/ls.rb CHANGED
@@ -2,21 +2,17 @@
2
2
 
3
3
  require_relative '../lib/natty-ui'
4
4
 
5
- ui.space
6
- ui.h1 'NattyUI: Print In Columns'
7
- ui.space
8
-
9
- LOREM = <<~IPSUM.lines(chomp: true)
10
- Lorem ipsum dolor sit
11
- amet, consectetur adipisicing
12
- elit, sed do eiusmod tempor
5
+ lorem = <<~IPSUM.lines(chomp: true)
6
+ Lorem ipsum dolor sit amet,
7
+ consectetur adipisicing elit,
8
+ sed do eiusmod tempor
13
9
  incididunt ut labore et
14
- dolore [red]magna[/] aliqua. Ut
15
- enim ad minim veniam, quis
10
+ dolore [red]magna[/] aliqua.
11
+ Ut enim ad minim veniam, quis
16
12
  nostrud exercitation ullamco
17
13
  laboris nisi ut aliquip ex
18
- ea commodo [b]consequat[/b]. Duis
19
- aute irure [bold green]dolor[/fg] in[/]
14
+ ea commodo [b]consequat[/b].
15
+ Duis aute irure [bold green]dolor[/fg] in[/]
20
16
  reprehenderit in voluptate
21
17
  velit [underline]esse cillum[/] dolore eu
22
18
  fugiat nulla pariatur.
@@ -27,10 +23,12 @@ LOREM = <<~IPSUM.lines(chomp: true)
27
23
  est laborum.
28
24
  IPSUM
29
25
 
30
- ui.h2 'Compact Display'
31
- ui.ls LOREM, glyph: 1
32
- ui.space
26
+ ui.message '[b]​ᓚᕠᗢ NattyUI[/b] [i green]Print Lists[/]' do
27
+ ui.space
28
+ ui.h2 'Traditional Display'
29
+ ui.ls lorem, glyph: 1, compact: false
33
30
 
34
- ui.h2 'Traditional Display'
35
- ui.ls LOREM, glyph: 1, compact: false
36
- ui.space
31
+ ui.space
32
+ ui.h2 'Compact Display'
33
+ ui.ls lorem, glyph: 1
34
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/natty-ui'
4
+
5
+ ui.message '[b]​ᓚᕠᗢ NattyUI[/b] [i green]Named Colors Support[/]' do
6
+ ui.puts <<~INFO
7
+
8
+ NattyUI supports a series of named color values, such as those supported by Kitty.
9
+
10
+ INFO
11
+
12
+ ui.information('Note') do
13
+ ui.puts('Not all terminal emulators support true-colors.')
14
+ end
15
+
16
+ ui.space
17
+ ui.ls(
18
+ NattyUI::Ansi
19
+ .named_colors
20
+ .delete_if { /\d/.match?(_1) }
21
+ .map! { "[bg_#{_1}] [/bg] [#{_1}]#{_1.to_s.ljust(22)}[/fg]" }
22
+ )
23
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/natty-ui'
4
+
5
+ ui.message '[b]​ᓚᕠᗢ NattyUI[/b] [i green]Sections[/]' do
6
+ ui.space
7
+ ui.information 'Informative Message' do
8
+ ui.puts <<~TEXT, ignore_newline: true
9
+ Sections and messages are elements which support any other feature. This
10
+ means they may contain text, other sections, titles, horizontal rules,
11
+ lists, progress bars and much more!
12
+ TEXT
13
+ end
14
+
15
+ ui.space
16
+ ui.warning 'Warning', 'This is a warning message example.'
17
+
18
+ ui.space
19
+ ui.error 'Error Message' do
20
+ ui.space
21
+ ui.cols do |cc|
22
+ cc.add "()-()\n \\\"/\n  `", width: 6, style: :yellow
23
+ cc.add 'You can add all other elements to a section.', vertical: :middle
24
+ end
25
+ end
26
+
27
+ ui.space
28
+ ui.failed "Fail Message\nA sad failure message."
29
+ end