rbtext 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ftext +7 -3
- data/lib/rbtext/cursor.rb +11 -1
- data/lib/rbtext/ftext.rb +9 -1
- data/lib/rbtext/screen.rb +6 -1
- data/lib/rbtext/string_methods.rb +36 -0
- data/lib/rbtext.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aeaa3d4a31eb6b39b6351a8ebeb376210ad717d62d9bf00490fc588cd27356f4
|
4
|
+
data.tar.gz: f201309c0bc1818511cbaa2e3435a6f27ac1a4446dcc73a3d5b2689aaae62102
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7efedf2c0528c5624716c58adbdbfaa6d6e709cf5f03e955d3320a326861330cc1465b863cb1084a4879a4a8d7ed812356c862c092cfe5506244d05e9471c154
|
7
|
+
data.tar.gz: 86ffbe26056a8de1437fa2ecd20c0b9cdb4ca04de03e82d868e8bf016965edded9aa08733cd3d33555cb9335448987dd539f6f7d10b1e83f994e897e636c4ddb
|
data/bin/ftext
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
require_relative '../lib/rbtext.rb'
|
3
3
|
|
4
|
+
params = (ARGV[1..ARGV.length-1]).to_a
|
5
|
+
|
4
6
|
if $stdin.tty? && ARGV[0]
|
5
7
|
txt = ARGV[0].to_s
|
6
8
|
elsif $stdin.tty?
|
@@ -18,13 +20,15 @@ else
|
|
18
20
|
end
|
19
21
|
|
20
22
|
(0..lines.length-1).each do |l|
|
21
|
-
txt << "#{"_.f:reset._" if
|
23
|
+
txt << "#{"_.f:reset._" if !params.include?("--noreset")}_.#{args[l]}._"+lines[l].gsub("_", "\0004")
|
22
24
|
end
|
23
25
|
|
24
26
|
txt = txt.join
|
25
27
|
else
|
26
|
-
txt = ARGF.readlines.join
|
28
|
+
txt = ARGF.readlines.join.gsub("_", "\0004")
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
|
-
|
32
|
+
out = R::Ft.new(txt).to_s.gsub("\0004", "_")
|
33
|
+
print out.dump.sub("\"", "").reverse.sub("\"", "").reverse if params.include?("--dump")
|
34
|
+
print out if !params.include?("--dump")
|
data/lib/rbtext/cursor.rb
CHANGED
@@ -7,7 +7,9 @@ module RBText
|
|
7
7
|
:right,
|
8
8
|
:beginning_of_line,
|
9
9
|
:go_to_pos,
|
10
|
-
:pos
|
10
|
+
:pos,
|
11
|
+
:show,
|
12
|
+
:hide
|
11
13
|
]
|
12
14
|
|
13
15
|
def up(num=1)
|
@@ -53,6 +55,14 @@ module RBText
|
|
53
55
|
print "\r"
|
54
56
|
end
|
55
57
|
|
58
|
+
def show
|
59
|
+
print "\033[?25h"
|
60
|
+
end
|
61
|
+
|
62
|
+
def hide
|
63
|
+
print "\033[?25l"
|
64
|
+
end
|
65
|
+
|
56
66
|
@@methods.each do |method|
|
57
67
|
module_function method
|
58
68
|
end
|
data/lib/rbtext/ftext.rb
CHANGED
@@ -4,7 +4,7 @@ module RBText
|
|
4
4
|
@original_text = str
|
5
5
|
@text = ""
|
6
6
|
|
7
|
-
str = str.split("_")
|
7
|
+
str = str.gsub("_.", "\0001").gsub("._", "\0002").gsub("_", "\0000").gsub("\0001", "_.").gsub("\0002", "._").split("_").map{|x|x.gsub("\0000", "_")}
|
8
8
|
|
9
9
|
for x in str do
|
10
10
|
if x[0] == "." && x[x.length-1] == "." && x.split(":").length == 2
|
@@ -77,6 +77,14 @@ module RBText
|
|
77
77
|
def [](num)
|
78
78
|
self.to_s[num]
|
79
79
|
end
|
80
|
+
|
81
|
+
def *(n)
|
82
|
+
self.to_s*n
|
83
|
+
end
|
84
|
+
|
85
|
+
def include?(i)
|
86
|
+
self.to_s.include?(i)
|
87
|
+
end
|
80
88
|
end
|
81
89
|
|
82
90
|
class Ft < RBText::Ftext
|
data/lib/rbtext/screen.rb
CHANGED
@@ -5,7 +5,8 @@ module RBText
|
|
5
5
|
:clear_line,
|
6
6
|
:size,
|
7
7
|
:height,
|
8
|
-
:width
|
8
|
+
:width,
|
9
|
+
:bell
|
9
10
|
]
|
10
11
|
|
11
12
|
def clear
|
@@ -28,6 +29,10 @@ module RBText
|
|
28
29
|
self.size[1]
|
29
30
|
end
|
30
31
|
|
32
|
+
def bell
|
33
|
+
print "\a"
|
34
|
+
end
|
35
|
+
|
31
36
|
@@methods.each do |method|
|
32
37
|
module_function method
|
33
38
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rbtext/colors'
|
2
|
+
require 'rbtext/formatting'
|
3
|
+
|
4
|
+
class String
|
5
|
+
def color(color, type: :fg)
|
6
|
+
RBText::Colors.color(color, type: type) + self + RBText::Colors.color(:reset, type: type)
|
7
|
+
end
|
8
|
+
|
9
|
+
def num_color(color, type: :fg)
|
10
|
+
RBText::Colors.num_color(color, type: type) + self + RBText::Colors.color(:reset, type: type)
|
11
|
+
end
|
12
|
+
|
13
|
+
def bold
|
14
|
+
RBText::Formatting.bold + self + RBText::Formatting.reset
|
15
|
+
end
|
16
|
+
|
17
|
+
def faint
|
18
|
+
RBText::Formatting.faint + self + RBText::Formatting.reset
|
19
|
+
end
|
20
|
+
|
21
|
+
def italic
|
22
|
+
RBText::Formatting.italic + self + RBText::Formatting.reset
|
23
|
+
end
|
24
|
+
|
25
|
+
def underline
|
26
|
+
RBText::Formatting.underline + self + RBText::Formatting.reset
|
27
|
+
end
|
28
|
+
|
29
|
+
def blinking
|
30
|
+
RBText::Formatting.blinking + self + RBText::Formatting.reset
|
31
|
+
end
|
32
|
+
|
33
|
+
def strikethrough
|
34
|
+
RBText::Formatting.strikethrough + self + RBText::Formatting.reset
|
35
|
+
end
|
36
|
+
end
|
data/lib/rbtext.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbtext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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-
|
11
|
+
date: 2022-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: io
|
14
|
+
name: io-console
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.5.6
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.5.6
|
27
27
|
description: A gem for printing formatted text
|
28
28
|
email: matthias@matthiasclee.com
|
29
29
|
executables:
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/rbtext/formatting.rb
|
39
39
|
- lib/rbtext/ftext.rb
|
40
40
|
- lib/rbtext/screen.rb
|
41
|
+
- lib/rbtext/string_methods.rb
|
41
42
|
homepage: https://github.com/Matthiasclee/RBText
|
42
43
|
licenses:
|
43
44
|
- AGPL-3.0
|