rutui 0.2 → 0.3.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.
- data/{lib/rutui.rb → rutui.rb} +21 -49
- metadata +5 -4
data/{lib/rutui.rb → rutui.rb}
RENAMED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
2
3
|
# Generated one file script of rutui
|
3
4
|
# This file is commandless and stripped down
|
4
5
|
# For full source please visit:
|
@@ -7,7 +8,7 @@
|
|
7
8
|
# Author: Roman Pramberger (roman.pramberger@gmail.com)
|
8
9
|
# License: MIT
|
9
10
|
#
|
10
|
-
#
|
11
|
+
# Mon Jul 1 13:54:29 CEST 2013
|
11
12
|
#
|
12
13
|
class RuTui
|
13
14
|
class Color
|
@@ -51,7 +52,7 @@ class Utils
|
|
51
52
|
ensure
|
52
53
|
system("stty -raw echo")
|
53
54
|
end
|
54
|
-
return str
|
55
|
+
return str.ord
|
55
56
|
end
|
56
57
|
# Hides the cursor
|
57
58
|
def self.init
|
@@ -137,14 +138,10 @@ class BaseObject
|
|
137
138
|
@obj[x][y] if !@obj[x].nil? and !@obj[x][y].nil?
|
138
139
|
end
|
139
140
|
# "special" each methods for objects
|
140
|
-
def each
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
row.each_with_index do |pixel,col_count|
|
145
|
-
yield row_count, col_count, pixel
|
146
|
-
end
|
147
|
-
end
|
141
|
+
def each
|
142
|
+
@obj.each_with_index do |row,row_count|
|
143
|
+
row.each_with_index do |pixel,col_count|
|
144
|
+
yield row_count, col_count, pixel
|
148
145
|
end
|
149
146
|
end
|
150
147
|
end
|
@@ -208,7 +205,7 @@ class Line < BaseObject
|
|
208
205
|
@pixel = options[:pixel]
|
209
206
|
@endpixel = options[:endpixel]
|
210
207
|
@pixel = Theme.get(:border) if @pixel.nil?
|
211
|
-
|
208
|
+
create
|
212
209
|
end
|
213
210
|
# Create Line
|
214
211
|
# can be recalled any time on attribute changes
|
@@ -337,17 +334,9 @@ class Screen
|
|
337
334
|
def add_static object
|
338
335
|
@statics << object if !@statics.include? object
|
339
336
|
object.each do |ri,ci,pixel|
|
340
|
-
@smap[object.y+ri][object.x+ci] = pixel if !pixel.nil? and object.y+ri
|
337
|
+
@smap[object.y+ri][object.x+ci] = pixel if !pixel.nil? and object.y+ri > 0 and object.y+ci > 0
|
341
338
|
end
|
342
339
|
end
|
343
|
-
# Set pixel on map
|
344
|
-
def set_pixel x,y,val
|
345
|
-
@smap[y][x] = val
|
346
|
-
end
|
347
|
-
# Get pixel from map
|
348
|
-
def get_pixel x,y
|
349
|
-
@smap[y][x]
|
350
|
-
end
|
351
340
|
# add dynamic object
|
352
341
|
def add object
|
353
342
|
@objects << object
|
@@ -444,28 +433,11 @@ class ScreenManager
|
|
444
433
|
ScreenManager.draw if autodraw
|
445
434
|
end
|
446
435
|
end
|
447
|
-
def self.draw_loop options
|
448
|
-
autofit = options[:autofit]
|
449
|
-
while true
|
450
|
-
key = Utils.gets
|
451
|
-
yield
|
452
|
-
ScreenManager.refit if @autofit
|
453
|
-
ScreenManager.draw
|
454
|
-
end
|
455
|
-
end
|
456
|
-
def self.input_loop options
|
457
|
-
Thread.new {
|
458
|
-
while true
|
459
|
-
key = Utils.gets
|
460
|
-
yield key
|
461
|
-
end
|
462
|
-
}
|
463
|
-
end
|
464
436
|
end
|
465
437
|
class Figlet < BaseObject
|
466
438
|
attr_accessor :text, :rainbow, :font, :colors
|
467
|
-
# Figlet font: '!" #$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz[|]'
|
468
|
-
@@chars = '!!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz[|]'.split("")
|
439
|
+
# Figlet font: '!" #$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz[|]~ÄÖÜäöüß'
|
440
|
+
@@chars = '!!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz[|]~ÄÖÜäöüß'.split("")
|
469
441
|
@@rainbow = nil
|
470
442
|
@@fonts = {}
|
471
443
|
# Initialize (see above)
|
@@ -480,7 +452,7 @@ class Figlet < BaseObject
|
|
480
452
|
@space = options[:space]
|
481
453
|
@space = 0 if @space.nil?
|
482
454
|
@colors = options[:colors]
|
483
|
-
@colors = [Pixel.new(Theme.get(:textcolor))] if @colors.nil?
|
455
|
+
@colors = [Pixel.new(Theme.get(:textcolor), Theme.get(:background).bg, Theme.get(:background).symbol)] if @colors.nil?
|
484
456
|
create
|
485
457
|
end
|
486
458
|
|
@@ -491,10 +463,7 @@ class Figlet < BaseObject
|
|
491
463
|
@@fonts[@font]['n'].size.times do
|
492
464
|
obj << []
|
493
465
|
end
|
494
|
-
p obj
|
495
466
|
current = 0
|
496
|
-
p @@fonts[@font]['F']
|
497
|
-
p @@fonts[@font]['L']
|
498
467
|
count = 0
|
499
468
|
@text.each_byte do |c|
|
500
469
|
if @@chars.include? c.chr
|
@@ -519,21 +488,21 @@ class Figlet < BaseObject
|
|
519
488
|
@@fonts[@font]['n'].size.times do |ri|
|
520
489
|
@space.times do
|
521
490
|
if @rainbow
|
522
|
-
obj[ri] << Pixel.new(@@rainbow[current], @colors[0].bg,
|
491
|
+
obj[ri] << Pixel.new(@@rainbow[current], @colors[0].bg,Theme.get(:background).symbol)
|
523
492
|
else
|
524
|
-
obj[ri] << Pixel.new(@colors[current].fg,@colors[current].bg,
|
493
|
+
obj[ri] << Pixel.new(@colors[current].fg,@colors[current].bg,Theme.get(:background).symbol)
|
525
494
|
end
|
526
495
|
end
|
527
496
|
end
|
528
497
|
end
|
529
498
|
# SPace
|
530
|
-
|
499
|
+
else
|
531
500
|
@@fonts[@font]['n'].size.times do |ri|
|
532
501
|
3.times do
|
533
502
|
if @rainbow
|
534
|
-
obj[ri] << Pixel.new(@@rainbow[current], @colors[0].bg,
|
503
|
+
obj[ri] << Pixel.new(@@rainbow[current], @colors[0].bg, Theme.get(:background).symbol)
|
535
504
|
else
|
536
|
-
obj[ri] << Pixel.new(@colors[current].fg,@colors[current].bg,
|
505
|
+
obj[ri] << Pixel.new(@colors[current].fg,@colors[current].bg, Theme.get(:background).symbol)
|
537
506
|
end
|
538
507
|
end
|
539
508
|
end
|
@@ -595,6 +564,9 @@ end
|
|
595
564
|
class Axx < BaseObject
|
596
565
|
def initialize options
|
597
566
|
@file = options[:file]
|
567
|
+
@x = options[:x]
|
568
|
+
@y = options[:y]
|
569
|
+
|
598
570
|
return if @file.nil?
|
599
571
|
return if !File.exists? @file
|
600
572
|
@img = File.open(@file).read
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rutui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-07-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Create Pure Ruby textbased interfaces of all kinds (Unix only)
|
15
15
|
email: roman.pramberger@gmail.com
|
@@ -17,7 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
-
|
20
|
+
- rutui.rb
|
21
21
|
homepage: http://rubygems.org/gems/rutui
|
22
22
|
licenses: []
|
23
23
|
post_install_message:
|
@@ -38,8 +38,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
40
|
rubyforge_project:
|
41
|
-
rubygems_version: 1.8.
|
41
|
+
rubygems_version: 1.8.24
|
42
42
|
signing_key:
|
43
43
|
specification_version: 3
|
44
44
|
summary: RUby Textbased User Interface
|
45
45
|
test_files: []
|
46
|
+
has_rdoc:
|