pipetext 0.2.0 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0ae63046e780049e0d20b63aab5604e11dcb8c0a3906e12c4db118bd317e5fd
4
- data.tar.gz: 39edba4cb4b0b899c5692f57ee71e371254f3f2b199ee5a1207872cb89eb7ef3
3
+ metadata.gz: c79619e754a795072b47b34cf152a56f01308c347e8b7ceb9a74d2fac3a9d407
4
+ data.tar.gz: 27f7cd8b4cad98f95bd888c56b1bf9793c5c083276f947be6f69c37619e2fcfa
5
5
  SHA512:
6
- metadata.gz: 84eae6ce6e8581f67281d46e34da26c427ebae034b6bfd3bfcc56f059569ad3366fdc74dd05db1cacd0ee9345fd4e28394d4be8923e3629421c2d8c2937eb507
7
- data.tar.gz: cd59a5cca225c9819947601ad39449c7fc4d70576027f09721287ad215798a965a09847f329eda0f246fd89ce5fed8bacbfccc908bb96ce5812b33cb14097ed2
6
+ metadata.gz: cd2794bef8842d24f2a9d558adc654fd2b66de4fd242d7edcebb6731441ebdccfac57d1187d61f56b93b47b4f490a6777cea0ee8c1de7405e3373f254bc4faee
7
+ data.tar.gz: 96eb07179f6936b55f480f3860e11e4a190457b7159835666f14d2bdc53f24d65c4de393fa82c9242959281b1a3429bb30e02981b0a58ded387bff5a6815d103
data/bin/pipetext CHANGED
@@ -38,9 +38,12 @@ Add spaces to line end ||; Set line end ||]#
38
38
  Set current x,y cursor position ||[x,y] Terminal bell ||[bell]
39
39
  Move cursor up 1 line ||^ Hide cursor ||h
40
40
  Move cursor down 1 line ||v Unhide cursor ||H
