rbtext 0.3.2 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ftext +33 -11
- data/lib/rbtext/screen.rb +12 -0
- data/lib/rbtext.rb +2 -1
- metadata +36 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccdee9f23008ced0f1bdc97a19f38fa63328a34c627c002c516b7e8eab6fd12b
|
4
|
+
data.tar.gz: 5bd460e3387683c628310b351b377ac614672cdf697da0d0f136cfdee04bd148
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2510193ee742687619d2655a3b744f929ea0af609a6840d2d53001bbeef642a188c122ae4fcc2b5279ce2157b5ca00451cf0a21c8f988d16fdf62b11b94d1b3c
|
7
|
+
data.tar.gz: aa33777189a62c0acaf2b6a30361db34b419404e9bcc9061f8d17ea534529b0a39855c103cb4281772e6cea581a6306af7ba91588f595cbd515c4d543104852d
|
data/bin/ftext
CHANGED
@@ -1,26 +1,48 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require_relative '../lib/rbtext.rb'
|
3
|
+
require 'argparse'
|
3
4
|
|
4
|
-
|
5
|
+
opts = {
|
6
|
+
dump: { has_argument: false },
|
7
|
+
noreset: { has_argument: false },
|
8
|
+
stdin: { has_argument: false },
|
9
|
+
help: { has_argument: false }
|
10
|
+
}
|
5
11
|
|
6
|
-
|
12
|
+
switches = {}
|
13
|
+
|
14
|
+
args = ArgsParser::Args.new(options: opts, switches: switches)
|
15
|
+
|
16
|
+
if args.options[:help]
|
17
|
+
puts "RBtext ftext #{RBText.version}"
|
18
|
+
puts "Syntax: ftext [ftext] [options]"
|
19
|
+
puts "Options"
|
20
|
+
puts "--dump - Output actual escape codes"
|
21
|
+
puts "--noreset - Doesn't reset formatting when applying ftext to piped input"
|
22
|
+
puts "--stdin - Get ftext from pipe"
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
if STDIN.tty? && ARGV[0] # If no pipe input and argument provided
|
7
27
|
txt = ARGV[0].to_s
|
8
|
-
elsif STDIN.tty?
|
9
|
-
|
28
|
+
elsif !STDIN.tty? && args.options[:stdin] # If pipe input and no argument provided
|
29
|
+
ft = STDIN.gets
|
30
|
+
print R::Ft.new(ft)
|
31
|
+
exit
|
10
32
|
else
|
11
33
|
if ARGV[0]
|
12
34
|
txt = []
|
13
35
|
|
14
|
-
|
36
|
+
ftargs = args.data[0].split(',')
|
15
37
|
lines = STDIN.each_line.to_a
|
16
38
|
|
17
|
-
if
|
18
|
-
x = lines.length/
|
19
|
-
|
39
|
+
if ftargs.length < lines.length
|
40
|
+
x = lines.length/ftargs.length
|
41
|
+
ftargs = ftargs * (x+1)
|
20
42
|
end
|
21
43
|
|
22
44
|
(0..lines.length-1).each do |l|
|
23
|
-
txt << "#{"_.f:reset._" if !
|
45
|
+
txt << "#{"_.f:reset._" if !args.options[:noreset]}_.#{ftargs[l]}._"+lines[l].gsub("_", "\0004")
|
24
46
|
end
|
25
47
|
|
26
48
|
txt = txt.join
|
@@ -30,5 +52,5 @@ else
|
|
30
52
|
end
|
31
53
|
|
32
54
|
out = R::Ft.new(txt).to_s.gsub("\0004", "_")
|
33
|
-
print out.dump.sub("\"", "").reverse.sub("\"", "").reverse if
|
34
|
-
print out if !
|
55
|
+
print out.dump.sub("\"", "").reverse.sub("\"", "").reverse if args.options[:dump]
|
56
|
+
print out if !args.options[:dump]
|
data/lib/rbtext/screen.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module RBText
|
2
2
|
module Screen
|
3
|
+
@@key_press_mappings = {:escape=>"\e", :f1=>"\eOP", :f2=>"\eOQ", :f3=>"\eOR", :f4=>"\eOS", :f5=>"\e[15~", :f6=>"\e[17~", :f7=>"\e[18~", :f8=>"\e[19~", :f9=>"\e[20~", :f10=>"\e[21~", :f11=>"\e[23~", :f12=>"\e[24~", :home=>"\e[1~", :end=>"\e[4~", :insert=>"\e[2~", :delete=>"\e[3~", "~"=>"~", "!"=>"!", "@"=>"@", "#"=>"#", "$"=>"$", "%"=>"%", "^"=>"^", "&"=>"&", "*"=>"*", "("=>"(", ")"=>")", "_"=>"_", "+"=>"+", :backspace=>"\u007F", "`"=>"`", "1"=>"1", "2"=>"2", "3"=>"3", "4"=>"4", "5"=>"5", "6"=>"6", "7"=>"7", "8"=>"8", "9"=>"9", "0"=>"0", "-"=>"-", "="=>"=", :tab=>"\t", "q"=>"q", "Q"=>"Q", :"ctrl-q"=>"\u0011", "w"=>"w", "W"=>"W", :"ctrl-w"=>"\u0017", "e"=>"e", "E"=>"E", :"ctrl-e"=>"\u0005", "r"=>"r", "R"=>"R", :"ctrl-r"=>"\u0012", "t"=>"t", "T"=>"T", :"ctrl-t"=>"\u0014", "y"=>"y", "Y"=>"Y", :"ctrl-y"=>"\u0019", "u"=>"u", "U"=>"U", :"ctrl-u"=>"\u0015", "i"=>"i", "I"=>"I", :"ctrl-i"=>"\t", "o"=>"o", "O"=>"O", :"ctrl-o"=>"\u000F", "p"=>"p", "P"=>"P", :"ctrl-p"=>"\u0010", "["=>"[", "]"=>"]", "\\"=>"\\", "{"=>"{", "}"=>"}", "|"=>"|", "a"=>"a", "A"=>"A", :"ctrl-a"=>"\u0001", "s"=>"s", "S"=>"S", :"ctrl-s"=>"\u0013", "d"=>"d", "D"=>"D", :"ctrl-d"=>"\u0004", "f"=>"f", "F"=>"F", :"ctrl-f"=>"\u0006", "g"=>"g", "G"=>"G", :"ctrl-g"=>"\a", "h"=>"h", "H"=>"H", :"ctrl-h"=>"\b", "j"=>"j", "J"=>"J", :"ctrl-j"=>"\n", "k"=>"k", "K"=>"K", :"ctrl-k"=>"\v", "l"=>"l", "L"=>"L", :"ctrl-l"=>"\f", ";"=>";", "'"=>"'", ":"=>":", "\""=>"\"", :enter=>"\r", "z"=>"z", "Z"=>"Z", :"ctrl-z"=>"\u001A", "x"=>"x", "X"=>"X", :"ctrl-x"=>"\u0018", "c"=>"c", "C"=>"C", :"ctrl-c"=>"\u0003", "v"=>"v", "V"=>"V", :"ctrl-v"=>"\u0016", "b"=>"b", "B"=>"B", :"ctrl-b"=>"\u0002", "n"=>"n", "N"=>"N", :"ctrl-n"=>"\u000E", "m"=>"m", "M"=>"M", :"ctrl-m"=>"\r", ","=>",", "."=>".", "/"=>"/", "<"=>"<", ">"=>">", "?"=>"?", :up=>"\e[A", :down=>"\e[B", :left=>"\e[D", :right=>"\e[C", :pageup=>"\e[5~", :pagedown=>"\e[6~"}
|
4
|
+
|
3
5
|
def self.clear
|
4
6
|
print "\033[2J"
|
5
7
|
end
|
@@ -23,6 +25,16 @@ module RBText
|
|
23
25
|
def self.bell
|
24
26
|
print "\a"
|
25
27
|
end
|
28
|
+
|
29
|
+
def self.getch
|
30
|
+
out = STDIN.getch
|
31
|
+
|
32
|
+
while STDIN.ready? do
|
33
|
+
out << STDIN.getch
|
34
|
+
end
|
35
|
+
|
36
|
+
return @@key_press_mappings.key(out)
|
37
|
+
end
|
26
38
|
end
|
27
39
|
end
|
28
40
|
|
data/lib/rbtext.rb
CHANGED
@@ -4,11 +4,12 @@ require_relative "rbtext/formatting.rb"
|
|
4
4
|
require_relative "rbtext/ftext.rb"
|
5
5
|
require_relative "rbtext/screen.rb"
|
6
6
|
require "io/console"
|
7
|
+
require "io/wait"
|
7
8
|
|
8
9
|
module RBText
|
9
10
|
@ver_1 = 0
|
10
11
|
@ver_2 = 3
|
11
|
-
@ver_3 =
|
12
|
+
@ver_3 = 4
|
12
13
|
@ver_4 = ""
|
13
14
|
|
14
15
|
def self.version
|
metadata
CHANGED
@@ -1,29 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbtext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthias Lee
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: io-console
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
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
26
|
version: 0.5.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: io-wait
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.3.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.3.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: argparse
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.3
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.3
|
27
55
|
description: A gem for printing formatted text
|
28
56
|
email: matthias@matthiasclee.com
|
29
57
|
executables:
|
@@ -43,7 +71,7 @@ homepage: https://github.com/Matthiasclee/RBText
|
|
43
71
|
licenses:
|
44
72
|
- AGPL-3.0
|
45
73
|
metadata: {}
|
46
|
-
post_install_message:
|
74
|
+
post_install_message:
|
47
75
|
rdoc_options: []
|
48
76
|
require_paths:
|
49
77
|
- lib
|
@@ -58,8 +86,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
86
|
- !ruby/object:Gem::Version
|
59
87
|
version: '0'
|
60
88
|
requirements: []
|
61
|
-
rubygems_version: 3.
|
62
|
-
signing_key:
|
89
|
+
rubygems_version: 3.2.3
|
90
|
+
signing_key:
|
63
91
|
specification_version: 4
|
64
92
|
summary: RBText
|
65
93
|
test_files: []
|