vedeu 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +5 -0
  3. data/README.md +34 -0
  4. data/deps.md +13 -13
  5. data/lib/vedeu.rb +1 -1
  6. data/lib/vedeu/instrumentation.rb +1 -1
  7. data/lib/vedeu/models/geometry.rb +76 -0
  8. data/lib/vedeu/models/interface.rb +9 -21
  9. data/lib/vedeu/models/stream.rb +16 -4
  10. data/lib/vedeu/output/clear_interface.rb +4 -4
  11. data/lib/vedeu/{support/translator.rb → output/colour_translator.rb} +1 -1
  12. data/lib/vedeu/output/erb_parser.rb +11 -0
  13. data/lib/vedeu/output/raw_parser.rb +9 -1
  14. data/lib/vedeu/output/render_interface.rb +3 -3
  15. data/lib/vedeu/support/esc.rb +8 -6
  16. data/lib/vedeu/support/helpers.rb +39 -18
  17. data/lib/vedeu/support/interface_template.rb +42 -19
  18. data/test/lib/vedeu/models/composition_test.rb +27 -21
  19. data/test/lib/vedeu/models/geometry_test.rb +183 -0
  20. data/test/lib/vedeu/models/interface_test.rb +26 -59
  21. data/test/lib/vedeu/models/stream_test.rb +57 -7
  22. data/test/lib/vedeu/output/clear_interface_test.rb +8 -4
  23. data/test/lib/vedeu/{support/translator_test.rb → output/colour_translator_test.rb} +8 -8
  24. data/test/lib/vedeu/output/erb_parser_test.rb +158 -70
  25. data/test/lib/vedeu/output/render_interface_test.rb +4 -3
  26. data/test/lib/vedeu/support/esc_test.rb +10 -2
  27. data/test/lib/vedeu/support/helpers_test.rb +11 -4
  28. data/test/lib/vedeu/support/interface_template_test.rb +58 -34
  29. data/test/support/colours.rb +2 -2
  30. data/test/support/erb/line.erb +4 -0
  31. data/test/support/erb/line_2x.erb +10 -0
  32. data/test/support/erb/line_foreground.erb +4 -0
  33. data/test/support/erb/line_foreground_2x.erb +5 -0
  34. data/vedeu.gemspec +2 -1
  35. metadata +30 -8
  36. data/lib/vedeu/support/geometry.rb +0 -172
  37. data/test/lib/vedeu/support/geometry_test.rb +0 -408
@@ -11,9 +11,10 @@ module Vedeu
11
11
  it 'returns the content for the interface' do
