terminal_rb 1.0.3 → 1.0.4
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 +2 -2
- data/lib/terminal/ansi.rb +8 -4
- data/lib/terminal/text/formatter.rb +3 -8
- data/lib/terminal/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cafc2d55ed2812b89586adb37fbe22d9c1a46bec4c7ab87f7ba326792254ff5f
|
|
4
|
+
data.tar.gz: 1cf7e56b768478dbafa982fe555693cb110c1825476f155af52214853527b9c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 80820ee91b7ae9db787cdbeb0d28fc0bfeafae944ea5106008286b693e13dfed8fa718794cc5c2f656d47d0a1a84918b0708b92206e6e00ec180a75b4ab406d3
|
|
7
|
+
data.tar.gz: 1fe8c92a73d3469cb356c924919dc2d4639e74706606f13b6cf7d06c299637ab193e4d6722d061dcfd59b854231d55c23c538dc4593ca21a5cfd600620bebc55
|
data/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# Terminal.rb v1.0.
|
|
1
|
+
# Terminal.rb v1.0.4
|
|
2
2
|
|
|
3
3
|
Terminal.rb supports you with input and output on your terminal. Simple [BBCode](https://en.wikipedia.org/wiki/BBCode)-like markup for attributes and coloring, word-wise line breaks, correct special key recognition and mouse event reporting enable you to implement your CLI app quickly and easily.
|
|
4
4
|
|
|
5
5
|
- Gem: [rubygems.org](https://rubygems.org/gems/terminal_rb)
|
|
6
6
|
- Source: [codeberg.org](https://codeberg.org/mblumtritt/Terminal.rb)
|
|
7
|
-
- Help: [rubydoc.info](https://rubydoc.info/gems/terminal_rb/1.0.
|
|
7
|
+
- Help: [rubydoc.info](https://rubydoc.info/gems/terminal_rb/1.0.4/Terminal)
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
data/lib/terminal/ansi.rb
CHANGED
|
@@ -184,7 +184,8 @@ module Terminal
|
|
|
184
184
|
# @param str [#to_s] text with BBCode markup
|
|
185
185
|
# @return [String] text with ANSI escape codes
|
|
186
186
|
def bbcode(str)
|
|
187
|
-
|
|
187
|
+
str = str.to_s
|
|
188
|
+
return str.dup unless str.index('[')
|
|
188
189
|
str.gsub(@re_bbcode) do |match_str|
|
|
189
190
|
match = Regexp.last_match(1) or next match_str
|
|
190
191
|
next try_convert(match) || match_str if match[0] != '\\'
|
|
@@ -203,7 +204,8 @@ module Terminal
|
|
|
203
204
|
# @param str [#to_s] text with BBCode markup
|
|
204
205
|
# @return [String] text with tags removed
|
|
205
206
|
def unbbcode(str)
|
|
206
|
-
|
|
207
|
+
str = str.to_s
|
|
208
|
+
return str.dup unless str.index('[')
|
|
207
209
|
str.gsub(@re_bbcode) do |match_str|
|
|
208
210
|
match = Regexp.last_match(1) or next match_str
|
|
209
211
|
if match[0] == '\\'
|
|
@@ -228,7 +230,8 @@ module Terminal
|
|
|
228
230
|
# @param str [#to_s] text with BBCode markup
|
|
229
231
|
# @return [String] text with BBCode tags escaped
|
|
230
232
|
def escape_bbcode(str)
|
|
231
|
-
|
|
233
|
+
str = str.to_s
|
|
234
|
+
return str.dup unless str.index('[')
|
|
232
235
|
str.gsub(@re_bbcode) do |match_str|
|
|
233
236
|
fc = match_str[1]
|
|
234
237
|
next match_str if fc == '\\' || fc == ']'
|
|
@@ -287,7 +290,8 @@ module Terminal
|
|
|
287
290
|
# @param str [#to_s] text with BBCode and/or ANSI codes
|
|
288
291
|
# @return [String] plain text
|
|
289
292
|
def plain(str)
|
|
290
|
-
str
|
|
293
|
+
str = unbbcode(str)
|
|
294
|
+
str.gsub!(@re_test, '') if str.index("\e")
|
|
291
295
|
str
|
|
292
296
|
end
|
|
293
297
|
|
|
@@ -80,7 +80,7 @@ module Terminal
|
|
|
80
80
|
)
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
# Create a new formatter
|
|
83
|
+
# Create a new formatter with given text and options.
|
|
84
84
|
#
|
|
85
85
|
# @param str [Array<#to_s>] text to process
|
|
86
86
|
# @param ansi [true, false] recognize ANSI escape codes
|
|
@@ -446,17 +446,12 @@ module Terminal
|
|
|
446
446
|
@lex << Csi.new(csi)
|
|
447
447
|
end
|
|
448
448
|
|
|
449
|
-
if (last = @lex[-1]) == EOL
|
|
450
|
-
@lex.pop
|
|
451
|
-
@lex << CsiEnd if csis != 0
|
|
452
|
-
next @lex << EOP
|
|
453
|
-
end
|
|
449
|
+
@lex.pop if (last = @lex[-1]) == EOL
|
|
454
450
|
|
|
455
451
|
next @lex << EOP if csis == 0
|
|
456
452
|
|
|
457
|
-
if last.is_a?(Csi)
|
|
453
|
+
if last.is_a?(Csi) && csis == 1
|
|
458
454
|
@lex.pop
|
|
459
|
-
@lex << CsiEnd if csis > 1
|
|
460
455
|
else
|
|
461
456
|
@lex << CsiEnd
|
|
462
457
|
end
|
data/lib/terminal/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: terminal_rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Blumtritt
|
|
@@ -59,7 +59,7 @@ metadata:
|
|
|
59
59
|
yard.run: yard
|
|
60
60
|
source_code_uri: https://codeberg.org/mblumtritt/Terminal.rb
|
|
61
61
|
bug_tracker_uri: https://codeberg.org/mblumtritt/Terminal.rb/issues
|
|
62
|
-
documentation_uri: https://rubydoc.info/gems/terminal_rb/1.0.
|
|
62
|
+
documentation_uri: https://rubydoc.info/gems/terminal_rb/1.0.4
|
|
63
63
|
rdoc_options: []
|
|
64
64
|
require_paths:
|
|
65
65
|
- lib
|
|
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
75
|
version: '0'
|
|
76
76
|
requirements: []
|
|
77
|
-
rubygems_version: 4.0.
|
|
77
|
+
rubygems_version: 4.0.11
|
|
78
78
|
specification_version: 4
|
|
79
79
|
summary: Fast terminal access with ANSI, CSIu, mouse events, BBCode, word-wise line
|
|
80
80
|
break support and much more.
|