41
- Move cursor forward 1 character ||> Sleep timer in seconds ||[#s]
41
+ Move cursor forward 1 character ||> Sleep timer in seconds ||[#s]
42
42
  Move cursor back 1 character ||< Sleep timer in milliseconds ||[#ms]
43
- Capture variable ||(variable name=data) Display variable ||(variable name)
43
+ Capture variable ||(variable name=data) Display variable ||(variable name)
44
+ Add to variable ||(variable name+=data) Subtract from variable ||(variable name-=data)
45
+ Multiple variable ||(variable name*=data) Divide variable ||(variable name/=data)
46
+ Copy variable to current number ||(#variable name)
44
47
 
45
48
  Emojis: https://unicode.org/emoji/charts/full-emoji-list.html
46
49
  ||[Abbreviated CLDR Short Name] |[smiling face with heart-eyes] ||[smiling face with heart-eyes] or
@@ -81,9 +84,10 @@ if(ARGV[0] == nil && STDIN.tty? == true)
81
84
  puts "pipetext '|]50Insert spaces until end (50)|W|{centered}|n|;Add After'"
82
85
  puts "pipetext 'Capture a variable named gear line|(gear line=|r|[gear]|n|-|60-|O|r|[gear]|n)|\\n" +
83
86
  "|(gear line)|\\n|(gear line)|\\n|(gear line)|\\n||(gear line) = |(gear line)'"
87
+ puts "pipetext '|(test=15)Print 10 stars: |(#test-=5)* and 20 hashes: |(#test+=5)#'"
84
88
  puts "pipetext '|10~ &r|----|O> ALL YOUR |kBASE|n |3\\~ARE|3\\~ BELONG TO US. <|----|O&n|\\n~|n'"
85
89
  puts
86
- pipe.paint("version |c#{PipeText::VERSION}|n")
90
+ pipe.paint("version |c#{PipeText::VERSION}|n\n")
87
91
  else
88
92
  if(STDIN.tty? == false)
89
93
  pipe.paint(STDIN.read)
@@ -44,6 +44,9 @@ module PipeText
44
44
  'fg' => String.new, # Needed to restore after background change
45
45
  'bg' => String.new # Needed to restore after foreground change
46
46
  }
47
+ attributes['variables']['height'] = `tput lines`.chomp
48
+ attributes['variables']['width'] = `tput cols`.chomp
49
+ return attributes
47
50
  end
48
51
 
49
52
  def pipe(text, attributes)
@@ -115,13 +118,11 @@ module PipeText
115
118
 
116
119
  def write(text, box_mode=true, ampersand_mode=false)
117
120
  fastpipetext(text, box_mode, ampersand_mode)
118
- puts
119
121
  end
120
122
 
121
123
  # Defaults to using & for background colors
122
124
  def paint(text, box_mode=true, ampersand_mode=true)
123
125
  fastpipetext(text, box_mode, ampersand_mode)
124
- puts
125
126
  end
126
127
 
127
128
  def ignored_character(character, ignored_characters)
@@ -202,20 +203,20 @@ module PipeText
202
203
  attributes['end_capture'] = false
203
204
  end
204
205
  if(attributes['end_capture'] == true && character =~ /[0-9]/)
205
- if(character == '0') # |10+
206
+ if(character == '0') # |10+
206
207
  if(attributes['num'] > 0)
207
208
  attributes['num'] *= 10
208
209
  end
209
- elsif(character >= '1' && character <= '9') # |1+ through |9+
210
+ elsif(character >= '1' && character <= '9') # |1+ through |9+
210
211
  if(attributes['num'] > 0)
211
212
  attributes['num'] *= 10
212
213
  end
213
214
  attributes['num'] += character.to_i
214
215
  end
215
216
  elsif(character == ')' && attributes['variable_capture'] == true && attributes['escape'] == false)
216
- if(attributes['variable'] =~ /=/) # Update
217
+ if(attributes['variable'] =~ /=/ && attributes['variable'][0] != '#') # Update
217
218
  update_variable(attributes)
218
- else # Display
219
+ else # Display
219
220
  emit_variable(new_text, attributes)
220
221
  end
221
222
  elsif(attributes['variable_capture'] == true)
@@ -337,8 +338,37 @@ module PipeText
337
338
  attributes['unicode'] = String.new
338
339
  end
339
340
 
341
+ def number?(text)
342
+ text.chars.each do |character|
343
+ if(character !~ /[0-9 ]/)
344
+ return false
345
+ end
346
+ end
347
+ return true
348
+ end
349
+
340
350
  def update_variable(attributes)
341
- if(attributes['variable'] =~ /(.*)=(.*)/)
351
+ if(attributes['variable'] =~ /(.*)\-=(.*)/)
352
+ if(!number?($2) || !number?(attributes['variables'][$1]))
353
+ attributes['variables'][$1].slice!($2)
354
+ elsif(attributes['variable'] =~ /(.*) \-= ?(.*)/ || attributes['variable'] =~ /(.*)\-= ?(.*)/)
355
+ value = attributes['variables'][$1].to_i - $2.to_i
356
+ attributes['variables'][$1] = value.to_s
357
+ end
358
+ elsif(attributes['variable'] =~ /(.*)\+=(.*)/)
359
+ if(!number?($2) || !number?(attributes['variables'][$1]))
360
+ attributes['variables'][$1] += $2
361
+ elsif(attributes['variable'] =~ /(.*) \+= ?(.*)/ || attributes['variable'] =~ /(.*)\+= ?(.*)/)
362
+ value = attributes['variables'][$1].to_i + $2.to_i
363
+ attributes['variables'][$1] = value.to_s
364
+ end
365
+ elsif(attributes['variable'] =~ /(.*) \*= ?(.*)/ || attributes['variable'] =~ /(.*)\*= ?(.*)/)
366
+ value = attributes['variables'][$1].to_i * $2.to_i
367
+ attributes['variables'][$1] = value.to_s
368
+ elsif(attributes['variable'] =~ /(.*) \/= ?(.*)/ || attributes['variable'] =~ /(.*)\/= ?(.*)/)
369
+ value = attributes['variables'][$1].to_i / $2.to_i
370
+ attributes['variables'][$1] = value.to_s
371
+ elsif(attributes['variable'] =~ /(.*) = ?(.*)/ || attributes['variable'] =~ /(.*)= ?(.*)/)
342
372
  attributes['variables'][$1] = $2
343
373
  end
344
374
  attributes['variable_capture'] = false
@@ -346,7 +376,30 @@ module PipeText
346
376
  end
347
377
 
348
378
  def emit_variable(new_text, attributes)
349
- if(attributes['variables'][attributes['variable']])
379
+ if(attributes['variable'][0] == '#') # We are manipulating attributes['num']
380
+ if(attributes['variable'][1..-1] =~ /(.*) \-= ?(.*)/ ||
381
+ attributes['variable'][1..-1] =~ /(.*)\-= ?(.*)/)
382
+ attributes['num'] = pipetext(escape_fix(attributes['variables'][$1]), attributes['box_mode'],
383
+ attributes['ampersand_mode']).to_i - $2.to_i
384
+ elsif(attributes['variable'][1..-1] =~ /(.*) \+= ?(.*)/ ||
385
+ attributes['variable'][1..-1] =~ /(.*)\+= ?(.*)/)
386
+ attributes['num'] = pipetext(escape_fix(attributes['variables'][$1]), attributes['box_mode'],
387
+ attributes['ampersand_mode']).to_i + $2.to_i
388
+ elsif(attributes['variable'][1..-1] =~ /(.*) \*= ?(.*)/ ||
389
+ attributes['variable'][1..-1] =~ /(.*)\*= ?(.*)/)
390
+ attributes['num'] = pipetext(escape_fix(attributes['variables'][$1]), attributes['box_mode'],
391
+ attributes['ampersand_mode']).to_i * $2.to_i
392
+ elsif(attributes['variable'][1..-1] =~ /(.*) \/= ?(.*)/ ||
393
+ attributes['variable'][1..-1] =~ /(.*)\/= ?(.*)/)
394
+ attributes['num'] = pipetext(escape_fix(attributes['variables'][$1]), attributes['box_mode'],
395
+ attributes['ampersand_mode']).to_i / $2.to_i
396
+ else
397
+ attributes['num'] = pipetext(escape_fix(attributes['variables'][attributes['variable'][1..-1]]),
398
+ attributes['box_mode'], attributes['ampersand_mode']).to_i
399
+ end
400
+ attributes['pipe'] = true
401
+ attributes['found'] = false
402
+ elsif(attributes['variables'][attributes['variable']])
350
403
  new_text << pipetext(escape_fix(attributes['variables'][attributes['variable']]),
351
404
  attributes['box_mode'], attributes['ampersand_mode'])
352
405
  else
@@ -4,6 +4,6 @@ module PipeText
4
4
 
5
5
  public
6
6
 
7
- VERSION = "0.2.0"
7
+ VERSION = "0.2.2"
8
8
  end
9
9
 
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.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minaswan Nakamoto
@@ -36,9 +36,12 @@ description: "== Easily add colors, boxes, repetitions and emojis to your termin
36
36
  \ Set line end |]#\n Set current x,y cursor position |[x,y] Terminal
37
37
  bell |[bell]\n Move cursor up 1 line |^ Hide cursor |h\n
38
38
  \ Move cursor down 1 line |v Unhide cursor |H\n Move cursor
39
- forward 1 character |> Sleep timer in seconds |[#s]\n Move cursor back
40
- 1 character |< Sleep timer in milliseconds |[#ms]\n Capture variable
41
- \ |(variable name=data) Display variable |(variable name)\n\n---\n Emojis:
39
+ forward 1 character |> Sleep timer in seconds |[#s]\n Move cursor
40
+ back 1 character |< Sleep timer in milliseconds |[#ms]\n Capture
41
+ variable |(variable name=data) Display variable |(variable name)\n
42
+ \ Add to variable |(variable name+=data) Subtract from variable |(variable
43
+ name-=data)\n Multiple variable |(variable name*=data) Divide variable |(variable
44
+ name/=data)\n Copy variable to current number |(#variable name)\n\n---\n Emojis:
42
45
  \ https://unicode.org/emoji/charts/full-emoji-list.html\n |[Abbreviated
43
46
  CLDR Short Name] \U0001F60D |[smiling face with heart-eyes] or\n ⚙ |[gear]
44
47
  \ \U0001F4A4 |[zzz] \U0001F468 |[man] \U0001F60D |[sm f w he e]\n ✔ |U2714