pipetext 0.2.4 → 0.2.6
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/bin/pipetext +1 -1
- data/lib/pipetext/pipetext.rb +27 -5
- data/lib/pipetext/version.rb +1 -1
- 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: 1a49c4a1db0607a10805da620311a16d0686fb29b5405d1edb329ac9eb3ba05c
|
|
4
|
+
data.tar.gz: 761a90f52750d0c933996426770a4482d3edc8fa41890dfaa008cfcb118131cc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b3635c1e4e698ef6e22694b29afcd7190f1eed0372e8c6f5647b8423fdab781c8f00aa95e6485edb9d465e7ec760073ca3d3af930ab5f34dac872a45e2a7a991
|
|
7
|
+
data.tar.gz: 7e4f5b0b2a47d81103e605d0f9ecd3a72e1135d0901797d47db9fd272ffaa94633bd1bdb8a85ce9287768ac93dab02250663e89c47b7c40d78c8fa4b8943c47c
|
data/bin/pipetext
CHANGED
|
@@ -90,7 +90,7 @@ if(ARGV[0] == nil && STDIN.tty? == true)
|
|
|
90
90
|
puts "pipetext '|10~ &r|----|O> ALL YOUR |kBASE|n |3\\~ARE|3\\~ BELONG TO US. <|----|O&n|\\n~|n'"
|
|
91
91
|
puts
|
|
92
92
|
puts "Set your bash prompt:"
|
|
93
|
-
puts "PS1=$(pipetext '
|
|
93
|
+
puts "PS1=$(pipetext '|$|g\\u|n@|g\\h|n:|g\\w|n$ ')"
|
|
94
94
|
puts
|
|
95
95
|
pipe.paint("version |c#{PipeText::VERSION}|n\n")
|
|
96
96
|
else
|
data/lib/pipetext/pipetext.rb
CHANGED
|
@@ -168,21 +168,43 @@ module PipeText
|
|
|
168
168
|
|
|
169
169
|
# This is not entirely accurate because of emojis, which we assume are 2 characters
|
|
170
170
|
def printable_length(string)
|
|
171
|
+
if(string == "")
|
|
172
|
+
return 0
|
|
173
|
+
end
|
|
171
174
|
length = 0
|
|
172
175
|
escape = false
|
|
176
|
+
wide = false
|
|
177
|
+
wide_count = 0
|
|
173
178
|
string.chars.each do |character|
|
|
174
|
-
if(character.ord == 27)
|
|
179
|
+
if(character[0].ord == 27)
|
|
175
180
|
escape = true
|
|
176
|
-
elsif(character.ord
|
|
177
|
-
|
|
181
|
+
elsif(character[0].ord == 226 && wide == false)
|
|
182
|
+
wide = true
|
|
183
|
+
elsif(character[0].ord == 240 && wide == false)
|
|
184
|
+
wide = true
|
|
185
|
+
elsif(character[0].ord >= 32)
|
|
186
|
+
if(escape == true && character[0].ord == 109)
|
|
178
187
|
escape = false
|
|
179
|
-
elsif(character.ord > 9600) # ~ Emoji / Unicode - double wide characters start
|
|
188
|
+
elsif(character[0].ord > 9600) # ~ Emoji / Unicode - double wide characters start
|
|
180
189
|
length += 2
|
|
181
|
-
elsif(escape == false)
|
|
190
|
+
elsif(escape == false && wide == false)
|
|
191
|
+
length += 1
|
|
192
|
+
elsif(wide == true)
|
|
193
|
+
wide_count += 1
|
|
194
|
+
end
|
|
195
|
+
if(wide == true && wide_count >= 2)
|
|
196
|
+
if(character[0].ord == 147)
|
|
197
|
+
length += 1
|
|
198
|
+
end
|
|
182
199
|
length += 1
|
|
200
|
+
wide = false
|
|
201
|
+
wide_count = 0
|
|
183
202
|
end
|
|
184
203
|
end
|
|
185
204
|
end
|
|
205
|
+
if(wide == true && wide_count > 0)
|
|
206
|
+
length += 1
|
|
207
|
+
end
|
|
186
208
|
return length
|
|
187
209
|
end
|
|
188
210
|
|
data/lib/pipetext/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pipetext
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Minaswan Nakamoto
|
|
@@ -16,7 +16,7 @@ description: "== Easily add colors, boxes, repetitions and emojis to your termin
|
|
|
16
16
|
print(string)\n write('|Y' + string + '|n')\n end\n end\n \n printer
|
|
17
17
|
= YellowPrinter.new\n printer.print('This is yellow')\n \n The gem includes a
|
|
18
18
|
command line interface too:\n \n > pipetext\n\n > pipetext '|Ccyan|n'\n\n Easily
|
|
19
|
-
set your bash prompt colors using pipetext:\n\n > PS1=$(pipetext '
|
|
19
|
+
set your bash prompt colors using pipetext:\n\n > PS1=$(pipetext '|$|g\\u|n@|g\\h|n:|g\\w|n$
|
|
20
20
|
')\n\n Works with files:\n\n > pipetext <filename>\n\n Works with pipes too:\n\n
|
|
21
21
|
\ > echo '|RRed test |u1f49c|n' | pipetext\n\n---\n | pipe || & ampersand &&
|
|
22
22
|
\ Toggle (&) background color mode |&\n smoke |s white |W black text
|