natty-ui 0.29.0 → 0.30.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/README.md +3 -3
- data/lib/natty-ui/features.rb +61 -50
- data/lib/natty-ui/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3573e7d7a6d163f278494a095198e3fd913ff6710c4984ff12279f80893c1b54
|
4
|
+
data.tar.gz: 9d424a564160fa470b71d857b31fa725320b21047abd8423e613335b0e0449c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2b6c3c4bc0c8636bbed5dcfcfb5cc9f77487ef84be7650abba172b707cf2e9eb9c59b9a4f0ba3c2209ce4902c704f8920cbd99d63d7da3cd347dbf466afe689
|
7
|
+
data.tar.gz: 2c514b126360dd2c2b6173e9944db8e3cc1bd5a5505d5176ebaa382cf9a810dccc59137c55d1b18d7f1229ac8cbcee5fa9553ad5763ecea30fa84cabc0430387
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
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
|
-
- Source: [
|
6
|
+
- Source: [codeberg.org](https://codeberg.org/mblumtritt/natty-ui)
|
7
7
|
- Help: [rubydoc.info](https://rubydoc.info/gems/natty-ui/NattyUI)
|
8
8
|
|
9
9
|
## Features
|
@@ -33,13 +33,13 @@ This is the beautiful, nice, nifty, fancy, neat, pretty, cool, rich, lovely, nat
|
|
33
33
|
|
34
34
|
You can execute all examples by
|
35
35
|
|
36
|
-
```
|
36
|
+
```shell
|
37
37
|
ruby ./examples/examples.rb
|
38
38
|
```
|
39
39
|
|
40
40
|
or see the non-ANSI version
|
41
41
|
|
42
|
-
```
|
42
|
+
```shell
|
43
43
|
NO_COLOR=1 ruby ./examples/examples.rb
|
44
44
|
```
|
45
45
|
|
data/lib/natty-ui/features.rb
CHANGED
@@ -37,52 +37,67 @@ module NattyUI
|
|
37
37
|
# @return [Features]
|
38
38
|
# itself
|
39
39
|
def puts(*text, **options)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
if max_width < 1
|
45
|
-
if max_width > 0
|
46
|
-
max_width *= Terminal.columns
|
47
|
-
elsif max_width < 0
|
48
|
-
max_width += Terminal.columns
|
49
|
-
end
|
40
|
+
if (ansi = Terminal.ansi?)
|
41
|
+
@__eol ||= "\e[m\n"
|
42
|
+
else
|
43
|
+
@__eol ||= "\n"
|
50
44
|
end
|
51
45
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
46
|
+
if options.empty?
|
47
|
+
bbcode = true
|
48
|
+
max_width = Terminal.columns
|
49
|
+
else
|
50
|
+
bbcode = true if (bbcode = options[:bbcode]).nil?
|
51
|
+
ignore_newline = options[:eol] == false || options[:ignore_newline]
|
52
|
+
|
53
|
+
if (max_width = options[:max_width]).nil?
|
54
|
+
return self if (max_width = Terminal.columns).zero?
|
55
|
+
elsif max_width < 1
|
56
|
+
if max_width > 0
|
57
|
+
max_width *= Terminal.columns
|
58
|
+
elsif max_width < 0
|
59
|
+
max_width += Terminal.columns
|
60
|
+
else
|
61
|
+
return self
|
62
|
+
end
|
58
63
|
end
|
59
64
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
65
|
+
prefix_width =
|
66
|
+
if (prefix = options[:prefix])
|
67
|
+
prefix = Ansi.bbcode(prefix) if bbcode
|
68
|
+
options[:prefix_width] || Text.width(prefix, bbcode: false)
|
69
|
+
else
|
70
|
+
0
|
71
|
+
end
|
72
|
+
|
73
|
+
if (first_line = options[:first_line_prefix])
|
74
|
+
first_line = Ansi.bbcode(first_line) if bbcode
|
75
|
+
first_line_width =
|
76
|
+
options[:first_line_prefix_width] ||
|
77
|
+
Text.width(first_line, bbcode: false)
|
78
|
+
|
79
|
+
if prefix_width < first_line_width
|
80
|
+
prefix_next = "#{prefix}#{' ' * (first_line_width - prefix_width)}"
|
81
|
+
prefix = first_line
|
82
|
+
prefix_width = first_line_width
|
83
|
+
else
|
84
|
+
prefix_next = prefix
|
85
|
+
prefix =
|
86
|
+
if first_line_width < prefix_width
|
87
|
+
first_line + (' ' * (prefix_width - first_line_width))
|
88
|
+
else
|
89
|
+
first_line
|
90
|
+
end
|
91
|
+
end
|
78
92
|
end
|
79
|
-
end
|
80
93
|
|
81
|
-
|
94
|
+
max_width -= prefix_width
|
82
95
|
|
83
|
-
|
84
|
-
|
85
|
-
|
96
|
+
if (suffix = options[:suffix])
|
97
|
+
suffix = Ansi.bbcode(suffix) if bbcode
|
98
|
+
max_width -=
|
99
|
+
options[:suffix_width] || Text.width(suffix, bbcode: false)
|
100
|
+
end
|
86
101
|
end
|
87
102
|
|
88
103
|
return self if max_width <= 0
|
@@ -92,13 +107,13 @@ module NattyUI
|
|
92
107
|
*text,
|
93
108
|
limit: max_width,
|
94
109
|
bbcode: bbcode,
|
95
|
-
ansi:
|
96
|
-
ignore_newline:
|
110
|
+
ansi: ansi,
|
111
|
+
ignore_newline: ignore_newline
|
97
112
|
)
|
98
113
|
|
99
114
|
if (align = options[:align]).nil?
|
100
115
|
lines.each do |line|
|
101
|
-
Terminal.print(prefix, line, suffix, __eol, bbcode: false)
|
116
|
+
Terminal.print(prefix, line, suffix, @__eol, bbcode: false)
|
102
117
|
@lines_written += 1
|
103
118
|
prefix, prefix_next = prefix_next, nil if prefix_next
|
104
119
|
end
|
@@ -118,7 +133,7 @@ module NattyUI
|
|
118
133
|
' ' * (max_width - width),
|
119
134
|
line,
|
120
135
|
suffix,
|
121
|
-
__eol,
|
136
|
+
@__eol,
|
122
137
|
bbcode: false
|
123
138
|
)
|
124
139
|
@lines_written += 1
|
@@ -133,7 +148,7 @@ module NattyUI
|
|
133
148
|
line,
|
134
149
|
' ' * (space - lw),
|
135
150
|
suffix,
|
136
|
-
__eol,
|
151
|
+
@__eol,
|
137
152
|
bbcode: false
|
138
153
|
)
|
139
154
|
@lines_written += 1
|
@@ -146,7 +161,7 @@ module NattyUI
|
|
146
161
|
line,
|
147
162
|
' ' * (max_width - width),
|
148
163
|
suffix,
|
149
|
-
__eol,
|
164
|
+
@__eol,
|
150
165
|
bbcode: false
|
151
166
|
)
|
152
167
|
@lines_written += 1
|
@@ -301,7 +316,7 @@ module NattyUI
|
|
301
316
|
#
|
302
317
|
# @return (see puts)
|
303
318
|
def space(count = 1)
|
304
|
-
puts("\n" * count)
|
319
|
+
(count = count.to_i).positive? ? puts("\n" * count) : self
|
305
320
|
end
|
306
321
|
|
307
322
|
# Print given items as list (like 'ls' command).
|
@@ -945,10 +960,6 @@ module NattyUI
|
|
945
960
|
end
|
946
961
|
end
|
947
962
|
end
|
948
|
-
|
949
|
-
def __eol
|
950
|
-
@__eol ||= Terminal.ansi? ? "\e[m\n" : "\n"
|
951
|
-
end
|
952
963
|
end
|
953
964
|
|
954
965
|
dir = __dir__
|
data/lib/natty-ui/version.rb
CHANGED
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: 0.30.0
|
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: 0.13.0
|
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: 0.13.0
|
26
26
|
description: |
|
27
27
|
This is the beautiful, nice, nifty, fancy, neat, pretty, cool, rich, lovely,
|
28
28
|
natty user interface tool you like to have for your command line applications.
|
@@ -78,12 +78,12 @@ files:
|
|
78
78
|
- lib/natty-ui/version.rb
|
79
79
|
- lib/natty-ui/width_finder.rb
|
80
80
|
- lib/natty_ui.rb
|
81
|
-
homepage: https://
|
81
|
+
homepage: https://codeberg.org/mblumtritt/natty-ui
|
82
82
|
licenses:
|
83
83
|
- BSD-3-Clause
|
84
84
|
metadata:
|
85
|
-
source_code_uri: https://
|
86
|
-
bug_tracker_uri: https://
|
85
|
+
source_code_uri: https://codeberg.org/mblumtritt/natty-ui
|
86
|
+
bug_tracker_uri: https://codeberg.org/mblumtritt/natty-ui/issues
|
87
87
|
documentation_uri: https://rubydoc.info/gems/natty-ui
|
88
88
|
rubygems_mfa_required: 'true'
|
89
89
|
yard.run: yard
|