pipetext 0.2.0 → 0.2.1

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: 0f7f0d849921eef214577fe5b3418bcda0815b9158de41079c5ded31beb06e39
4
+ data.tar.gz: 31623762e3303061e8753b07a4a44b5efbd1eda8748fb411871ca643b54dbe6f
5
5
  SHA512:
6
- metadata.gz: 84eae6ce6e8581f67281d46e34da26c427ebae034b6bfd3bfcc56f059569ad3366fdc74dd05db1cacd0ee9345fd4e28394d4be8923e3629421c2d8c2937eb507
7
- data.tar.gz: cd59a5cca225c9819947601ad39449c7fc4d70576027f09721287ad215798a965a09847f329eda0f246fd89ce5fed8bacbfccc908bb96ce5812b33cb14097ed2
6
+ metadata.gz: 500918c7d15469238f5c1f3424570a759cabd9a80dbbd8c2faec1b781ce44cbabcb1ea0c4cfdf19a6914b2f80d3d5e88136f7f0f68ec1fe1ab26eee1adb1afc0
7
+ data.tar.gz: 41a068587aed07e5c3fc360497c8296640509951e12d6d513e3cf8c89a88c43c9ea5f1517a3a373ec12eb0a470de32901b2b79575aa46c30ad0802e73807af7f
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,6 +84,7 @@ 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
90
  pipe.paint("version |c#{PipeText::VERSION}|n")
@@ -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)
@@ -202,20 +205,20 @@ module PipeText
202
205
  attributes['end_capture'] = false
203
206
  end
204
207
  if(attributes['end_capture'] == true && character =~ /[0-9]/)
205
- if(character == '0') # |10+
208
+ if(character == '0') # |10+
206
209
  if(attributes['num'] > 0)
207
210
  attributes['num'] *= 10
208
211
  end
209
- elsif(character >= '1' && character <= '9') # |1+ through |9+
212
+ elsif(character >= '1' && character <= '9') # |1+ through |9+
210
213
  if(attributes['num'] > 0)
211
214
  attributes['num'] *= 10
212
215
  end
213
216
  attributes['num'] += character.to_i
214
217
  end
215
218
  elsif(character == ')' && attributes['variable_capture'] == true && attributes['escape'] == false)
216
- if(attributes['variable'] =~ /=/) # Update
219
+ if(attributes['variable'] =~ /=/ && attributes['variable'][0] != '#') # Update
217
220
  update_variable(attributes)
218
- else # Display
221
+ else # Display
219
222
  emit_variable(new_text, attributes)
220
223
  end
221
224
  elsif(attributes['variable_capture'] == true)
@@ -337,8 +340,37 @@ module PipeText
337
340
  attributes['unicode'] = String.new
338
341
  end
339
342
 
343
+ def number?(text)
344
+ text.chars.each do |character|
345
+ if(character !~ /[0-9 ]/)
346
+ return false
347
+ end
348
+ end
349
+ return true
350
+ end
351
+
340
352
  def update_variable(attributes)
341
- if(attributes['variable'] =~ /(.*)=(.*)/)
353
+ if(attributes['variable'] =~ /(.*)\-=(.*)/)
354
+ if(!number?($2) || !number?(attributes['variables'][$1]))
355
+ attributes['variables'][$1].slice!($2)
356
+ elsif(attributes['variable'] =~ /(.*) \-= ?(.*)/ || attributes['variable'] =~ /(.*)\-= ?(.*)/)
357
+ value = attributes['variables'][$1].to_i - $2.to_i
358
+ attributes['variables'][$1] = value.to_s
359
+ end
360
+ elsif(attributes['variable'] =~ /(.*)\+=(.*)/)
361
+ if(!number?($2) || !number?(attributes['variables'][$1]))
362
+ attributes['variables'][$1] += $2
363
+ elsif(attributes['variable'] =~ /(.*) \+= ?(.*)/ || attributes['variable'] =~ /(.*)\+= ?(.*)/)
364
+ value = attributes['variables'][$1].to_i + $2.to_i
365
+ attributes['variables'][$1] = value.to_s
366
+ end
367
+ elsif(attributes['variable'] =~ /(.*) \*= ?(.*)/ || attributes['variable'] =~ /(.*)\*= ?(.*)/)
368
+ value = attributes['variables'][$1].to_i * $2.to_i
369
+ attributes['variables'][$1] = value.to_s
370
+ elsif(attributes['variable'] =~ /(.*) \/= ?(.*)/ || attributes['variable'] =~ /(.*)\/= ?(.*)/)
371
+ value = attributes['variables'][$1].to_i / $2.to_i
372
+ attributes['variables'][$1] = value.to_s
373
+ elsif(attributes['variable'] =~ /(.*) = ?(.*)/ || attributes['variable'] =~ /(.*)= ?(.*)/)
342
374
  attributes['variables'][$1] = $2
343
375
  end
344
376
  attributes['variable_capture'] = false
@@ -346,7 +378,30 @@ module PipeText
346
378
  end
347
379
 
348
380
  def emit_variable(new_text, attributes)
349
- if(attributes['variables'][attributes['variable']])
381
+ if(attributes['variable'][0] == '#') # We are manipulating attributes['num']
382
+ if(attributes['variable'][1..-1] =~ /(.*) \-= ?(.*)/ ||
383
+ attributes['variable'][1..-1] =~ /(.*)\-= ?(.*)/)
384
+ attributes['num'] = pipetext(escape_fix(attributes['variables'][$1]), attributes['box_mode'],
385
+ attributes['ampersand_mode']).to_i - $2.to_i
386
+ elsif(attributes['variable'][1..-1] =~ /(.*) \+= ?(.*)/ ||
387
+ attributes['variable'][1..-1] =~ /(.*)\+= ?(.*)/)
388
+ attributes['num'] = pipetext(escape_fix(attributes['variables'][$1]), attributes['box_mode'],
389
+ attributes['ampersand_mode']).to_i + $2.to_i
390
+ elsif(attributes['variable'][1..-1] =~ /(.*) \*= ?(.*)/ ||
391
+ attributes['variable'][1..-1] =~ /(.*)\*= ?(.*)/)
392
+ attributes['num'] = pipetext(escape_fix(attributes['variables'][$1]), attributes['box_mode'],
393
+ attributes['ampersand_mode']).to_i * $2.to_i
394
+ elsif(attributes['variable'][1..-1] =~ /(.*) \/= ?(.*)/ ||
395
+ attributes['variable'][1..-1] =~ /(.*)\/= ?(.*)/)
396
+ attributes['num'] = pipetext(escape_fix(attributes['variables'][$1]), attributes['box_mode'],
397
+ attributes['ampersand_mode']).to_i / $2.to_i
398
+ else
399
+ attributes['num'] = pipetext(escape_fix(attributes['variables'][attributes['variable'][1..-1]]),
400
+ attributes['box_mode'], attributes['ampersand_mode']).to_i
401
+ end
402
+ attributes['pipe'] = true
403
+ attributes['found'] = false
404
+ elsif(attributes['variables'][attributes['variable']])
350
405
  new_text << pipetext(escape_fix(attributes['variables'][attributes['variable']]),
351
406
  attributes['box_mode'], attributes['ampersand_mode'])
352
407
  else
@@ -4,6 +4,6 @@ module PipeText
4
4
 
5
5
  public
6
6
 
7
- VERSION = "0.2.0"
7
+ VERSION = "0.2.1"
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.1
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