natty-ui 0.35.0 → 1.0.2
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/README.md +6 -6
- data/examples/24bit-colors.rb +9 -5
- data/examples/3bit-colors.rb +7 -7
- data/examples/8bit-colors.rb +5 -7
- data/examples/attributes.rb +2 -3
- data/examples/elements.rb +9 -6
- data/examples/examples.rb +9 -9
- data/examples/frames.rb +31 -0
- data/examples/hbars.rb +6 -3
- data/examples/info.rb +13 -10
- data/examples/key-codes.rb +8 -9
- data/examples/ls.rb +24 -22
- data/examples/named-colors.rb +4 -3
- data/examples/sections.rb +26 -24
- data/examples/select.rb +28 -0
- data/examples/sh.rb +25 -7
- data/examples/tables.rb +19 -37
- data/examples/tasks.rb +32 -22
- data/examples/vbars.rb +5 -3
- data/lib/natty-ui/dumb_progress.rb +68 -0
- data/lib/natty-ui/element.rb +61 -70
- data/lib/natty-ui/features.rb +771 -949
- data/lib/natty-ui/frame.rb +87 -0
- data/lib/natty-ui/helper/table.rb +1376 -0
- data/lib/natty-ui/margin.rb +83 -0
- data/lib/natty-ui/progress.rb +116 -152
- data/lib/natty-ui/renderer/bars.rb +93 -0
- data/lib/natty-ui/renderer/choice.rb +56 -0
- data/lib/natty-ui/renderer/dumb_choice.rb +34 -0
- data/lib/natty-ui/renderer/dumb_select.rb +60 -0
- data/lib/natty-ui/renderer/dumb_shell_runner.rb +19 -0
- data/lib/natty-ui/renderer/heading.rb +26 -0
- data/lib/natty-ui/renderer/horizontal_rule.rb +32 -0
- data/lib/natty-ui/{ls_renderer.rb → renderer/ls.rb} +15 -27
- data/lib/natty-ui/renderer/mark.rb +13 -0
- data/lib/natty-ui/renderer/quote.rb +13 -0
- data/lib/natty-ui/renderer/select.rb +63 -0
- data/lib/natty-ui/renderer/shell.rb +15 -0
- data/lib/natty-ui/renderer/shell_runner.rb +29 -0
- data/lib/natty-ui/renderer/table_renderer.rb +429 -0
- data/lib/natty-ui/section.rb +144 -32
- data/lib/natty-ui/task.rb +38 -25
- data/lib/natty-ui/temporary.rb +27 -14
- data/lib/natty-ui/utils/border.rb +139 -0
- data/lib/natty-ui/utils/str_const.rb +62 -0
- data/lib/natty-ui/utils/utils.rb +47 -0
- data/lib/natty-ui/version.rb +1 -1
- data/lib/natty-ui.rb +76 -35
- metadata +31 -28
- data/examples/cols.rb +0 -38
- data/examples/illustration.rb +0 -60
- data/examples/options.rb +0 -28
- data/examples/themes.rb +0 -51
- data/lib/natty-ui/attributes.rb +0 -593
- data/lib/natty-ui/choice.rb +0 -67
- data/lib/natty-ui/dumb_choice.rb +0 -47
- data/lib/natty-ui/dumb_options.rb +0 -64
- data/lib/natty-ui/framed.rb +0 -50
- data/lib/natty-ui/hbars_renderer.rb +0 -66
- data/lib/natty-ui/options.rb +0 -78
- data/lib/natty-ui/shell_renderer.rb +0 -91
- data/lib/natty-ui/table.rb +0 -325
- data/lib/natty-ui/table_renderer.rb +0 -165
- data/lib/natty-ui/theme.rb +0 -403
- data/lib/natty-ui/utils.rb +0 -111
- data/lib/natty-ui/vbars_renderer.rb +0 -49
- data/lib/natty-ui/width_finder.rb +0 -137
- data/natty-ui.gemspec +0 -34
data/lib/natty-ui.rb
CHANGED
|
@@ -6,34 +6,46 @@ require_relative 'natty-ui/features'
|
|
|
6
6
|
# This is the beautiful, nice, nifty, fancy, neat, pretty, cool, rich, lovely,
|
|
7
7
|
# natty user interface you like to have for your command line applications.
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# {NattyUI} ᓚᕠᗢ is the top-level module and default UI element of the gem. It
|
|
10
|
+
# extends {Features}, so every output, section, and interaction method is
|
|
11
|
+
# available directly on the module or through the {Kernel#ui} helper.
|
|
12
|
+
#
|
|
13
|
+
# @example Require and use via the Kernel helper
|
|
14
|
+
# require 'natty-ui'
|
|
15
|
+
# ui.puts 'Hello, [b]world[/b]!'
|
|
16
|
+
#
|
|
17
|
+
# @example Direct module access
|
|
18
|
+
# require 'natty-ui'
|
|
19
|
+
# NattyUI.puts 'Hello, [b]world[/b]!'
|
|
10
20
|
#
|
|
11
21
|
module NattyUI
|
|
12
|
-
# Uses the ANSI tools of the Terminal.rb gem
|
|
13
|
-
Ansi = Terminal::Ansi
|
|
14
|
-
|
|
15
|
-
# Uses the Text tools of the Terminal.rb gem
|
|
16
|
-
Text = Terminal::Text
|
|
17
|
-
|
|
18
22
|
extend Features
|
|
19
23
|
|
|
20
24
|
class << self
|
|
21
|
-
#
|
|
22
|
-
#
|
|
25
|
+
# Active {Element} (or {NattyUI} as top element) supporting all {Features}.
|
|
26
|
+
#
|
|
27
|
+
# Returns the innermost currently open element. When no element is active
|
|
28
|
+
# this returns {NattyUI} itself, which also implements all {Features}.
|
|
29
|
+
#
|
|
30
|
+
# @example
|
|
31
|
+
# ui.section do
|
|
32
|
+
# NattyUI.element # => the Section instance
|
|
33
|
+
# end
|
|
34
|
+
# NattyUI.element # => NattyUI (no element open)
|
|
23
35
|
#
|
|
24
36
|
# @return [Features]
|
|
25
|
-
# current
|
|
37
|
+
# current active {Element}, or {NattyUI} itself when no element is open
|
|
26
38
|
attr_reader :element
|
|
27
39
|
|
|
28
|
-
# Supported input mode.
|
|
40
|
+
# Supported input mode of the current terminal.
|
|
29
41
|
#
|
|
30
42
|
# @attribute [r] input_mode
|
|
31
43
|
# @return [:default]
|
|
32
|
-
# when terminal
|
|
44
|
+
# when the terminal supports ANSI and interactive keyboard input
|
|
33
45
|
# @return [:dumb]
|
|
34
|
-
# when terminal does not support ANSI or interactive input
|
|
46
|
+
# when the terminal does not support ANSI or interactive input
|
|
35
47
|
# @return [nil]
|
|
36
|
-
# when
|
|
48
|
+
# when standard input is not available
|
|
37
49
|
def input_mode
|
|
38
50
|
case Terminal.input_mode
|
|
39
51
|
when :csi_u, :legacy
|
|
@@ -43,16 +55,34 @@ module NattyUI
|
|
|
43
55
|
end
|
|
44
56
|
end
|
|
45
57
|
|
|
46
|
-
#
|
|
58
|
+
# Current terminal title.
|
|
59
|
+
#
|
|
60
|
+
# Returns the title most recently set via `title=`, or `nil` when no
|
|
61
|
+
# title has been set yet. Titles are kept in an internal stack; assigning
|
|
62
|
+
# `nil` to `title=` pops the current entry and restores the previous one.
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
# NattyUI.title = 'My App'
|
|
66
|
+
# NattyUI.title = 'My App — Processing…'
|
|
67
|
+
# do_work
|
|
68
|
+
# NattyUI.title = nil # => restore last title
|
|
69
|
+
# NattyUI.title # => "My App"
|
|
47
70
|
#
|
|
48
71
|
# @attribute [r] title
|
|
49
|
-
# @return [String]
|
|
50
|
-
#
|
|
51
|
-
# @return [nil]
|
|
52
|
-
# when no title was set
|
|
72
|
+
# @return [String] currently active title
|
|
73
|
+
# @return [nil] when no title has been set
|
|
53
74
|
def title = @title_stack[-1]
|
|
54
75
|
|
|
76
|
+
# Sets or clears the terminal title.
|
|
77
|
+
#
|
|
78
|
+
# Pushes the given title onto an internal stack and writes an ANSI title
|
|
79
|
+
# escape to the terminal (when ANSI is supported). Passing `nil` pops the
|
|
80
|
+
# current title and restores the previous one.
|
|
81
|
+
#
|
|
82
|
+
#
|
|
55
83
|
# @attribute [w] title
|
|
84
|
+
# @param value [#to_s, nil]
|
|
85
|
+
# new title string, or `nil` to remove the current title
|
|
56
86
|
def title=(value)
|
|
57
87
|
if value
|
|
58
88
|
title = Ansi.plain(value).gsub(/\s+/, ' ')
|
|
@@ -85,6 +115,9 @@ module NattyUI
|
|
|
85
115
|
@lines_written = number
|
|
86
116
|
end
|
|
87
117
|
|
|
118
|
+
# @private
|
|
119
|
+
def end = self
|
|
120
|
+
|
|
88
121
|
private
|
|
89
122
|
|
|
90
123
|
def _begin(element)
|
|
@@ -95,24 +128,19 @@ module NattyUI
|
|
|
95
128
|
|
|
96
129
|
def _end(element)
|
|
97
130
|
idx = @stack.index(element) or return @element
|
|
98
|
-
@stack.drop(idx).each {
|
|
131
|
+
@stack.drop(idx).each { it.__send__(:done) }
|
|
99
132
|
@stack = @stack.take(idx)
|
|
100
133
|
Terminal.show_cursor if (@element = @stack[-1]) == self
|
|
101
134
|
@element
|
|
102
135
|
end
|
|
103
|
-
|
|
104
|
-
def _with(element, *text, **options, &block)
|
|
105
|
-
_begin(element)
|
|
106
|
-
element.puts(*text, **options) unless text.empty?
|
|
107
|
-
return element unless block
|
|
108
|
-
begin
|
|
109
|
-
yield(element)
|
|
110
|
-
ensure
|
|
111
|
-
_end(element)
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
136
|
end
|
|
115
137
|
|
|
138
|
+
# @private
|
|
139
|
+
Ansi = Terminal::Ansi
|
|
140
|
+
|
|
141
|
+
Text = Terminal::Text
|
|
142
|
+
private_constant(:Text)
|
|
143
|
+
|
|
116
144
|
@stack = [@element = self]
|
|
117
145
|
@lines_written = 0
|
|
118
146
|
@title_stack = []
|
|
@@ -121,12 +149,25 @@ module NattyUI
|
|
|
121
149
|
end
|
|
122
150
|
|
|
123
151
|
unless defined?(Kernel.ui)
|
|
152
|
+
# Extensions to the standard `Kernel` module added by NattyUI.
|
|
124
153
|
module Kernel
|
|
125
|
-
#
|
|
126
|
-
#
|
|
127
|
-
#
|
|
154
|
+
# Returns the currently active {NattyUI} element.
|
|
155
|
+
#
|
|
156
|
+
# Convenience shorthand for {NattyUI.element}. All {NattyUI::Features}
|
|
157
|
+
# methods are available on the returned value.
|
|
158
|
+
#
|
|
159
|
+
# @example
|
|
160
|
+
# ui.puts 'Hello!'
|
|
161
|
+
#
|
|
162
|
+
# @example Inside a section block
|
|
163
|
+
# ui.section 'Results' do
|
|
164
|
+
# ui.ok 'All tests passed'
|
|
165
|
+
# end
|
|
166
|
+
#
|
|
167
|
+
# @return [NattyUI::Features]
|
|
168
|
+
# active UI element ({NattyUI::Element} or {NattyUI} itself)
|
|
128
169
|
def ui = NattyUI.element
|
|
129
170
|
|
|
130
|
-
# alias
|
|
171
|
+
# alias ᓚᕠᗢ ui
|
|
131
172
|
end
|
|
132
173
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: natty-ui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Blumtritt
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 1.0.5
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 1.0.5
|
|
26
26
|
description: 'This is the beautiful, nice, nifty, fancy, neat, pretty, cool, rich,
|
|
27
27
|
lovely, natty user interface tool you like to have for your command line applications.
|
|
28
28
|
It contains elegant, simple and beautiful features that enhance your command line
|
|
@@ -38,57 +38,60 @@ files:
|
|
|
38
38
|
- examples/3bit-colors.rb
|
|
39
39
|
- examples/8bit-colors.rb
|
|
40
40
|
- examples/attributes.rb
|
|
41
|
-
- examples/cols.rb
|
|
42
41
|
- examples/elements.rb
|
|
43
42
|
- examples/examples.rb
|
|
43
|
+
- examples/frames.rb
|
|
44
44
|
- examples/hbars.rb
|
|
45
|
-
- examples/illustration.rb
|
|
46
45
|
- examples/info.rb
|
|
47
46
|
- examples/key-codes.rb
|
|
48
47
|
- examples/ls.rb
|
|
49
48
|
- examples/named-colors.rb
|
|
50
|
-
- examples/options.rb
|
|
51
49
|
- examples/sections.rb
|
|
50
|
+
- examples/select.rb
|
|
52
51
|
- examples/sh.rb
|
|
53
52
|
- examples/tables.rb
|
|
54
53
|
- examples/tasks.rb
|
|
55
|
-
- examples/themes.rb
|
|
56
54
|
- examples/vbars.rb
|
|
57
55
|
- lib/natty-ui.rb
|
|
58
|
-
- lib/natty-ui/
|
|
59
|
-
- lib/natty-ui/choice.rb
|
|
60
|
-
- lib/natty-ui/dumb_choice.rb
|
|
61
|
-
- lib/natty-ui/dumb_options.rb
|
|
56
|
+
- lib/natty-ui/dumb_progress.rb
|
|
62
57
|
- lib/natty-ui/element.rb
|
|
63
58
|
- lib/natty-ui/features.rb
|
|
64
|
-
- lib/natty-ui/
|
|
65
|
-
- lib/natty-ui/
|
|
66
|
-
- lib/natty-ui/
|
|
67
|
-
- lib/natty-ui/options.rb
|
|
59
|
+
- lib/natty-ui/frame.rb
|
|
60
|
+
- lib/natty-ui/helper/table.rb
|
|
61
|
+
- lib/natty-ui/margin.rb
|
|
68
62
|
- lib/natty-ui/progress.rb
|
|
63
|
+
- lib/natty-ui/renderer/bars.rb
|
|
64
|
+
- lib/natty-ui/renderer/choice.rb
|
|
65
|
+
- lib/natty-ui/renderer/dumb_choice.rb
|
|
66
|
+
- lib/natty-ui/renderer/dumb_select.rb
|
|
67
|
+
- lib/natty-ui/renderer/dumb_shell_runner.rb
|
|
68
|
+
- lib/natty-ui/renderer/heading.rb
|
|
69
|
+
- lib/natty-ui/renderer/horizontal_rule.rb
|
|
70
|
+
- lib/natty-ui/renderer/ls.rb
|
|
71
|
+
- lib/natty-ui/renderer/mark.rb
|
|
72
|
+
- lib/natty-ui/renderer/quote.rb
|
|
73
|
+
- lib/natty-ui/renderer/select.rb
|
|
74
|
+
- lib/natty-ui/renderer/shell.rb
|
|
75
|
+
- lib/natty-ui/renderer/shell_runner.rb
|
|
76
|
+
- lib/natty-ui/renderer/table_renderer.rb
|
|
69
77
|
- lib/natty-ui/section.rb
|
|
70
|
-
- lib/natty-ui/shell_renderer.rb
|
|
71
|
-
- lib/natty-ui/table.rb
|
|
72
|
-
- lib/natty-ui/table_renderer.rb
|
|
73
78
|
- lib/natty-ui/task.rb
|
|
74
79
|
- lib/natty-ui/temporary.rb
|
|
75
|
-
- lib/natty-ui/
|
|
76
|
-
- lib/natty-ui/utils.rb
|
|
77
|
-
- lib/natty-ui/
|
|
80
|
+
- lib/natty-ui/utils/border.rb
|
|
81
|
+
- lib/natty-ui/utils/str_const.rb
|
|
82
|
+
- lib/natty-ui/utils/utils.rb
|
|
78
83
|
- lib/natty-ui/version.rb
|
|
79
|
-
- lib/natty-ui/width_finder.rb
|
|
80
84
|
- lib/natty_ui.rb
|
|
81
|
-
- natty-ui.gemspec
|
|
82
85
|
homepage: https://codeberg.org/mblumtritt/natty-ui
|
|
83
86
|
licenses:
|
|
84
87
|
- MIT
|
|
85
88
|
- Ruby
|
|
86
89
|
metadata:
|
|
87
|
-
source_code_uri: https://codeberg.org/mblumtritt/natty-ui
|
|
88
|
-
bug_tracker_uri: https://codeberg.org/mblumtritt/natty-ui/issues
|
|
89
|
-
documentation_uri: https://rubydoc.info/gems/natty-ui
|
|
90
90
|
rubygems_mfa_required: 'true'
|
|
91
91
|
yard.run: yard
|
|
92
|
+
source_code_uri: https://codeberg.org/mblumtritt/natty-ui
|
|
93
|
+
bug_tracker_uri: https://codeberg.org/mblumtritt/natty-ui/issues
|
|
94
|
+
documentation_uri: https://rubydoc.info/gems/natty-ui1.0.2
|
|
92
95
|
rdoc_options: []
|
|
93
96
|
require_paths:
|
|
94
97
|
- lib
|
|
@@ -96,14 +99,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
96
99
|
requirements:
|
|
97
100
|
- - ">="
|
|
98
101
|
- !ruby/object:Gem::Version
|
|
99
|
-
version: '3.
|
|
102
|
+
version: '3.4'
|
|
100
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
104
|
requirements:
|
|
102
105
|
- - ">="
|
|
103
106
|
- !ruby/object:Gem::Version
|
|
104
107
|
version: '0'
|
|
105
108
|
requirements: []
|
|
106
|
-
rubygems_version: 4.0.
|
|
109
|
+
rubygems_version: 4.0.13
|
|
107
110
|
specification_version: 4
|
|
108
111
|
summary: This is the beautiful, nice, nifty, fancy, neat, pretty, cool, rich, lovely,
|
|
109
112
|
natty user interface you like to have for your CLI.
|
data/examples/cols.rb
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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(<<~TEXT, style: 'bright_white on_blue', align: :left)
|
|
21
|
-
This is a left aligned blue column with some text but also with
|
|
22
|
-
a forced line break.
|
|
23
|
-
TEXT
|
|
24
|
-
cc.add(
|
|
25
|
-
'This is the middle red column.',
|
|
26
|
-
style: 'bright_white on_red',
|
|
27
|
-
align: :centered,
|
|
28
|
-
vertical: :middle
|
|
29
|
-
)
|
|
30
|
-
cc.add(
|
|
31
|
-
'This is a right aligned blue column vertically bottom aligned.',
|
|
32
|
-
style: 'bright_white on_blue',
|
|
33
|
-
align: :right,
|
|
34
|
-
vertical: :bottom
|
|
35
|
-
)
|
|
36
|
-
cc.padding = [1, 2]
|
|
37
|
-
end
|
|
38
|
-
end
|
data/examples/illustration.rb
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative '../lib/natty-ui'
|
|
4
|
-
|
|
5
|
-
ui.message '[b]ᓚᕠᗢ NattyUI[/b]' do
|
|
6
|
-
ui.space
|
|
7
|
-
ui.table(border: :defaulth, border_style: 'bright_blue') do |table|
|
|
8
|
-
table.add do |row|
|
|
9
|
-
row.add 'Styles'
|
|
10
|
-
row.add <<~TEXT, eol: false
|
|
11
|
-
Support of all ANSI styles like
|
|
12
|
-
[b]bold[/b],
|
|
13
|
-
[i]italic[/i],
|
|
14
|
-
[u]underline[/u],
|
|
15
|
-
[inv]invert[/inv],
|
|
16
|
-
[s]strike[/s],
|
|
17
|
-
[faint]faint[/faint],
|
|
18
|
-
[double_underline]double underline[/double_underline],
|
|
19
|
-
[curly_underline]curly underline[/curly_underline],
|
|
20
|
-
[dotted_underline]dotted underline[/dotted_underline],
|
|
21
|
-
[dashed_underline]dashed underline[/dashed_underline]
|
|
22
|
-
and even rarely supported like [fraktur]fraktur[/fraktur].
|
|
23
|
-
TEXT
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
table.add do |row|
|
|
27
|
-
row.add 'Colors'
|
|
28
|
-
row.add <<~TEXT
|
|
29
|
-
✓ [palegreen]3/4-bit color[/fg] ✓ #{NattyUI::Ansi.rainbow('Truecolor')} ✓ [tan1]NO_COLOR convention[/fg]
|
|
30
|
-
✓ [skyblue]8-bit color[/fg] ✓ [gold]Dumb terminals[/fg]
|
|
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
|
|
42
|
-
🎩 heading elements 📝 messages 📊 bar graphs
|
|
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
|
|
51
|
-
[bright_green]🇨🇳 该库支持中文,日文和韩文文本!
|
|
52
|
-
[bright_green]🇯🇵 ライブラリは中国語、日本語、韓国語のテキストをサポートしています
|
|
53
|
-
[bright_green]🇰🇷 이 라이브러리는 중국어, 일본어 및 한국어 텍스트를 지원합니다
|
|
54
|
-
TEXT
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
table.columns[0].assign(style: 'bold red', width: 8)
|
|
58
|
-
table.columns[1].padding_right = 2
|
|
59
|
-
end
|
|
60
|
-
end
|
data/examples/options.rb
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative '../lib/natty-ui'
|
|
4
|
-
|
|
5
|
-
ui.message '[b]ᓚᕠᗢ NattyUI[/b] [i green]Options and Selections[/]' do
|
|
6
|
-
ui.space
|
|
7
|
-
ui.puts <<~INFO, eol: false
|
|
8
|
-
[i]Options[/i] and [i]selections[/i] allow the user to select from several
|
|
9
|
-
options interactively.
|
|
10
|
-
If ANSI is available the user can use [b][Up][/b] and [b][Down][/b] keys to
|
|
11
|
-
navigate, switch the state of selected item with [b][Space][/b] and complete
|
|
12
|
-
the selection with [b][Enter][/b].
|
|
13
|
-
INFO
|
|
14
|
-
|
|
15
|
-
ui.space
|
|
16
|
-
options =
|
|
17
|
-
ui.select %w[Kitty iTerm2 Ghostty Tabby Rio] do
|
|
18
|
-
ui.puts '[i]Which terminal applications did you already tested?[/i]'
|
|
19
|
-
end
|
|
20
|
-
case options.size
|
|
21
|
-
when 0
|
|
22
|
-
ui.puts 'You selected nothing – test more in future!'
|
|
23
|
-
when 1
|
|
24
|
-
ui.puts "#{options.first} is indeed a nice terminal."
|
|
25
|
-
else
|
|
26
|
-
ui.puts "#{options.join(', ')} are worth to test!"
|
|
27
|
-
end
|
|
28
|
-
end
|
data/examples/themes.rb
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative '../lib/natty-ui'
|
|
4
|
-
|
|
5
|
-
NAMES = NattyUI::Theme.names.freeze
|
|
6
|
-
DESCR = NAMES.map { NattyUI::Theme.description(_1) }.freeze
|
|
7
|
-
ORG = NattyUI::Theme.current_name
|
|
8
|
-
|
|
9
|
-
def show(name)
|
|
10
|
-
NattyUI::Theme.use(name)
|
|
11
|
-
theme = NattyUI::Theme.current
|
|
12
|
-
ui.message(
|
|
13
|
-
"[b]ᓚᕠᗢ NattyUI [/b] [i green]Theme #{NattyUI::Theme.description(name)}[/]"
|
|
14
|
-
) do
|
|
15
|
-
ui.ls(
|
|
16
|
-
(1..6).map do |i|
|
|
17
|
-
left, right = theme.heading(i)
|
|
18
|
-
"#{left} H#{i} #{right}"
|
|
19
|
-
end
|
|
20
|
-
)
|
|
21
|
-
ui.space
|
|
22
|
-
ui.ls(theme.defined_marks.map { "#{theme.mark(_1)} #{_1}" })
|
|
23
|
-
ui.space
|
|
24
|
-
ui.ls(
|
|
25
|
-
%i[
|
|
26
|
-
task_style
|
|
27
|
-
choice_style
|
|
28
|
-
choice_current_style
|
|
29
|
-
sh_out_style
|
|
30
|
-
sh_err_style
|
|
31
|
-
].map { "#{theme.send(_1)}█ #{_1} [/]" }
|
|
32
|
-
)
|
|
33
|
-
ui.space
|
|
34
|
-
%i[section message information warning error].each do |name|
|
|
35
|
-
ui.send(name, name.capitalize)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
while true
|
|
41
|
-
selected =
|
|
42
|
-
ui.choice(*DESCR, abortable: true, selected: selected) do
|
|
43
|
-
ui.puts '[bright_green b]Select a theme:[/] [faint](Abort with [\\ESC])'
|
|
44
|
-
end
|
|
45
|
-
break unless selected
|
|
46
|
-
ui.temporary do
|
|
47
|
-
show(NAMES[selected])
|
|
48
|
-
ui.await { ui.puts '[faint][\\Press ENTER to continue...]' }
|
|
49
|
-
end
|
|
50
|
-
NattyUI::Theme.use(ORG)
|
|
51
|
-
end
|