digi_moji 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +75 -0
- data/Rakefile +7 -0
- data/bin/digi_moji +5 -0
- data/digi_moji.gemspec +25 -0
- data/lib/digi_moji.rb +52 -0
- data/lib/digi_moji/char.rb +792 -0
- data/lib/digi_moji/cli.rb +89 -0
- data/lib/digi_moji/version.rb +3 -0
- data/spec/char_spec.rb +123 -0
- data/spec/cli_spec.rb +35 -0
- data/spec/digi_moji_spec.rb +72 -0
- data/spec/spec_helper.rb +3 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c6cac885fd44251e38ed8fea8c2782dc49cb7b4c
|
4
|
+
data.tar.gz: 19ae1b1c342e1974c64af59d13205ddf7fe87305
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 431111951d4fa8336b001d7ada67b141f5b25746a708516752b68be460832616846709540a7e8eea81acb607a96137760177ae75b257ed3c6567f6b117488e4e
|
7
|
+
data.tar.gz: 86d328f8fc24ca053935b5163c49cc2b70ad229164b70b62844bdb926f198314cdb9740bc5a44ef6612246e637c5b588951aa537106e724906f52ec468962ae4
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 kyoendo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# DigiMoji
|
2
|
+
|
3
|
+
5x7 digital color words on your terminal.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'digi_moji'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install digi_moji
|
18
|
+
|
19
|
+
## Usage in your terminal
|
20
|
+
|
21
|
+
### new command
|
22
|
+
|
23
|
+
Try `digi_moji new` command with words:
|
24
|
+
|
25
|
+
% digi_moji new RUBY
|
26
|
+
|
27
|
+
![sample1](https://github.com/melborne/digi_moji/raw/screenshot/sample1.png)
|
28
|
+
|
29
|
+
% digi_moji new RUBY --fg=bg_red --bg=bg_yellow
|
30
|
+
|
31
|
+
![sample2](https://github.com/melborne/digi_moji/raw/screenshot/sample2.png)
|
32
|
+
|
33
|
+
% digi_moji new RUBY --fg=red --bg=red_blink --cell='R'
|
34
|
+
|
35
|
+
![sample3](https://github.com/melborne/digi_moji/raw/screenshot/sample3.gif)
|
36
|
+
|
37
|
+
### time command
|
38
|
+
|
39
|
+
`digi_moji time` outputs current time:
|
40
|
+
|
41
|
+
![sample4](https://github.com/melborne/digi_moji/raw/screenshot/sample4.gif)
|
42
|
+
|
43
|
+
### timer command
|
44
|
+
|
45
|
+
`digi_moji timer` outputs count down timer:
|
46
|
+
|
47
|
+
![sample5](https://github.com/melborne/digi_moji/raw/screenshot/sample5.gif)
|
48
|
+
|
49
|
+
`digi_moji help` for more info.
|
50
|
+
|
51
|
+
## Usage as ruby script
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
require 'digi_moji'
|
55
|
+
|
56
|
+
str = DigiMoji::String.new("HE", fg:'bg_green', bg:'bg_yellow')
|
57
|
+
|
58
|
+
puts str
|
59
|
+
puts
|
60
|
+
puts str + "LLO!"
|
61
|
+
puts
|
62
|
+
puts str.join("LP!", fg:'bg_red')
|
63
|
+
```
|
64
|
+
|
65
|
+
Output:
|
66
|
+
|
67
|
+
![sample6](https://github.com/melborne/digi_moji/raw/screenshot/sample6.png)
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
|
71
|
+
1. Fork it ( https://github.com/[my-github-username]/digi_moji/fork )
|
72
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
73
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
74
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
75
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/digi_moji
ADDED
data/digi_moji.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'digi_moji/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "digi_moji"
|
8
|
+
spec.version = DigiMoji::VERSION
|
9
|
+
spec.authors = ["kyoendo"]
|
10
|
+
spec.email = ["postagie@gmail.com"]
|
11
|
+
spec.summary = %q{5x7 digital color words on your terminal.}
|
12
|
+
spec.homepage = "https://github.com/melborne/digi_moji"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "colcolor"
|
21
|
+
spec.add_dependency "thor"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
end
|
data/lib/digi_moji.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require "digi_moji/version"
|
2
|
+
require "digi_moji/char"
|
3
|
+
require "digi_moji/cli"
|
4
|
+
|
5
|
+
require "colcolor"
|
6
|
+
|
7
|
+
module DigiMoji
|
8
|
+
class String
|
9
|
+
attr_accessor :string
|
10
|
+
attr_reader :raw_string
|
11
|
+
def initialize(str, space:1, **opts)
|
12
|
+
@raw_string = str.to_s
|
13
|
+
@space = space
|
14
|
+
@opts = opts
|
15
|
+
@bg = opts[:bg]
|
16
|
+
# @string holds a sequence of Char objects.
|
17
|
+
@string = str2chars(str, opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
head, *rest = @string
|
22
|
+
joint = (" " * @space).colco(@bg, regexp:/./)
|
23
|
+
head.zip(*rest).map { |e| e.join(joint) }.join("\n")
|
24
|
+
end
|
25
|
+
|
26
|
+
def +(other, **opts)
|
27
|
+
opts = @opts.merge(opts)
|
28
|
+
other =
|
29
|
+
case other
|
30
|
+
when ::String, ::Symbol
|
31
|
+
str2chars(other, opts)
|
32
|
+
when DigiMoji::String
|
33
|
+
other.string
|
34
|
+
else
|
35
|
+
raise "'other' should be a string, symbol or DigiString object."
|
36
|
+
end
|
37
|
+
self.dup.tap { |s| s.string += other }
|
38
|
+
end
|
39
|
+
alias :join :+
|
40
|
+
|
41
|
+
def <<(other, **opts)
|
42
|
+
@string = (self + other).string
|
43
|
+
@raw_string += other.respond_to?(:raw_string) ? other.raw_string : other.to_s
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def str2chars(str, opts)
|
49
|
+
str.to_s.each_char.map { |chr| Char[chr.intern, opts] }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,792 @@
|
|
1
|
+
module DigiMoji
|
2
|
+
class Char
|
3
|
+
CHAR_WIDTH = 5
|
4
|
+
CHAR_HEIGHT = 7
|
5
|
+
A =
|
6
|
+
%w(f t t t f
|
7
|
+
t f f f t
|
8
|
+
t f f f t
|
9
|
+
t t t t t
|
10
|
+
t f f f t
|
11
|
+
t f f f t
|
12
|
+
t f f f t)
|
13
|
+
B =
|
14
|
+
%w(t t t t f
|
15
|
+
t f f f t
|
16
|
+
t f f f t
|
17
|
+
t t t t f
|
18
|
+
t f f f t
|
19
|
+
t f f f t
|
20
|
+
t t t t f)
|
21
|
+
C =
|
22
|
+
%w(f t t t t
|
23
|
+
t f f f f
|
24
|
+
t f f f f
|
25
|
+
t f f f f
|
26
|
+
t f f f f
|
27
|
+
t f f f f
|
28
|
+
f t t t t)
|
29
|
+
D =
|
30
|
+
%w(t t t t f
|
31
|
+
t f f f t
|
32
|
+
t f f f t
|
33
|
+
t f f f t
|
34
|
+
t f f f t
|
35
|
+
t f f f t
|
36
|
+
t t t t f)
|
37
|
+
E =
|
38
|
+
%w(t t t t t
|
39
|
+
t f f f f
|
40
|
+
t f f f f
|
41
|
+
t t t t f
|
42
|
+
t f f f f
|
43
|
+
t f f f f
|
44
|
+
t t t t t)
|
45
|
+
F =
|
46
|
+
%w(t t t t t
|
47
|
+
t f f f f
|
48
|
+
t f f f f
|
49
|
+
t t t t f
|
50
|
+
t f f f f
|
51
|
+
t f f f f
|
52
|
+
t f f f f)
|
53
|
+
G =
|
54
|
+
%w(f t t t t
|
55
|
+
t f f f f
|
56
|
+
t f f f f
|
57
|
+
t f t t t
|
58
|
+
t f f f t
|
59
|
+
t f f f t
|
60
|
+
f t t t f)
|
61
|
+
H =
|
62
|
+
%w(t f f f t
|
63
|
+
t f f f t
|
64
|
+
t f f f t
|
65
|
+
t t t t t
|
66
|
+
t f f f t
|
67
|
+
t f f f t
|
68
|
+
t f f f t)
|
69
|
+
I =
|
70
|
+
%w(t t t t t
|
71
|
+
f f t f f
|
72
|
+
f f t f f
|
73
|
+
f f t f f
|
74
|
+
f f t f f
|
75
|
+
f f t f f
|
76
|
+
t t t t t)
|
77
|
+
J =
|
78
|
+
%w(f f f t f
|
79
|
+
f f f t f
|
80
|
+
f f f t f
|
81
|
+
f f f t f
|
82
|
+
t f f t f
|
83
|
+
t f f t f
|
84
|
+
f t t f f)
|
85
|
+
K =
|
86
|
+
%w(t f f f t
|
87
|
+
t f f t f
|
88
|
+
t f t f f
|
89
|
+
t t f f f
|
90
|
+
t f t f f
|
91
|
+
t f f t f
|
92
|
+
t f f f t)
|
93
|
+
L =
|
94
|
+
%w(t f f f f
|
95
|
+
t f f f f
|
96
|
+
t f f f f
|
97
|
+
t f f f f
|
98
|
+
t f f f f
|
99
|
+
t f f f f
|
100
|
+
t t t t t)
|
101
|
+
M =
|
102
|
+
%w(t f f f t
|
103
|
+
t t f t t
|
104
|
+
t f t f t
|
105
|
+
t f t f t
|
106
|
+
t f f f t
|
107
|
+
t f f f t
|
108
|
+
t f f f t)
|
109
|
+
N =
|
110
|
+
%w(t f f f t
|
111
|
+
t f f f t
|
112
|
+
t t f f t
|
113
|
+
t f t f t
|
114
|
+
t f f t t
|
115
|
+
t f f f t
|
116
|
+
t f f f t)
|
117
|
+
O =
|
118
|
+
%w(f t t t f
|
119
|
+
t f f f t
|
120
|
+
t f f f t
|
121
|
+
t f f f t
|
122
|
+
t f f f t
|
123
|
+
t f f f t
|
124
|
+
f t t t f)
|
125
|
+
P =
|
126
|
+
%w(t t t t f
|
127
|
+
t f f f t
|
128
|
+
t f f f t
|
129
|
+
t t t t f
|
130
|
+
t f f f f
|
131
|
+
t f f f f
|
132
|
+
t f f f f)
|
133
|
+
Q =
|
134
|
+
%w(f t t t f
|
135
|
+
t f f f t
|
136
|
+
t f f f t
|
137
|
+
t f f f t
|
138
|
+
t f t f t
|
139
|
+
t f f t t
|
140
|
+
f t t t t)
|
141
|
+
R =
|
142
|
+
%w(t t t t f
|
143
|
+
t f f f t
|
144
|
+
t f f f t
|
145
|
+
t t t t f
|
146
|
+
t f t f f
|
147
|
+
t f f t f
|
148
|
+
t f f f t)
|
149
|
+
S =
|
150
|
+
%w(f t t t t
|
151
|
+
t f f f f
|
152
|
+
t f f f f
|
153
|
+
t t t t f
|
154
|
+
f f f f t
|
155
|
+
f f f f t
|
156
|
+
t t t t f)
|
157
|
+
T =
|
158
|
+
%w(t t t t t
|
159
|
+
f f t f f
|
160
|
+
f f t f f
|
161
|
+
f f t f f
|
162
|
+
f f t f f
|
163
|
+
f f t f f
|
164
|
+
f f t f f)
|
165
|
+
U =
|
166
|
+
%w(t f f f t
|
167
|
+
t f f f t
|
168
|
+
t f f f t
|
169
|
+
t f f f t
|
170
|
+
t f f f t
|
171
|
+
t f f f t
|
172
|
+
f t t t f)
|
173
|
+
V =
|
174
|
+
%w(t f f f t
|
175
|
+
t f f f t
|
176
|
+
t f f f t
|
177
|
+
t f f f t
|
178
|
+
t f f f t
|
179
|
+
f t f t f
|
180
|
+
f f t f f)
|
181
|
+
W =
|
182
|
+
%w(t f f f t
|
183
|
+
t f f f t
|
184
|
+
t f f f t
|
185
|
+
t f t f t
|
186
|
+
t f t f t
|
187
|
+
t t f t t
|
188
|
+
t f f f t)
|
189
|
+
X =
|
190
|
+
%w(t f f f t
|
191
|
+
t f f f t
|
192
|
+
f t f t f
|
193
|
+
f f t f f
|
194
|
+
f t f t f
|
195
|
+
t f f f t
|
196
|
+
t f f f t)
|
197
|
+
Y =
|
198
|
+
%w(t f f f t
|
199
|
+
t f f f t
|
200
|
+
f t f t f
|
201
|
+
f f t f f
|
202
|
+
f f t f f
|
203
|
+
f f t f f
|
204
|
+
f f t f f)
|
205
|
+
Z =
|
206
|
+
%w(t t t t t
|
207
|
+
f f f f t
|
208
|
+
f f f t f
|
209
|
+
f f t f f
|
210
|
+
f t f f f
|
211
|
+
t f f f f
|
212
|
+
t t t t t)
|
213
|
+
LA =
|
214
|
+
%w(f f f f f
|
215
|
+
f f f f f
|
216
|
+
t t t f f
|
217
|
+
f f f t f
|
218
|
+
f t t t f
|
219
|
+
t f f t f
|
220
|
+
f t t t f)
|
221
|
+
LB =
|
222
|
+
%w(t f f f f
|
223
|
+
t f f f f
|
224
|
+
t f f f f
|
225
|
+
t t t f f
|
226
|
+
t f f t f
|
227
|
+
t f f t f
|
228
|
+
t t t f f)
|
229
|
+
LC =
|
230
|
+
%w(f f f f f
|
231
|
+
f f f f f
|
232
|
+
f t t f f
|
233
|
+
t f f t f
|
234
|
+
t f f f f
|
235
|
+
t f f t f
|
236
|
+
f t t f f)
|
237
|
+
LD =
|
238
|
+
%w(f f f t f
|
239
|
+
f f f t f
|
240
|
+
f f f t f
|
241
|
+
f t t t f
|
242
|
+
t f f t f
|
243
|
+
t f f t f
|
244
|
+
f t t t f)
|
245
|
+
LE =
|
246
|
+
%w(f f f f f
|
247
|
+
f f f f f
|
248
|
+
f t t f f
|
249
|
+
t f f t f
|
250
|
+
t t t t f
|
251
|
+
t f f f f
|
252
|
+
f t t t f)
|
253
|
+
LF =
|
254
|
+
%w(f f t t f
|
255
|
+
f t f f f
|
256
|
+
t t t t f
|
257
|
+
f t f f f
|
258
|
+
f t f f f
|
259
|
+
f t f f f
|
260
|
+
f t f f f)
|
261
|
+
LG =
|
262
|
+
%w(f f f f f
|
263
|
+
f t t t f
|
264
|
+
t f f t f
|
265
|
+
t f f t f
|
266
|
+
f t t t f
|
267
|
+
f f f t f
|
268
|
+
t t t f f)
|
269
|
+
LH =
|
270
|
+
%w(t f f f f
|
271
|
+
t f f f f
|
272
|
+
t f f f f
|
273
|
+
t t t f f
|
274
|
+
t f f t f
|
275
|
+
t f f t f
|
276
|
+
t f f t f)
|
277
|
+
LI =
|
278
|
+
%w(f f t f f
|
279
|
+
f f f f f
|
280
|
+
f f t f f
|
281
|
+
f f t f f
|
282
|
+
f f t f f
|
283
|
+
f f t f f
|
284
|
+
f f t f f)
|
285
|
+
LJ =
|
286
|
+
%w(f f t f f
|
287
|
+
f f f f f
|
288
|
+
f f t f f
|
289
|
+
f f t f f
|
290
|
+
f f t f f
|
291
|
+
f f t f f
|
292
|
+
t t f f f)
|
293
|
+
LK =
|
294
|
+
%w(f f f f f
|
295
|
+
t f f t f
|
296
|
+
t f t f f
|
297
|
+
t t f f f
|
298
|
+
t f t f f
|
299
|
+
t f f t f
|
300
|
+
f f f f f)
|
301
|
+
LL =
|
302
|
+
%w(f f t f f
|
303
|
+
f f t f f
|
304
|
+
f f t f f
|
305
|
+
f f t f f
|
306
|
+
f f t f f
|
307
|
+
f f t f f
|
308
|
+
f f t f f)
|
309
|
+
LM =
|
310
|
+
%w(f f f f f
|
311
|
+
t t t t f
|
312
|
+
t f t f t
|
313
|
+
t f t f t
|
314
|
+
t f t f t
|
315
|
+
t f t f t
|
316
|
+
f f f f f)
|
317
|
+
LN =
|
318
|
+
%w(f f f f f
|
319
|
+
t t t f f
|
320
|
+
t f f t f
|
321
|
+
t f f t f
|
322
|
+
t f f t f
|
323
|
+
t f f t f
|
324
|
+
f f f f f)
|
325
|
+
LO =
|
326
|
+
%w(f f f f f
|
327
|
+
f t t f f
|
328
|
+
t f f t f
|
329
|
+
t f f t f
|
330
|
+
t f f t f
|
331
|
+
f t t f f
|
332
|
+
f f f f f)
|
333
|
+
LP =
|
334
|
+
%w(f f f f f
|
335
|
+
t t t f f
|
336
|
+
t f f t f
|
337
|
+
t f f t f
|
338
|
+
t t t f f
|
339
|
+
t f f f f
|
340
|
+
t f f f f)
|
341
|
+
LQ =
|
342
|
+
%w(f f f f f
|
343
|
+
f t t t f
|
344
|
+
t f f t f
|
345
|
+
t f f t f
|
346
|
+
f t t t f
|
347
|
+
f f f t f
|
348
|
+
f f f t f)
|
349
|
+
LR =
|
350
|
+
%w(f f f f f
|
351
|
+
f t t t f
|
352
|
+
t f f f f
|
353
|
+
t f f f f
|
354
|
+
t f f f f
|
355
|
+
t f f f f
|
356
|
+
t f f f f)
|
357
|
+
LS =
|
358
|
+
%w(f f f f f
|
359
|
+
f t t f f
|
360
|
+
t f f t f
|
361
|
+
f t f f f
|
362
|
+
f f t f f
|
363
|
+
t f f t f
|
364
|
+
f t t f f)
|
365
|
+
LT =
|
366
|
+
%w(f t f f f
|
367
|
+
f t f f f
|
368
|
+
t t t t f
|
369
|
+
f t f f f
|
370
|
+
f t f f f
|
371
|
+
f t f f f
|
372
|
+
f t t t f)
|
373
|
+
LU =
|
374
|
+
%w(f f f f f
|
375
|
+
t f f t f
|
376
|
+
t f f t f
|
377
|
+
t f f t f
|
378
|
+
t f f t f
|
379
|
+
f t t t f
|
380
|
+
f f f f f)
|
381
|
+
LV =
|
382
|
+
%w(f f f f f
|
383
|
+
t f f f t
|
384
|
+
t f f f t
|
385
|
+
t f f f t
|
386
|
+
f t f t f
|
387
|
+
f f t f f
|
388
|
+
f f f f f)
|
389
|
+
LW =
|
390
|
+
%w(f f f f f
|
391
|
+
t f f f t
|
392
|
+
t f f f t
|
393
|
+
t f t f t
|
394
|
+
f t t t f
|
395
|
+
t f t f t
|
396
|
+
f f f f f)
|
397
|
+
LX =
|
398
|
+
%w(f f f f f
|
399
|
+
t f f t f
|
400
|
+
t f f t f
|
401
|
+
f t t f f
|
402
|
+
t f f t f
|
403
|
+
t f f t f
|
404
|
+
f f f f f)
|
405
|
+
LY =
|
406
|
+
%w(f f f f f
|
407
|
+
t f f t f
|
408
|
+
t f f t f
|
409
|
+
f t t t f
|
410
|
+
f f f t f
|
411
|
+
t t t f f
|
412
|
+
f f f f f)
|
413
|
+
LZ =
|
414
|
+
%w(f f f f f
|
415
|
+
t t t t f
|
416
|
+
f f t f f
|
417
|
+
f t f f f
|
418
|
+
t f f f f
|
419
|
+
t t t t f
|
420
|
+
f f f f f)
|
421
|
+
ONE =
|
422
|
+
%w(f f t f f
|
423
|
+
f t t f f
|
424
|
+
f f t f f
|
425
|
+
f f t f f
|
426
|
+
f f t f f
|
427
|
+
f f t f f
|
428
|
+
t t t t t)
|
429
|
+
TWO =
|
430
|
+
%w(f t t t f
|
431
|
+
t f f f t
|
432
|
+
f f f f t
|
433
|
+
f f f t f
|
434
|
+
f f t f f
|
435
|
+
f t f f f
|
436
|
+
t t t t t)
|
437
|
+
THREE =
|
438
|
+
%w(f t t t f
|
439
|
+
t f f f t
|
440
|
+
f f f f t
|
441
|
+
f f t t f
|
442
|
+
f f f f t
|
443
|
+
t f f f t
|
444
|
+
f t t t f)
|
445
|
+
FOUR =
|
446
|
+
%w(f f f t f
|
447
|
+
f f t t f
|
448
|
+
f t f t f
|
449
|
+
t f f t f
|
450
|
+
t t t t t
|
451
|
+
f f f t f
|
452
|
+
f f f t f)
|
453
|
+
FIVE =
|
454
|
+
%w(t t t t t
|
455
|
+
t f f f f
|
456
|
+
t t t t f
|
457
|
+
f f f f t
|
458
|
+
f f f f t
|
459
|
+
t f f f t
|
460
|
+
f t t t f)
|
461
|
+
SIX =
|
462
|
+
%w(f t t t f
|
463
|
+
t f f f t
|
464
|
+
t f f f f
|
465
|
+
t t t t f
|
466
|
+
t f f f t
|
467
|
+
t f f f t
|
468
|
+
f t t t f)
|
469
|
+
SEVEN =
|
470
|
+
%w(t t t t t
|
471
|
+
f f f f t
|
472
|
+
f f f t f
|
473
|
+
f f t f f
|
474
|
+
f f t f f
|
475
|
+
f f t f f
|
476
|
+
f f t f f)
|
477
|
+
EIGHT =
|
478
|
+
%w(f t t t f
|
479
|
+
t f f f t
|
480
|
+
t f f f t
|
481
|
+
f t t t f
|
482
|
+
t f f f t
|
483
|
+
t f f f t
|
484
|
+
f t t t f)
|
485
|
+
NINE =
|
486
|
+
%w(f t t t f
|
487
|
+
t f f f t
|
488
|
+
t f f f t
|
489
|
+
f t t t t
|
490
|
+
f f f f t
|
491
|
+
t f f f t
|
492
|
+
f t t t f)
|
493
|
+
ZERO =
|
494
|
+
%w(f t t t f
|
495
|
+
t f f f t
|
496
|
+
t f f f t
|
497
|
+
t f f f t
|
498
|
+
t f f f t
|
499
|
+
t f f f t
|
500
|
+
f t t t f)
|
501
|
+
SPACE =
|
502
|
+
%w(f f f f f
|
503
|
+
f f f f f
|
504
|
+
f f f f f
|
505
|
+
f f f f f
|
506
|
+
f f f f f
|
507
|
+
f f f f f
|
508
|
+
f f f f f)
|
509
|
+
EXCLAMATION =
|
510
|
+
%w(f f t f f
|
511
|
+
f f t f f
|
512
|
+
f f t f f
|
513
|
+
f f t f f
|
514
|
+
f f t f f
|
515
|
+
f f f f f
|
516
|
+
f f t f f)
|
517
|
+
QUESTION =
|
518
|
+
%w(f t t t f
|
519
|
+
t f f f t
|
520
|
+
t f f f t
|
521
|
+
f f f t f
|
522
|
+
f f t f f
|
523
|
+
f f f f f
|
524
|
+
f f t f f)
|
525
|
+
ARROW_RIGHT =
|
526
|
+
%w(f f f f f
|
527
|
+
f f t f f
|
528
|
+
f f f t f
|
529
|
+
t t t t t
|
530
|
+
f f f t f
|
531
|
+
f f t f f
|
532
|
+
f f f f f)
|
533
|
+
ARROW_LEFT =
|
534
|
+
%w(f f f f f
|
535
|
+
f f t f f
|
536
|
+
f t f f f
|
537
|
+
t t t t t
|
538
|
+
f t f f f
|
539
|
+
f f t f f
|
540
|
+
f f f f f)
|
541
|
+
ARROW_UP =
|
542
|
+
%w(f f t f f
|
543
|
+
f t t t f
|
544
|
+
t f t f t
|
545
|
+
f f t f f
|
546
|
+
f f t f f
|
547
|
+
f f t f f
|
548
|
+
f f t f f)
|
549
|
+
ARROW_DOWN =
|
550
|
+
%w(f f t f f
|
551
|
+
f f t f f
|
552
|
+
f f t f f
|
553
|
+
f f t f f
|
554
|
+
t f t f t
|
555
|
+
f t t t f
|
556
|
+
f f t f f)
|
557
|
+
UNDERSCORE =
|
558
|
+
%w(f f f f f
|
559
|
+
f f f f f
|
560
|
+
f f f f f
|
561
|
+
f f f f f
|
562
|
+
f f f f f
|
563
|
+
f f f f f
|
564
|
+
t t t t t)
|
565
|
+
DASH =
|
566
|
+
%w(f f f f f
|
567
|
+
f f f f f
|
568
|
+
f f f f f
|
569
|
+
f t t t f
|
570
|
+
f f f f f
|
571
|
+
f f f f f
|
572
|
+
f f f f f)
|
573
|
+
BRACKET_LEFT =
|
574
|
+
%w(f f f t f
|
575
|
+
f f t f f
|
576
|
+
f f t f f
|
577
|
+
f f t f f
|
578
|
+
f f t f f
|
579
|
+
f f t f f
|
580
|
+
f f f t f)
|
581
|
+
BRACKET_RIGHT =
|
582
|
+
%w(f t f f f
|
583
|
+
f f t f f
|
584
|
+
f f t f f
|
585
|
+
f f t f f
|
586
|
+
f f t f f
|
587
|
+
f f t f f
|
588
|
+
f t f f f)
|
589
|
+
PERIOD =
|
590
|
+
%w(f f f f f
|
591
|
+
f f f f f
|
592
|
+
f f f f f
|
593
|
+
f f f f f
|
594
|
+
f t t f f
|
595
|
+
f t t f f)
|
596
|
+
COMMA =
|
597
|
+
%w(f f f f f
|
598
|
+
f f f f f
|
599
|
+
f f f f f
|
600
|
+
f f f f f
|
601
|
+
f t t f f
|
602
|
+
f f t f f
|
603
|
+
f t f f f)
|
604
|
+
COLON =
|
605
|
+
%w(f f f f f
|
606
|
+
f t t f f
|
607
|
+
f t t f f
|
608
|
+
f f f f f
|
609
|
+
f t t f f
|
610
|
+
f t t f f
|
611
|
+
f f f f f)
|
612
|
+
SEMI_COLON =
|
613
|
+
%w(f f f f f
|
614
|
+
f t t f f
|
615
|
+
f t t f f
|
616
|
+
f f f f f
|
617
|
+
f t t f f
|
618
|
+
f f t f f
|
619
|
+
f t f f f)
|
620
|
+
APOSTROPHE =
|
621
|
+
%w(f t t f f
|
622
|
+
f f t f f
|
623
|
+
f t f f f
|
624
|
+
f f f f f
|
625
|
+
f f f f f
|
626
|
+
f f f f f
|
627
|
+
f f f f f)
|
628
|
+
DOLLAR =
|
629
|
+
%w(f t t t f
|
630
|
+
t f t f t
|
631
|
+
t f t f f
|
632
|
+
f t t t f
|
633
|
+
f f t f t
|
634
|
+
t f t f t
|
635
|
+
f t t t f)
|
636
|
+
EURO =
|
637
|
+
%w(f f t t f
|
638
|
+
f t f f t
|
639
|
+
f t f f f
|
640
|
+
t t t t f
|
641
|
+
f t f f f
|
642
|
+
f t f f t
|
643
|
+
f f t t f)
|
644
|
+
SLASH =
|
645
|
+
%w(f f f f f
|
646
|
+
f f f f t
|
647
|
+
f f f t f
|
648
|
+
f f t f f
|
649
|
+
f t f f f
|
650
|
+
t f f f f
|
651
|
+
f f f f f)
|
652
|
+
PLUS =
|
653
|
+
%w(f f f f f
|
654
|
+
f f t f f
|
655
|
+
f f t f f
|
656
|
+
t t t t t
|
657
|
+
f f t f f
|
658
|
+
f f t f f
|
659
|
+
f f f f f)
|
660
|
+
MINUS =
|
661
|
+
%w(f f f f f
|
662
|
+
f f f f f
|
663
|
+
f f f f f
|
664
|
+
t t t t t
|
665
|
+
f f f f f
|
666
|
+
f f f f f
|
667
|
+
f f f f f)
|
668
|
+
TIMES =
|
669
|
+
%w(f f f f f
|
670
|
+
t f f f t
|
671
|
+
f t f t f
|
672
|
+
f f t f f
|
673
|
+
f t f t f
|
674
|
+
t f f f t
|
675
|
+
f f f f f)
|
676
|
+
DIVIDE =
|
677
|
+
%w(f f f f f
|
678
|
+
f f t f f
|
679
|
+
f f f f f
|
680
|
+
t t t t t
|
681
|
+
f f f f f
|
682
|
+
f f t f f
|
683
|
+
f f f f f)
|
684
|
+
EQUAL =
|
685
|
+
%w(f f f f f
|
686
|
+
f f f f f
|
687
|
+
t t t t t
|
688
|
+
f f f f f
|
689
|
+
t t t t t
|
690
|
+
f f f f f
|
691
|
+
f f f f f)
|
692
|
+
PERCENT =
|
693
|
+
%w(f f f f f
|
694
|
+
t f f f t
|
695
|
+
f f f t f
|
696
|
+
f f t f f
|
697
|
+
f t f f f
|
698
|
+
t f f f t
|
699
|
+
f f f f f)
|
700
|
+
SHAPE =
|
701
|
+
%w(f f f f f
|
702
|
+
f t f t f
|
703
|
+
t t t t t
|
704
|
+
f t f t f
|
705
|
+
t t t t t
|
706
|
+
f t f t f
|
707
|
+
f f f f f)
|
708
|
+
AND =
|
709
|
+
%w(f t t f f
|
710
|
+
t f f t f
|
711
|
+
t f t f f
|
712
|
+
f t f f f
|
713
|
+
t f t f t
|
714
|
+
t f f t f
|
715
|
+
f t t f t)
|
716
|
+
GREATER =
|
717
|
+
%w(f f f f f
|
718
|
+
f t f f f
|
719
|
+
f f t f f
|
720
|
+
f f f t f
|
721
|
+
f f t f f
|
722
|
+
f t f f f
|
723
|
+
f f f f f)
|
724
|
+
LESS =
|
725
|
+
%w(f f f f f
|
726
|
+
f f f t f
|
727
|
+
f f t f f
|
728
|
+
f t f f f
|
729
|
+
f f t f f
|
730
|
+
f f f t f
|
731
|
+
f f f f f)
|
732
|
+
AT =
|
733
|
+
%w(f t t t f
|
734
|
+
t f f f t
|
735
|
+
t f t t t
|
736
|
+
t f t f t
|
737
|
+
t f t t t
|
738
|
+
t f f f f
|
739
|
+
f t t t t)
|
740
|
+
BLOCK =
|
741
|
+
%w(t t t t t
|
742
|
+
t t t t t
|
743
|
+
t t t t t
|
744
|
+
t t t t t
|
745
|
+
t t t t t
|
746
|
+
t t t t t
|
747
|
+
t t t t t)
|
748
|
+
|
749
|
+
ALPHABETS = [*'A'..'Z', *'a'..'z'].zip([*'A'..'Z', *'LA'..'LZ']).to_h
|
750
|
+
|
751
|
+
MISC = '0123456789 !?_-().,:;$+-*/=%\'#&><@'.split(//).zip(%i(ZERO ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE SPACE EXCLAMATION QUESTION UNDERSCORE DASH BRACKET_LEFT BRACKET_RIGHT PERIOD COMMA COLON SEMI_COLON DOLLAR PLUS MINUS TIMES DIVIDE EQUAL PERCENT APOSTROPHE SHAPE AND GREATER LESS AT)).to_h
|
752
|
+
|
753
|
+
class NotImplementError < StandardError; end
|
754
|
+
class InvalidCharForm < StandardError; end
|
755
|
+
class InUseCharError < StandardError; end
|
756
|
+
|
757
|
+
def self.build_char_map(char)
|
758
|
+
unless char_map = @special_chars[char.to_s]
|
759
|
+
char = ALPHABETS[char.to_s] || MISC[char.to_s] || raise(NotImplementError)
|
760
|
+
char_map = const_get(char)
|
761
|
+
end
|
762
|
+
char_map.map { |cell| cell == 't' }
|
763
|
+
.each_slice(char_map.size/7).to_a
|
764
|
+
end
|
765
|
+
|
766
|
+
def self.[](char, fg: :bg_white, bg: nil, cell:" ", width:2)
|
767
|
+
cells = cell * width * CHAR_WIDTH
|
768
|
+
build_char_map(char).map do |row|
|
769
|
+
pattern = row.map { |col| [col ? fg : bg] * width }.flatten
|
770
|
+
cells.colco(*pattern, regexp:/./)
|
771
|
+
end
|
772
|
+
end
|
773
|
+
|
774
|
+
@special_chars = { 'å' => BLOCK }
|
775
|
+
|
776
|
+
def self.register(char, map)
|
777
|
+
validate_char_form(char, map)
|
778
|
+
@special_chars[char] = map
|
779
|
+
end
|
780
|
+
|
781
|
+
def self.validate_char_form(char, map)
|
782
|
+
if @special_chars[char.to_s]
|
783
|
+
raise InUseCharError, "'#{char}' is in use"
|
784
|
+
end
|
785
|
+
if map.size != (CHAR_WIDTH * CHAR_HEIGHT) ||
|
786
|
+
!map.all? { |c| %w(t f).include? c }
|
787
|
+
raise InvalidCharForm, "Passed map has invalid form"
|
788
|
+
end
|
789
|
+
true
|
790
|
+
end
|
791
|
+
end
|
792
|
+
end
|