rbtext 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbtext/colors.rb +8 -3
- data/lib/rbtext/formatting.rb +18 -4
- data/lib/rbtext/ftext.rb +22 -0
- data/lib/rbtext.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c7aca79a52e20d6e7d51024f1029cc8ed92a2e870f796026463005acfa28d37
|
4
|
+
data.tar.gz: 8ed901117befbb3899c7a5f1ef9b64c03bec6e0cbe43da498295b6e7e3e4576e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3de37ec9edf252ac34d556b57a52dd5a83fdf8ab43c6099369fc73d30fb43cae5a95084eda353e8789e87064689e204b7dcc9eaed9214744851ffbcf1a988b75
|
7
|
+
data.tar.gz: 9255ebee6de279081a194c964096c6c5eaf1e35c3101d1304a2e2cefc0cf5ab4763c87feb8c0385f95703ee916598c4efa6dfb03f750906fc381e37ebbfe0960
|
data/lib/rbtext/colors.rb
CHANGED
@@ -17,7 +17,8 @@ module RBText
|
|
17
17
|
light_blue: "94",
|
18
18
|
light_magenta: "95",
|
19
19
|
light_cyan: "96",
|
20
|
-
white: "97"
|
20
|
+
white: "97",
|
21
|
+
reset: "39"
|
21
22
|
}
|
22
23
|
end
|
23
24
|
|
@@ -41,11 +42,15 @@ module RBText
|
|
41
42
|
return "\033[#{color_code}m"
|
42
43
|
end
|
43
44
|
|
44
|
-
|
45
|
+
def num_color(num, type: :fg)
|
46
|
+
return "\033[#{type == :fg ? "38" : "48"};5;#{num}m"
|
47
|
+
end
|
48
|
+
|
49
|
+
module_function :fg_color_codes, :bg_color_codes, :color, :num_color
|
45
50
|
end
|
46
51
|
|
47
52
|
module C
|
48
53
|
include RBText::Colors
|
49
|
-
module_function :fg_color_codes, :bg_color_codes, :color
|
54
|
+
module_function :fg_color_codes, :bg_color_codes, :color, :num_color
|
50
55
|
end
|
51
56
|
end
|
data/lib/rbtext/formatting.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
module RBText
|
2
2
|
module Formatting
|
3
|
-
def reset
|
4
|
-
|
3
|
+
def reset(f_opt = nil)
|
4
|
+
if f_opt
|
5
|
+
"\033[#{
|
6
|
+
f_opt =~ /^\033\[(1|2)m$/ ? "\033[22m" : "\033[2#{f_opt.gsub(/[^0-9]/, "")}m"
|
7
|
+
}"
|
8
|
+
else
|
9
|
+
"\033[0m"
|
10
|
+
end
|
5
11
|
end
|
6
12
|
|
7
13
|
def bold
|
@@ -20,11 +26,19 @@ module RBText
|
|
20
26
|
"\033[4m"
|
21
27
|
end
|
22
28
|
|
23
|
-
|
29
|
+
def blinking
|
30
|
+
"\033[5m"
|
31
|
+
end
|
32
|
+
|
33
|
+
def strikethrough
|
34
|
+
"\033[9m"
|
35
|
+
end
|
36
|
+
|
37
|
+
module_function :reset, :bold, :faint, :italic, :underline, :blinking, :strikethrough
|
24
38
|
end
|
25
39
|
|
26
40
|
module F
|
27
41
|
include RBText::Formatting
|
28
|
-
module_function :reset, :bold, :faint, :italic, :underline
|
42
|
+
module_function :reset, :bold, :faint, :italic, :underline, :blinking, :strikethrough
|
29
43
|
end
|
30
44
|
end
|
data/lib/rbtext/ftext.rb
CHANGED
@@ -15,6 +15,10 @@ module RBText
|
|
15
15
|
@text << RBText::Colors.color(x[1].to_sym)
|
16
16
|
elsif x[0] == "cb"
|
17
17
|
@text << RBText::Colors.color(x[1].to_sym, type: :bg)
|
18
|
+
elsif x[0] == "cfn" || x[0] == "cn"
|
19
|
+
@text << RBText::Colors.num_color(x[1])
|
20
|
+
elsif x[0] == "cbn"
|
21
|
+
@text << RBText::Colors.num_color(x[1], type: :bg)
|
18
22
|
elsif x[0] == "f"
|
19
23
|
if x[1] == "reset"
|
20
24
|
@text << RBText::Formatting.reset
|
@@ -26,6 +30,24 @@ module RBText
|
|
26
30
|
@text << RBText::Formatting.italic
|
27
31
|
elsif x[1] == "underline"
|
28
32
|
@text << RBText::Formatting.underline
|
33
|
+
elsif x[1] == "strikethrough"
|
34
|
+
@text << RBText::Formatting.strikethrough
|
35
|
+
elsif x[1] == "blinking"
|
36
|
+
@text << RBText::Formatting.blinking
|
37
|
+
end
|
38
|
+
elsif x[0] == "rf"
|
39
|
+
if x[1] == "bold"
|
40
|
+
@text << RBText::Formatting.reset(R::F.bold)
|
41
|
+
elsif x[1] == "faint"
|
42
|
+
@text << RBText::Formatting.reset(R::F.faint)
|
43
|
+
elsif x[1] == "italic"
|
44
|
+
@text << RBText::Formatting.reset(R::F.italic)
|
45
|
+
elsif x[1] == "underline"
|
46
|
+
@text << RBText::Formatting.reset(R::F.underline)
|
47
|
+
elsif x[1] == "strikethrough"
|
48
|
+
@text << RBText::Formatting.reset(R::F.strikethrough)
|
49
|
+
elsif x[1] == "blinking"
|
50
|
+
@text << RBText::Formatting.reset(R::F.blinking)
|
29
51
|
end
|
30
52
|
end
|
31
53
|
else
|
data/lib/rbtext.rb
CHANGED
@@ -7,10 +7,11 @@ require_relative "rbtext/screen.rb"
|
|
7
7
|
module RBText
|
8
8
|
@ver_1 = 0
|
9
9
|
@ver_2 = 0
|
10
|
-
@ver_3 =
|
10
|
+
@ver_3 = 7
|
11
|
+
@ver_4 = ""
|
11
12
|
|
12
13
|
def version
|
13
|
-
"#{@ver_1}.#{@ver_2}.#{@ver_3}"
|
14
|
+
"#{@ver_1}.#{@ver_2}.#{@ver_3}#{".#{@ver_4}" if @ver_4.length > 1}"
|
14
15
|
end
|
15
16
|
|
16
17
|
module_function :version
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbtext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthias Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A gem for printing formatted text
|
14
14
|
email: matthias@matthiasclee.com
|