rbtext 0.0.4 → 0.0.7
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/lib/rbtext/colors.rb +8 -3
- data/lib/rbtext/cursor.rb +7 -2
- data/lib/rbtext/formatting.rb +18 -4
- data/lib/rbtext/ftext.rb +22 -0
- data/lib/rbtext/screen.rb +18 -0
- data/lib/rbtext.rb +4 -2
- metadata +6 -4
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/cursor.rb
CHANGED
@@ -16,15 +16,20 @@ module RBText
|
|
16
16
|
print "\033[#{num.to_i}C"
|
17
17
|
end
|
18
18
|
|
19
|
+
def go_to_pos(x, y)
|
20
|
+
print "\033[#{y};#{x}H"
|
21
|
+
print "\033[#{y};#{x}f"
|
22
|
+
end
|
23
|
+
|
19
24
|
def beginning_of_line
|
20
25
|
print "\r"
|
21
26
|
end
|
22
27
|
|
23
|
-
module_function :up, :down, :left, :right, :beginning_of_line
|
28
|
+
module_function :up, :down, :left, :right, :beginning_of_line, :go_to_pos
|
24
29
|
end
|
25
30
|
|
26
31
|
module Cr
|
27
32
|
include RBText::Cursor
|
28
|
-
module_function :up, :down, :left, :right, :beginning_of_line
|
33
|
+
module_function :up, :down, :left, :right, :beginning_of_line, :go_to_pos
|
29
34
|
end
|
30
35
|
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
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RBText
|
2
|
+
module Screen
|
3
|
+
def clear
|
4
|
+
print "\033[2J"
|
5
|
+
end
|
6
|
+
|
7
|
+
def clear_line
|
8
|
+
print "\033[2K"
|
9
|
+
end
|
10
|
+
|
11
|
+
module_function :clear, :clear_line
|
12
|
+
end
|
13
|
+
|
14
|
+
module S
|
15
|
+
include RBText::Screen
|
16
|
+
module_function :clear, :clear_line
|
17
|
+
end
|
18
|
+
end
|
data/lib/rbtext.rb
CHANGED
@@ -2,14 +2,16 @@ require_relative "rbtext/cursor.rb"
|
|
2
2
|
require_relative "rbtext/colors.rb"
|
3
3
|
require_relative "rbtext/formatting.rb"
|
4
4
|
require_relative "rbtext/ftext.rb"
|
5
|
+
require_relative "rbtext/screen.rb"
|
5
6
|
|
6
7
|
module RBText
|
7
8
|
@ver_1 = 0
|
8
9
|
@ver_2 = 0
|
9
|
-
@ver_3 =
|
10
|
+
@ver_3 = 7
|
11
|
+
@ver_4 = ""
|
10
12
|
|
11
13
|
def version
|
12
|
-
"#{@ver_1}.#{@ver_2}.#{@ver_3}"
|
14
|
+
"#{@ver_1}.#{@ver_2}.#{@ver_3}#{".#{@ver_4}" if @ver_4.length > 1}"
|
13
15
|
end
|
14
16
|
|
15
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
|
@@ -21,8 +21,10 @@ files:
|
|
21
21
|
- lib/rbtext/cursor.rb
|
22
22
|
- lib/rbtext/formatting.rb
|
23
23
|
- lib/rbtext/ftext.rb
|
24
|
-
|
25
|
-
|
24
|
+
- lib/rbtext/screen.rb
|
25
|
+
homepage: https://github.com/Matthiasclee/RBText
|
26
|
+
licenses:
|
27
|
+
- AGPL-3.0
|
26
28
|
metadata: {}
|
27
29
|
post_install_message:
|
28
30
|
rdoc_options: []
|