12
12
  interface = Interface.new({
13
13
  name: '.call',
14
- width: 32,
15
- height: 3,
16
- lines: 'RenderInterface.call',
14
+ geometry: {
15
+ width: 32,
16
+ height: 3,
17
+ },
17
18
  lines: [
18
19
  {
19
20
  streams: [{ text: 'this is the first' }]
@@ -5,7 +5,7 @@ module Vedeu
5
5
  describe Esc do
6
6
  describe '.background_colour' do
7
7
  it 'returns an escape sequence' do
8
- Esc.background_colour.must_equal("\e[48;5;16m")
8
+ Esc.background_colour('#000000').must_equal("\e[48;5;16m")
9
9
  end
10
10
 
11
11
  it 'returns an empty string when the value is empty' do
@@ -15,7 +15,7 @@ module Vedeu
15
15
 
16
16
  describe '.foreground_colour' do
17
17
  it 'returns an escape sequence' do
18
- Esc.foreground_colour.must_equal("\e[38;5;231m")
18
+ Esc.foreground_colour('#ffffff').must_equal("\e[38;5;231m")
19
19
  end
20
20
 
21
21
  it 'returns an empty string when the value is empty' do
@@ -38,6 +38,10 @@ module Vedeu
38
38
  Esc.string.must_equal('')
39
39
  end
40
40
 
41
+ it 'returns an escape sequence when the style is bg_reset' do
42
+ Esc.string('bg_reset').must_equal("\e[48;2;49m")
43
+ end
44
+
41
45
  it 'returns an escape sequence when the style is blink' do
42
46
  Esc.string('blink').must_equal("\e[5m")
43
47
  end
@@ -62,6 +66,10 @@ module Vedeu
62
66
  Esc.string('colour_reset').must_equal("\e[38;2;39m\e[48;2;49m")
63
67
  end
64
68
 
69
+ it 'returns an escape sequence when the style is fg_reset' do
70
+ Esc.string('fg_reset').must_equal("\e[38;2;39m")
71
+ end
72
+
65
73
  it 'returns an escape sequence when the style is hide_cursor' do
66
74
  Esc.string('hide_cursor').must_equal("\e[?25l")
67
75
  end
@@ -7,6 +7,12 @@ module Vedeu
7
7
  end
8
8
 
9
9
  describe Helpers do
10
+ describe '.line' do
11
+ it 'returns the block with line returns removed' do
12
+ skip
13
+ end
14
+ end
15
+
10
16
  describe '.foreground' do
11
17
  it 'returns an escape sequence for the specified CSS foreground' do
12
18
  TestHelpers.new.foreground('#a5f500').must_equal("\e[38;5;148m")
@@ -16,7 +22,7 @@ module Vedeu
16
22
 
17
23
  it 'returns an escape sequence plus interpolation when a block is given' do
18
24
  TestHelpers.new.foreground('#a5f500') { 'Some text' }
19
- .must_equal("\e[38;5;148mSome text")
25
+ .must_equal("\e[38;5;148mSome text\e[38;2;39m")
20
26
  end
21
27
  end
22
28
 
@@ -29,7 +35,7 @@ module Vedeu
29
35
 
30
36
  it 'returns an escape sequence plus interpolation when a block is given' do
31
37
  TestHelpers.new.background('#2f2f2f') { 'Some text' }
32
- .must_equal("\e[48;5;16mSome text")
38
+ .must_equal("\e[48;5;16mSome text\e[48;2;49m")
33
39
  end
34
40
  end
35
41
 
@@ -40,7 +46,8 @@ module Vedeu
40
46
  end
41
47
 
42
48
  it 'returns an escape sequence plus interpolation when a block is given' do
43
- TestHelpers.new.colour({ background: '#2f2f2f', foreground: '#a5ff00' }) { 'Some text' }.must_equal("\e[38;5;154m\e[48;5;16mSome text")
49
+ TestHelpers.new.colour({ background: '#2f2f2f', foreground: '#a5ff00' }) { 'Some text' }
50
+ .must_equal("\e[38;5;154m\e[48;5;16mSome text\e[38;2;39m\e[48;2;49m")
44
51
  end
45
52
  end
46
53
 
@@ -61,7 +68,7 @@ module Vedeu
61
68
 
62
69
  it 'returns an escape sequence plus interpolation when a block is given' do
63
70
  TestHelpers.new.style('bold', 'underline') { 'Some text' }
64
- .must_equal("\e[1m\e[4mSome text")
71
+ .must_equal("\e[1m\e[4mSome text\e[0m")
65
72
  end
66
73
  end
67
74
  end
@@ -14,36 +14,6 @@ module Vedeu
14
14
  interface.must_be_instance_of(Interface)
15
15
  end
16
16
 
17
- it 'overrides x and y when centred is true' do
18
- IO.console.stub :winsize, [10, 40] do
19
- interface = InterfaceTemplate.save('widget') do
20
- colour foreground: '#ff0000', background: '#5f0000'
21
- cursor false
22
- centred true
23
- width 10
24
- height 2
25
- x 5
26
- y 5
27
- end
28
- interface.x.must_equal(15)
29
- interface.y.must_equal(4)
30
- end
31
- end
32
-
33
- it 'uses x and y when centred is false' do
34
- interface = InterfaceTemplate.save('widget') do
35
- colour foreground: '#ff0000', background: '#5f0000'
36
- cursor false
37
- centred false
38
- width 10
39
- height 2
40
- x 5
41
- y 5
42
- end
43
- interface.x.must_equal(5)
44
- interface.y.must_equal(5)
45
- end
46
-
47
17
  it 'allows interfaces to share behaviour' do
48
18
  IO.console.stub :winsize, [10, 40] do
49
19
  main = InterfaceTemplate.save('main') do
@@ -63,10 +33,64 @@ module Vedeu
63
33
  x main.geometry.left
64
34
  end
65
35
 
66
- main.x.must_equal(15)
67
- main.y.must_equal(4)
68
- status.x.must_equal(15)
69
- status.y.must_equal(5)
36
+ main.geometry.left.must_equal(15)
37
+ main.geometry.top.must_equal(4)
38
+ status.geometry.left.must_equal(15)
39
+ status.geometry.top.must_equal(5)
40
+ end
41
+ end
42
+
43
+ describe '#x' do
44
+ interface = InterfaceTemplate.new('widget')
45
+
46
+ it 'raises an exception when the value is out of bounds' do
47
+ proc { interface.x(0) }.must_raise(XOutOfBounds)
48
+ end
49
+
50
+ it 'raises an exception when the value is out of bounds' do
51
+ proc { interface.x(999) }.must_raise(XOutOfBounds)
52
+ end
53
+ end
54
+
55
+ describe '#y' do
56
+ interface = InterfaceTemplate.new('widget')
57
+
58
+ it 'raises an exception when the value is out of bounds' do
59
+ proc { interface.y(0) }.must_raise(YOutOfBounds)
60
+ end
61
+
62
+ it 'raises an exception when the value is out of bounds' do
63
+ proc { interface.y(999) }.must_raise(YOutOfBounds)
64
+ end
65
+ end
66
+
67
+ describe '#width' do
68
+ interface = InterfaceTemplate.new('widget')
69
+
70
+ it 'raises an exception when the value is out of bounds' do
71
+ proc { interface.width(0) }.must_raise(InvalidWidth)
72
+ end
73
+
74
+ it 'raises an exception when the value is out of bounds' do
75
+ proc { interface.width(999) }.must_raise(InvalidWidth)
76
+ end
77
+ end
78
+
79
+ describe '#height' do
80
+ interface = InterfaceTemplate.new('widget')
81
+
82
+ it 'raises an exception when the value is out of bounds' do
83
+ proc { interface.height(0) }.must_raise(InvalidHeight)
84
+ end
85
+
86
+ it 'raises an exception when the value is out of bounds' do
87
+ proc { interface.height(999) }.must_raise(InvalidHeight)
88
+ end
89
+ end
90
+
91
+ describe '#centred' do
92
+ it 'should hav a valid spec, please write one.' do
93
+ skip
70
94
  end
71
95
  end
72
96
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative '../../lib/vedeu/support/translator'
2
+ require_relative '../../lib/vedeu/output/colour_translator'
3
3
 
4
4
  values = ["00", "5f", "87", "af", "d7", "ff"]
5
5
  codes = {}
@@ -8,7 +8,7 @@ values.each do |r|
8
8
  values.each do |g|
9
9
  values.each do |b|
10
10
  value = ["#", r, g, b].join
11
- trans = Vedeu::Translator.translate(value)
11
+ trans = Vedeu::ColourTranslator.translate(value)
12
12
  codes[trans] = value
13
13
  end
14
14
  end
@@ -0,0 +1,4 @@
1
+ <%- line do -%>
2
+ This is line one.
3
+ This is line two.
4
+ <%- end -%>
@@ -0,0 +1,10 @@
1
+ <%- lines do -%>
2
+ <%- line do -%>
3
+ This is line one.
4
+ This is line two.
5
+ <%- end -%>
6
+ <%- line do -%>
7
+ This is line three.
8
+ This is line four.
9
+ <%- end -%>
10
+ <%- end -%>
@@ -0,0 +1,4 @@
1
+ <%- line do -%>
2
+ <%= foreground('#ffff00') { "This is line one." } -%>
3
+ This is line two.
4
+ <%- end -%>
@@ -0,0 +1,5 @@
1
+ <%- line do -%>
2
+ <%= foreground('#ffff00') { "This is line one." } -%>
3
+ <%= foreground('#ff0000') { "This is line two." } -%>
4
+ This is line three.
5
+ <%- end -%>
data/vedeu.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'vedeu'
7
- spec.version = '0.1.3'
7
+ spec.version = '0.1.4'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = %q{A terminal case of wonderland.}
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.add_development_dependency 'bundler', '~> 1.6'
20
20
  spec.add_development_dependency 'guard', '2.6.1'
21
+ spec.add_development_dependency 'guard-bundler', '2.0.0'
21
22
  spec.add_development_dependency 'guard-minitest', '2.3.1'
22
23
  spec.add_development_dependency 'minitest', '5.4.0'
23
24
  spec.add_development_dependency 'minitest-reporters', '1.0.5'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-03 00:00:00.000000000 Z
11
+ date: 2014-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.6.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard-bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: guard-minitest
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -181,11 +195,13 @@ files:
181
195
  - lib/vedeu/models/attributes/stream_collection.rb
182
196
  - lib/vedeu/models/colour.rb
183
197
  - lib/vedeu/models/composition.rb
198
+ - lib/vedeu/models/geometry.rb
184
199
  - lib/vedeu/models/interface.rb
185
200
  - lib/vedeu/models/line.rb
186
201
  - lib/vedeu/models/stream.rb
187
202
  - lib/vedeu/models/style.rb
188
203
  - lib/vedeu/output/clear_interface.rb
204
+ - lib/vedeu/output/colour_translator.rb
189
205
  - lib/vedeu/output/erb_parser.rb
190
206
  - lib/vedeu/output/json_parser.rb
191
207
  - lib/vedeu/output/menu_parser.rb
@@ -195,7 +211,6 @@ files:
195
211
  - lib/vedeu/output/view.rb
196
212
  - lib/vedeu/support/esc.rb
197
213
  - lib/vedeu/support/events.rb
198
- - lib/vedeu/support/geometry.rb
199
214
  - lib/vedeu/support/helpers.rb
200
215
  - lib/vedeu/support/input.rb
201
216
  - lib/vedeu/support/interface_store.rb
@@ -203,7 +218,6 @@ files:
203
218
  - lib/vedeu/support/menu.rb
204
219
  - lib/vedeu/support/queue.rb
205
220
  - lib/vedeu/support/terminal.rb
206
- - lib/vedeu/support/translator.rb
207
221
  - lib/vedeu/support/wordwrap.rb
208
222
  - logs/.gitkeep
209
223
  - test/lib/vedeu/application_test.rb
@@ -215,11 +229,13 @@ files:
215
229
  - test/lib/vedeu/models/attributes/stream_collection_test.rb
216
230
  - test/lib/vedeu/models/colour_test.rb
217
231
  - test/lib/vedeu/models/composition_test.rb
232
+ - test/lib/vedeu/models/geometry_test.rb
218
233
  - test/lib/vedeu/models/interface_test.rb
219
234
  - test/lib/vedeu/models/line_test.rb
220
235
  - test/lib/vedeu/models/stream_test.rb
221
236
  - test/lib/vedeu/models/style_test.rb
222
237
  - test/lib/vedeu/output/clear_interface_test.rb
238
+ - test/lib/vedeu/output/colour_translator_test.rb
223
239
  - test/lib/vedeu/output/erb_parser_test.rb
224
240
  - test/lib/vedeu/output/json_parser_test.rb
225
241
  - test/lib/vedeu/output/menu_parser_test.rb
@@ -229,7 +245,6 @@ files:
229
245
  - test/lib/vedeu/output/view_test.rb
230
246
  - test/lib/vedeu/support/esc_test.rb
231
247
  - test/lib/vedeu/support/events_test.rb
232
- - test/lib/vedeu/support/geometry_test.rb
233
248
  - test/lib/vedeu/support/helpers_test.rb
234
249
  - test/lib/vedeu/support/input_test.rb
235
250
  - test/lib/vedeu/support/interface_store_test.rb
@@ -237,7 +252,6 @@ files:
237
252
  - test/lib/vedeu/support/menu_test.rb
238
253
  - test/lib/vedeu/support/queue_test.rb
239
254
  - test/lib/vedeu/support/terminal_test.rb
240
- - test/lib/vedeu/support/translator_test.rb
241
255
  - test/lib/vedeu/support/wordwrap_test.rb
242
256
  - test/lib/vedeu_test.rb
243
257
  - test/stats.sh
@@ -246,6 +260,10 @@ files:
246
260
  - test/support/dummy_interface.rb
247
261
  - test/support/erb/colour.erb
248
262
  - test/support/erb/colour_style.erb
263
+ - test/support/erb/line.erb
264
+ - test/support/erb/line_2x.erb
265
+ - test/support/erb/line_foreground.erb
266
+ - test/support/erb/line_foreground_2x.erb
249
267
  - test/support/erb/style.erb
250
268
  - test/support/json/int1_lin1_str1.json
251
269
  - test/support/json/int1_lin1_str3.json
@@ -294,11 +312,13 @@ test_files:
294
312
  - test/lib/vedeu/models/attributes/stream_collection_test.rb
295
313
  - test/lib/vedeu/models/colour_test.rb
296
314
  - test/lib/vedeu/models/composition_test.rb
315
+ - test/lib/vedeu/models/geometry_test.rb
297
316
  - test/lib/vedeu/models/interface_test.rb
298
317
  - test/lib/vedeu/models/line_test.rb
299
318
  - test/lib/vedeu/models/stream_test.rb
300
319
  - test/lib/vedeu/models/style_test.rb
301
320
  - test/lib/vedeu/output/clear_interface_test.rb
321
+ - test/lib/vedeu/output/colour_translator_test.rb
302
322
  - test/lib/vedeu/output/erb_parser_test.rb
303
323
  - test/lib/vedeu/output/json_parser_test.rb
304
324
  - test/lib/vedeu/output/menu_parser_test.rb
@@ -308,7 +328,6 @@ test_files:
308
328
  - test/lib/vedeu/output/view_test.rb
309
329
  - test/lib/vedeu/support/esc_test.rb
310
330
  - test/lib/vedeu/support/events_test.rb
311
- - test/lib/vedeu/support/geometry_test.rb
312
331
  - test/lib/vedeu/support/helpers_test.rb
313
332
  - test/lib/vedeu/support/input_test.rb
314
333
  - test/lib/vedeu/support/interface_store_test.rb
@@ -316,7 +335,6 @@ test_files:
316
335
  - test/lib/vedeu/support/menu_test.rb
317
336
  - test/lib/vedeu/support/queue_test.rb
318
337
  - test/lib/vedeu/support/terminal_test.rb
319
- - test/lib/vedeu/support/translator_test.rb
320
338
  - test/lib/vedeu/support/wordwrap_test.rb
321
339
  - test/lib/vedeu_test.rb
322
340
  - test/stats.sh
@@ -325,6 +343,10 @@ test_files:
325
343
  - test/support/dummy_interface.rb
326
344
  - test/support/erb/colour.erb
327
345
  - test/support/erb/colour_style.erb
346
+ - test/support/erb/line.erb
347
+ - test/support/erb/line_2x.erb
348
+ - test/support/erb/line_foreground.erb
349
+ - test/support/erb/line_foreground_2x.erb
328
350
  - test/support/erb/style.erb
329
351
  - test/support/json/int1_lin1_str1.json
330
352
  - test/support/json/int1_lin1_str3.json
@@ -1,172 +0,0 @@
1
- require 'vedeu/support/esc'
2
- require 'vedeu/support/terminal'
3
-
4
- module Vedeu
5
- InvalidHeight = Class.new(StandardError)
6
- InvalidWidth = Class.new(StandardError)
7
- OutOfBoundsError = Class.new(StandardError)
8
-
9
- class Geometry
10
- def initialize(attrs = {})
11
- @attrs = attrs
12
- end
13
-
14
- def origin(index = 0)
15
- Esc.set_position(virtual_y(index), virtual_x)
16
- end
17
-
18
- def terminal_height
19
- @terminal_height ||= attrs_terminal_height
20
- end
21
-
22
- def height
23
- @height ||= attrs_height
24
- end
25
-
26
- def y
27
- @y ||= attrs_y
28
- end
29
-
30
- def x
31
- @x ||= attrs_x
32
- end
33
-
34
- def terminal_width
35
- @terminal_width ||= attrs_terminal_width
36
- end
37
-
38
- def width
39
- @width ||= attrs_width
40
- end
41
-
42
- def centred
43
- @centred ||= attrs_centred
44
- end
45
-
46
- def centre
47
- [(terminal_height / 2), (terminal_width / 2)]
48
- end
49
-
50
- def centre_y
51
- centre.first
52
- end
53
-
54
- def centre_x
55
- centre.last
56
- end
57
-
58
- def top
59
- if centred
60
- centre_y - (height / 2)
61
- else
62
- y
63
- end
64
- end
65
-
66
- def left
67
- if centred
68
- centre_x - (width / 2)
69
- else
70
- x
71
- end
72
- end
73
-
74
- def bottom
75
- top + height
76
- end
77
-
78
- def right
79
- left + width
80
- end
81
-
82
- def position
83
- {
84
- y: top,
85
- x: left,
86
- height: height,
87
- width: width,
88
- centred: centred,
89
- top: top,
90
- bottom: bottom,
91
- left: left,
92
- right: right,
93
- }
94
- end
95
-
96
- private
97
-
98
- attr_reader :attrs
99
-
100
- def attrs_height
101
- height = attrs.fetch(:height)
102
- fail_if_less_than_one(height)
103
- fail_if_out_of_bounds('height', height, terminal_height)
104
- height
105
- rescue KeyError
106
- fail InvalidHeight, 'An Interface must have a height attribute.'
107
- end
108
-
109
- def attrs_terminal_height
110
- terminal_height = attrs.fetch(:terminal_height, Terminal.height)
111
- fail_if_less_than_one(terminal_height)
112
- fail_if_out_of_bounds('terminal_height', terminal_height, Terminal.height)
113
- terminal_height
114
- end
115
-
116
- def attrs_y
117
- y = attrs.fetch(:y, 1)
118
- fail_if_less_than_one(y)
119
- fail_if_out_of_bounds('y', y, terminal_height)
120
- y
121
- end
122
-
123
- def attrs_x
124
- x = attrs.fetch(:x, 1)
125
- fail_if_less_than_one(x)
126
- fail_if_out_of_bounds('x', x, terminal_width)
127
- x
128
- end
129
-
130
- def attrs_terminal_width
131
- terminal_width = attrs.fetch(:terminal_width, Terminal.width)
132
- fail_if_less_than_one(terminal_width)
133
- fail_if_out_of_bounds('terminal_width',
134
- terminal_width,
135
- Terminal.width)
136
- terminal_width
137
- end
138
-
139
- def attrs_width
140
- width = attrs.fetch(:width)
141
- fail_if_less_than_one(width)
142
- fail_if_out_of_bounds('width', width, terminal_width)
143
- width
144
- rescue KeyError
145
- fail InvalidWidth, 'An Interface must have a width attribute.'
146
- end
147
-
148
- def attrs_centred
149
- !!(attrs.fetch(:centred, true))
150
- end
151
-
152
- def fail_if_less_than_one(value)
153
- fail OutOfBoundsError,
154
- 'Value must be greater than or equal to 1.' if value < 1
155
- end
156
-
157
- def fail_if_out_of_bounds(name, attribute, boundary)
158
- if attribute > boundary
159
- fail OutOfBoundsError,
160
- "Cannot set #{name} to be outside the terminal visible area."
161
- end
162
- end
163
-
164
- def virtual_x
165
- left
166
- end
167
-
168
- def virtual_y(index = 0)
169
- ((top..bottom).to_a)[index]
170
- end
171
- end
172
- end