vedeu 0.1.17 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/README.md +17 -3
- data/lib/vedeu.rb +12 -7
- data/lib/vedeu/api/api.rb +37 -13
- data/lib/vedeu/api/composition.rb +1 -6
- data/lib/vedeu/api/helpers.rb +2 -0
- data/lib/vedeu/api/interface.rb +47 -55
- data/lib/vedeu/api/line.rb +6 -0
- data/lib/vedeu/api/stream.rb +9 -1
- data/lib/vedeu/application.rb +38 -50
- data/lib/vedeu/configuration.rb +163 -44
- data/lib/vedeu/launcher.rb +3 -6
- data/lib/vedeu/models/attributes/background.rb +9 -1
- data/lib/vedeu/models/attributes/colour_translator.rb +40 -2
- data/lib/vedeu/models/attributes/foreground.rb +9 -1
- data/lib/vedeu/models/colour.rb +6 -0
- data/lib/vedeu/models/composition.rb +8 -1
- data/lib/vedeu/models/geometry.rb +27 -14
- data/lib/vedeu/models/interface.rb +59 -0
- data/lib/vedeu/models/line.rb +4 -0
- data/lib/vedeu/models/stream.rb +10 -0
- data/lib/vedeu/models/style.rb +2 -0
- data/lib/vedeu/support/buffer.rb +12 -1
- data/lib/vedeu/support/buffers.rb +10 -0
- data/lib/vedeu/support/clear.rb +4 -0
- data/lib/vedeu/support/esc.rb +26 -8
- data/lib/vedeu/support/event.rb +28 -0
- data/lib/vedeu/support/events.rb +2 -0
- data/lib/vedeu/support/focus.rb +14 -6
- data/lib/vedeu/support/grid.rb +6 -0
- data/lib/vedeu/support/groups.rb +13 -3
- data/lib/vedeu/support/input.rb +7 -2
- data/lib/vedeu/support/log.rb +7 -1
- data/lib/vedeu/support/position.rb +6 -0
- data/lib/vedeu/support/render.rb +38 -0
- data/lib/vedeu/support/terminal.rb +69 -15
- data/lib/vedeu/support/trace.rb +8 -0
- data/lib/vedeu/support/view.rb +6 -0
- data/test/integration/run_once_test.rb +26 -0
- data/test/lib/vedeu/api/api_test.rb +19 -6
- data/test/lib/vedeu/api/interface_test.rb +67 -1
- data/test/lib/vedeu/api/line_test.rb +10 -0
- data/test/lib/vedeu/api/stream_test.rb +8 -0
- data/test/lib/vedeu/configuration_test.rb +119 -12
- data/test/lib/vedeu/models/attributes/background_test.rb +1 -1
- data/test/lib/vedeu/models/attributes/foreground_test.rb +1 -1
- data/test/lib/vedeu/models/interface_test.rb +22 -0
- data/test/lib/vedeu/support/buffer_test.rb +44 -0
- data/test/lib/vedeu/support/events_test.rb +3 -9
- data/test/lib/vedeu/support/input_test.rb +1 -0
- data/test/lib/vedeu/support/terminal_test.rb +128 -5
- data/test/test_helper.rb +2 -2
- data/vedeu.gemspec +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c988501e3c74334d3be70e231d973e75aeb1d3ec
|
4
|
+
data.tar.gz: e452c34986e00757580aab9e8adb6a2016d8c6b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e03000d3934efdcf2597f9a0334f277c5a7779ae22939bc13419dee0986c9cf2013192a98b374335437605fd6b15447c7602814da7f0442ef4d5b2f185bef565
|
7
|
+
data.tar.gz: e4dfb2ae02ae58371a6d64fec619d4b9a17791a5e7b36b6597b0a16d594d06ada538184799457d806273c2fdc43e9e2b5dd6832645fdfd7fa902345caf66c6f0
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--private
|
data/README.md
CHANGED
@@ -165,13 +165,13 @@ echo "export TERM=xterm-256color" >> ~/.bashrc
|
|
165
165
|
or, if you wish not to tamper with `$TERM`:
|
166
166
|
|
167
167
|
```bash
|
168
|
-
echo "export
|
168
|
+
echo "export VEDEU_TERM=xterm-256color" >> ~/.bashrc
|
169
169
|
```
|
170
170
|
|
171
|
-
If you know your terminal supports full 24-bit colour, set the `$
|
171
|
+
If you know your terminal supports full 24-bit colour, set the `$VEDEU_TERM` environment variable:
|
172
172
|
|
173
173
|
```bash
|
174
|
-
echo "export
|
174
|
+
echo "export VEDEU_TERM=xterm-truecolor" >> ~/.bashrc
|
175
175
|
```
|
176
176
|
|
177
177
|
|
@@ -180,6 +180,20 @@ echo "export VEDEUTERM=xterm-truecolor" >> ~/.bashrc
|
|
180
180
|
Vedeu has a range of symbol styles which are compatible with most terminals which are ANSI compatible. Like colours, they can be defined in either interfaces, for specific lines or within streams. Styles are applied as encountered.
|
181
181
|
|
182
182
|
|
183
|
+
## Debugging & Environment Variables
|
184
|
+
|
185
|
+
Vedeu has two types of debugging; `VEDEU_DEBUG` and `VEDEU_TRACE`. Both of these can be configured at run-time using the arguments you pass to your application. They can also be enabled/disabled globally by setting environment variables (see below). These messages are written to `~/.vedeu/vedeu.log`.
|
186
|
+
|
187
|
+
To enable or disable, use true or false:
|
188
|
+
|
189
|
+
```bash
|
190
|
+
echo "export VEDEU_DEBUG=true" >> ~/.bashrc
|
191
|
+
echo "export VEDEU_TRACE=true" >> ~/.bashrc
|
192
|
+
```
|
193
|
+
|
194
|
+
Debugging (`VEDEU_DEBUG`) provides helpful messages which inform you what is happening in the application. Tracing (`VEDEU_TRACE`) is a noisy, blow-by-blow account of what is happening, letting you know which methods were called and which events have been triggered. Both (more so with tracing) can impact the performance of your application.
|
195
|
+
|
196
|
+
|
183
197
|
## Development / Contributing
|
184
198
|
|
185
199
|
* Documentation hosted at [RubyDoc](http://rubydoc.info/github/gavinlaking/vedeu/master/frames).
|
data/lib/vedeu.rb
CHANGED
@@ -3,6 +3,7 @@ module Vedeu
|
|
3
3
|
EntityNotFound = Class.new(StandardError)
|
4
4
|
GroupNotFound = Class.new(StandardError)
|
5
5
|
InterfaceNotFound = Class.new(StandardError)
|
6
|
+
InvalidSyntax = Class.new(StandardError)
|
6
7
|
ModeSwitch = Class.new(StandardError)
|
7
8
|
NoInterfacesDefined = Class.new(StandardError)
|
8
9
|
NotImplemented = Class.new(StandardError)
|
@@ -22,6 +23,8 @@ require 'logger'
|
|
22
23
|
require 'optparse'
|
23
24
|
require 'set'
|
24
25
|
|
26
|
+
require 'vedeu/support/log'
|
27
|
+
require 'vedeu/support/trace'
|
25
28
|
require 'vedeu/configuration'
|
26
29
|
|
27
30
|
require 'vedeu/models/attributes/coercions'
|
@@ -30,7 +33,13 @@ require 'vedeu/models/attributes/background'
|
|
30
33
|
require 'vedeu/models/attributes/foreground'
|
31
34
|
require 'vedeu/models/attributes/presentation'
|
32
35
|
require 'vedeu/models/composition'
|
36
|
+
|
37
|
+
require 'vedeu/support/position'
|
38
|
+
require 'vedeu/support/esc'
|
33
39
|
require 'vedeu/support/terminal'
|
40
|
+
require 'vedeu/support/event'
|
41
|
+
require 'vedeu/support/events'
|
42
|
+
|
34
43
|
require 'vedeu/models/geometry'
|
35
44
|
require 'vedeu/models/colour'
|
36
45
|
require 'vedeu/models/style'
|
@@ -45,6 +54,8 @@ require 'vedeu/api/interface'
|
|
45
54
|
require 'vedeu/api/line'
|
46
55
|
require 'vedeu/api/stream'
|
47
56
|
|
57
|
+
require 'vedeu/support/input'
|
58
|
+
|
48
59
|
require 'vedeu/application'
|
49
60
|
require 'vedeu/launcher'
|
50
61
|
|
@@ -55,12 +66,6 @@ require 'vedeu/support/clear'
|
|
55
66
|
require 'vedeu/support/render'
|
56
67
|
require 'vedeu/support/view'
|
57
68
|
require 'vedeu/support/buffer'
|
58
|
-
require 'vedeu/support/position'
|
59
|
-
require 'vedeu/support/esc'
|
60
|
-
require 'vedeu/support/event'
|
61
|
-
require 'vedeu/support/events'
|
62
69
|
require 'vedeu/support/grid'
|
63
|
-
require 'vedeu/support/input'
|
64
|
-
require 'vedeu/support/log'
|
65
70
|
require 'vedeu/support/menu'
|
66
|
-
|
71
|
+
|
data/lib/vedeu/api/api.rb
CHANGED
@@ -4,6 +4,7 @@ module Vedeu
|
|
4
4
|
# Register an event by name with optional delay (throttling) which when
|
5
5
|
# triggered will execute the code contained within the passed block.
|
6
6
|
#
|
7
|
+
# @api public
|
7
8
|
# @param name [Symbol] The name of the event which will be triggered later.
|
8
9
|
# @param [Hash] opts The options to register the event with.
|
9
10
|
# @option opts :delay [Fixnum|Float] Limits the execution of the
|
@@ -23,19 +24,21 @@ module Vedeu
|
|
23
24
|
# Vedeu.trigger(:my_other_event)
|
24
25
|
# end
|
25
26
|
#
|
26
|
-
# T = Triggered, X = Executed,
|
27
|
+
# T = Triggered, X = Executed, i = Ignored.
|
28
|
+
#
|
27
29
|
# 0.0.....0.2.....0.4.....0.6.....0.8.....1.0.....1.2.....1.4.....1.6...
|
28
30
|
# .T...T...T...T...T...T...T...T...T...T...T...T...T...T...T...T...T...T
|
29
|
-
# .X...
|
31
|
+
# .X...i...i...i...i...X...i...i...i...i...X...i...i...i...i...i...i...i
|
30
32
|
#
|
31
33
|
# Vedeu.event(:my_delayed_event, { delay: 0.5 })
|
32
34
|
# ... some code here ...
|
33
35
|
# end
|
34
36
|
#
|
35
|
-
# T = Triggered, X = Executed,
|
37
|
+
# T = Triggered, X = Executed, i = Ignored.
|
38
|
+
#
|
36
39
|
# 0.0.....0.2.....0.4.....0.6.....0.8.....1.0.....1.2.....1.4.....1.6...
|
37
40
|
# .T...T...T...T...T...T...T...T...T...T...T...T...T...T...T...T...T...T
|
38
|
-
# .
|
41
|
+
# .i...i...i...i...i...i...i...X...i...i...i...i...i...i...X...i...i...i
|
39
42
|
#
|
40
43
|
# Vedeu.event(:my_debounced_event, { debounce: 0.7 })
|
41
44
|
# ... some code here ...
|
@@ -48,6 +51,7 @@ module Vedeu
|
|
48
51
|
|
49
52
|
# Unregister an event by name.
|
50
53
|
#
|
54
|
+
# @api public
|
51
55
|
# @param name [Symbol]
|
52
56
|
# @return [Hash]
|
53
57
|
def unevent(name)
|
@@ -60,6 +64,7 @@ module Vedeu
|
|
60
64
|
|
61
65
|
# Find out how many lines the current terminal is able to display.
|
62
66
|
#
|
67
|
+
# @api public
|
63
68
|
# @example
|
64
69
|
# Vedeu.height
|
65
70
|
#
|
@@ -72,6 +77,7 @@ module Vedeu
|
|
72
77
|
# command. This provides the means for you to define your application's
|
73
78
|
# views without their content.
|
74
79
|
#
|
80
|
+
# @api public
|
75
81
|
# @param name [String] The name of the interface. Used to reference the
|
76
82
|
# interface throughout your application's execution lifetime.
|
77
83
|
# @param block [Proc] A set of attributes which define the features of the
|
@@ -79,18 +85,24 @@ module Vedeu
|
|
79
85
|
#
|
80
86
|
# @example
|
81
87
|
# Vedeu.interface 'my_interface' do
|
82
|
-
#
|
83
|
-
#
|
88
|
+
# ...
|
89
|
+
#
|
90
|
+
# Vedeu.interface do
|
91
|
+
# name 'interfaces_must_have_a_name'
|
92
|
+
# ...
|
84
93
|
#
|
85
94
|
# @return [TrueClass]
|
86
|
-
def interface(name, &block)
|
95
|
+
def interface(name = '', &block)
|
87
96
|
API::Interface.define({ name: name }, &block)
|
88
97
|
end
|
89
98
|
|
90
|
-
#
|
99
|
+
# Handles the keypress in your application. Can also be used to simulate a
|
100
|
+
# keypress.
|
91
101
|
#
|
92
|
-
# @
|
93
|
-
#
|
102
|
+
# @api public
|
103
|
+
# @param key [String|Symbol] The key which was pressed. Escape sequences
|
104
|
+
# are also supported. Special keys like the F-keys are named as symbols;
|
105
|
+
# i.e. `:f4`. A list of these translations can be found at {Vedeu::Input}.
|
94
106
|
#
|
95
107
|
# @example
|
96
108
|
# TODO
|
@@ -98,12 +110,15 @@ module Vedeu
|
|
98
110
|
# @return []
|
99
111
|
def keypress(key)
|
100
112
|
Vedeu.events.trigger(:key, key)
|
101
|
-
Vedeu.events.trigger(:_log_, "Key: #{key}")
|
113
|
+
Vedeu.events.trigger(:_log_, "Key: #{key}") if Configuration.debug?
|
102
114
|
Vedeu.events.trigger(:_mode_switch_) if key == :escape
|
115
|
+
Vedeu.events.trigger(:_focus_next_) if key == :tab
|
116
|
+
Vedeu.events.trigger(:_focus_prev_) if key == :shift_tab
|
103
117
|
end
|
104
118
|
|
105
119
|
# Write a message to the Vedeu log file located at `$HOME/.vedeu/vedeu.log`
|
106
120
|
#
|
121
|
+
# @api public
|
107
122
|
# @param message [String] The message you wish to emit to the log
|
108
123
|
# file, useful for debugging.
|
109
124
|
#
|
@@ -112,11 +127,12 @@ module Vedeu
|
|
112
127
|
#
|
113
128
|
# @return [TrueClass]
|
114
129
|
def log(message)
|
115
|
-
Vedeu::Log.logger.debug(message)
|
130
|
+
Vedeu::Log.logger.debug(message) if Configuration.debug?
|
116
131
|
end
|
117
132
|
|
118
133
|
# Trigger a registered or system event by name with arguments.
|
119
134
|
#
|
135
|
+
# @api public
|
120
136
|
# @param name [Symbol] The name of the event you wish to trigger.
|
121
137
|
# The event does not have to exist.
|
122
138
|
# @param args [Array] Any arguments the event needs to execute correctly.
|
@@ -131,6 +147,7 @@ module Vedeu
|
|
131
147
|
|
132
148
|
# Use attributes of another interface whilst defining one. TODO: More help.
|
133
149
|
#
|
150
|
+
# @api public
|
134
151
|
# @param name [String] The name of the interface you wish to use. Typically
|
135
152
|
# used when defining interfaces to share geometry.
|
136
153
|
#
|
@@ -148,6 +165,7 @@ module Vedeu
|
|
148
165
|
|
149
166
|
# Define a view (content) for an interface. TODO: More help.
|
150
167
|
#
|
168
|
+
# @api public
|
151
169
|
# @param name [String] The name of the interface you are targetting for this
|
152
170
|
# view.
|
153
171
|
# @param block [Proc] The directives you wish to send to this interface.
|
@@ -163,8 +181,8 @@ module Vedeu
|
|
163
181
|
end
|
164
182
|
|
165
183
|
# Instruct Vedeu to treat contents of block as a single composition.
|
166
|
-
# TODO: More help.
|
167
184
|
#
|
185
|
+
# @api public
|
168
186
|
# @param block [Proc] Instructs Vedeu to treat all of the 'view' directives
|
169
187
|
# therein as one instruction. Useful for redrawing multiple interfaces at
|
170
188
|
# once.
|
@@ -186,12 +204,15 @@ module Vedeu
|
|
186
204
|
#
|
187
205
|
# @return [Hash]
|
188
206
|
def views(&block)
|
207
|
+
fail InvalidSyntax, '`views` requires a block.' unless block_given?
|
208
|
+
|
189
209
|
API::Composition.build(&block)
|
190
210
|
end
|
191
211
|
alias_method :composition, :views
|
192
212
|
|
193
213
|
# Find out how many columns the current terminal is able to display.
|
194
214
|
#
|
215
|
+
# @api public
|
195
216
|
# @example
|
196
217
|
# Vedeu.width
|
197
218
|
#
|
@@ -201,6 +222,7 @@ module Vedeu
|
|
201
222
|
end
|
202
223
|
|
203
224
|
# @api private
|
225
|
+
# @return []
|
204
226
|
def events
|
205
227
|
@events ||= Vedeu::Events.new do
|
206
228
|
event(:_log_) { |msg| Vedeu.log(msg) }
|
@@ -214,6 +236,7 @@ module Vedeu
|
|
214
236
|
end
|
215
237
|
|
216
238
|
# @api private
|
239
|
+
# @return []
|
217
240
|
def resize
|
218
241
|
trigger(:_clear_)
|
219
242
|
|
@@ -221,6 +244,7 @@ module Vedeu
|
|
221
244
|
end
|
222
245
|
|
223
246
|
# @api private
|
247
|
+
# @return [Exception]
|
224
248
|
def shutdown
|
225
249
|
trigger(:_cleanup_)
|
226
250
|
|
@@ -2,17 +2,12 @@ module Vedeu
|
|
2
2
|
module API
|
3
3
|
class Composition < Vedeu::Composition
|
4
4
|
|
5
|
+
# @api public
|
5
6
|
# @see Vedeu::API#view
|
6
7
|
def view(name, &block)
|
7
8
|
attributes[:interfaces] << Interface.build({ name: name }, &block)
|
8
9
|
end
|
9
10
|
|
10
|
-
private
|
11
|
-
|
12
|
-
def method_missing(method, *args, &block)
|
13
|
-
@self_before_instance_eval.send(method, *args, &block)
|
14
|
-
end
|
15
|
-
|
16
11
|
end
|
17
12
|
end
|
18
13
|
end
|
data/lib/vedeu/api/helpers.rb
CHANGED
@@ -5,6 +5,7 @@ module Vedeu
|
|
5
5
|
# Define either or both foreground and background colours for an
|
6
6
|
# interface, line or a stream.
|
7
7
|
#
|
8
|
+
# @api public
|
8
9
|
# @param values [Hash]
|
9
10
|
#
|
10
11
|
# @example
|
@@ -30,6 +31,7 @@ module Vedeu
|
|
30
31
|
|
31
32
|
# Define a style for an interface, line or a stream.
|
32
33
|
#
|
34
|
+
# @api public
|
33
35
|
# @param values [Array|String]
|
34
36
|
# @param block [Proc]
|
35
37
|
#
|
data/lib/vedeu/api/interface.rb
CHANGED
@@ -3,50 +3,40 @@ module Vedeu
|
|
3
3
|
class Interface < Vedeu::Interface
|
4
4
|
include Helpers
|
5
5
|
|
6
|
-
# @see Vedeu::API#interface
|
7
|
-
# @param attributes [Hash]
|
8
|
-
# @param block [Proc]
|
9
|
-
# @return []
|
10
|
-
def self.define(attributes = {}, &block)
|
11
|
-
new(attributes).define(&block)
|
12
|
-
end
|
13
|
-
|
14
|
-
# @see Vedeu::API#interface
|
15
|
-
# @param block [Proc]
|
16
|
-
#
|
17
|
-
# @example
|
18
|
-
# TODO
|
19
|
-
#
|
20
|
-
# @return []
|
21
|
-
def define(&block)
|
22
|
-
instance_eval(&block) if block_given?
|
23
|
-
|
24
|
-
Vedeu::Buffers.create(attributes)
|
25
|
-
|
26
|
-
Vedeu.event("_refresh_#{attributes[:name]}_".to_sym,
|
27
|
-
{ delay: attributes[:delay] }) do
|
28
|
-
Vedeu::Buffers.refresh(attributes[:name])
|
29
|
-
end
|
30
|
-
|
31
|
-
true
|
32
|
-
end
|
33
|
-
|
34
6
|
# Define a single line in a view.
|
35
7
|
#
|
8
|
+
# @api public
|
9
|
+
# @param value [String]
|
36
10
|
# @param block [Proc]
|
37
11
|
#
|
38
12
|
# @example
|
39
13
|
# view 'my_interface' do
|
14
|
+
# line 'This is a line of text...'
|
15
|
+
# line 'and so is this...'
|
16
|
+
# ...
|
17
|
+
#
|
18
|
+
# view 'my_interface' do
|
40
19
|
# line do
|
41
20
|
# ... some line attributes ...
|
42
21
|
# end
|
43
22
|
# end
|
44
23
|
#
|
45
24
|
# @return []
|
46
|
-
def line(&block)
|
47
|
-
|
25
|
+
def line(value = '', &block)
|
26
|
+
if block_given?
|
27
|
+
attributes[:lines] << Line.build(&block)
|
28
|
+
|
29
|
+
else
|
30
|
+
attributes[:lines] << Line.build({ streams: { text: value } })
|
31
|
+
|
32
|
+
end
|
48
33
|
end
|
49
34
|
|
35
|
+
# Use the specified interface; useful for sharing attributes with other
|
36
|
+
# interfaces.
|
37
|
+
#
|
38
|
+
# @api public
|
39
|
+
# @param value [String]
|
50
40
|
# @see Vedeu::API#use
|
51
41
|
def use(value)
|
52
42
|
Vedeu.use(value)
|
@@ -55,19 +45,28 @@ module Vedeu
|
|
55
45
|
# Define the cursor visibility for an interface. A `true` value will show
|
56
46
|
# the cursor, whilst `false` will hide it.
|
57
47
|
#
|
48
|
+
# @api public
|
58
49
|
# @param value [Boolean]
|
59
50
|
#
|
60
51
|
# @example
|
61
52
|
# interface 'my_interface' do
|
62
53
|
# cursor true
|
63
|
-
# ...
|
64
|
-
# end
|
54
|
+
# ...
|
65
55
|
#
|
66
56
|
# @return []
|
67
57
|
def cursor(value)
|
58
|
+
unless value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
59
|
+
fail InvalidSyntax, 'Argument must be `true` or `false` for cursor.'
|
60
|
+
end
|
61
|
+
|
68
62
|
attributes[:cursor] = value
|
69
63
|
end
|
70
64
|
|
65
|
+
# To maintain performance interfaces can be delayed from refreshing too
|
66
|
+
# often, the reduces artefacts particularly when resizing the terminal
|
67
|
+
# screen.
|
68
|
+
#
|
69
|
+
# @api public
|
71
70
|
# @param value [Fixnum|Float]
|
72
71
|
#
|
73
72
|
# @return []
|
@@ -79,13 +78,13 @@ module Vedeu
|
|
79
78
|
# targetted together; for example you may want to refresh multiple
|
80
79
|
# interfaces at once.
|
81
80
|
#
|
81
|
+
# @api public
|
82
82
|
# @param value [String]
|
83
83
|
#
|
84
84
|
# @example
|
85
85
|
# interface 'my_interface' do
|
86
|
-
# group 'main_screen'
|
87
|
-
# ...
|
88
|
-
# end
|
86
|
+
# group 'main_screen'
|
87
|
+
# ...
|
89
88
|
#
|
90
89
|
# @return []
|
91
90
|
def group(value)
|
@@ -95,10 +94,13 @@ module Vedeu
|
|
95
94
|
# The name of the interface. Used to reference the interface throughout
|
96
95
|
# your application's execution lifetime.
|
97
96
|
#
|
97
|
+
# @api public
|
98
98
|
# @param value [String]
|
99
99
|
#
|
100
100
|
# @example
|
101
|
-
#
|
101
|
+
# interface do
|
102
|
+
# name 'my_interface'
|
103
|
+
# ...
|
102
104
|
#
|
103
105
|
# @return []
|
104
106
|
def name(value)
|
@@ -107,6 +109,7 @@ module Vedeu
|
|
107
109
|
|
108
110
|
# Define the starting x position (column) of the interface.
|
109
111
|
#
|
112
|
+
# @api public
|
110
113
|
# @param value [Fixnum]
|
111
114
|
# @param block [Proc]
|
112
115
|
#
|
@@ -130,6 +133,7 @@ module Vedeu
|
|
130
133
|
|
131
134
|
# Define the starting y position (row/line) of the interface.
|
132
135
|
#
|
136
|
+
# @api public
|
133
137
|
# @param value [Fixnum]
|
134
138
|
# @param block [Proc]
|
135
139
|
#
|
@@ -154,6 +158,7 @@ module Vedeu
|
|
154
158
|
|
155
159
|
# Define the number of characters/columns wide the interface will be.
|
156
160
|
#
|
161
|
+
# @api public
|
157
162
|
# @param value [Fixnum]
|
158
163
|
#
|
159
164
|
# @example
|
@@ -170,6 +175,7 @@ module Vedeu
|
|
170
175
|
|
171
176
|
# Define the number of characters/rows/lines tall the interface will be.
|
172
177
|
#
|
178
|
+
# @api public
|
173
179
|
# @param value [Fixnum]
|
174
180
|
#
|
175
181
|
# @example
|
@@ -187,6 +193,7 @@ module Vedeu
|
|
187
193
|
# Instructs Vedeu to calculate x and y geometry automatically based on the
|
188
194
|
# centre character of the terminal, the width and the height.
|
189
195
|
#
|
196
|
+
# @api public
|
190
197
|
# @param value [Boolean]
|
191
198
|
#
|
192
199
|
# @example
|
@@ -196,26 +203,11 @@ module Vedeu
|
|
196
203
|
#
|
197
204
|
# @return []
|
198
205
|
def centred(value)
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
private
|
203
|
-
|
204
|
-
def out_of_bounds(name)
|
205
|
-
"Note: For this terminal, the value of '#{name}' may lead to content " \
|
206
|
-
"that is outside the viewable area."
|
207
|
-
end
|
208
|
-
|
209
|
-
def y_out_of_bounds?(value)
|
210
|
-
value < 1 || value > Terminal.height
|
211
|
-
end
|
212
|
-
|
213
|
-
def x_out_of_bounds?(value)
|
214
|
-
value < 1 || value > Terminal.width
|
215
|
-
end
|
206
|
+
unless value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
207
|
+
fail InvalidSyntax, 'Argument must be `true` or `false` for centred.'
|
208
|
+
end
|
216
209
|
|
217
|
-
|
218
|
-
@self_before_instance_eval.send(method, *args, &block)
|
210
|
+
attributes[:geometry][:centred] = value
|
219
211
|
end
|
220
212
|
|
221
213
|
end
|