vedeu 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/README.md +1 -1
- data/docs/api.md +60 -67
- data/docs/configuration.md +8 -5
- data/docs/events.md +31 -15
- data/docs/events/application.md +12 -0
- data/docs/events/document.md +57 -0
- data/docs/events/drb.md +43 -0
- data/docs/events/focus.md +24 -0
- data/docs/events/menu.md +57 -0
- data/docs/events/movement.md +57 -0
- data/docs/events/refresh.md +25 -0
- data/docs/events/system.md +90 -0
- data/docs/events/visibility.md +68 -0
- data/lib/vedeu.rb +2 -2
- data/lib/vedeu/all.rb +3 -2
- data/lib/vedeu/api.rb +18 -18
- data/lib/vedeu/application/controller.rb +1 -1
- data/lib/vedeu/application/helper.rb +1 -1
- data/lib/vedeu/application/view.rb +1 -1
- data/lib/vedeu/bindings/application.rb +1 -12
- data/lib/vedeu/bindings/bindings.rb +3 -1
- data/lib/vedeu/bindings/document.rb +9 -62
- data/lib/vedeu/bindings/drb.rb +12 -56
- data/lib/vedeu/bindings/focus.rb +3 -28
- data/lib/vedeu/bindings/menus.rb +10 -66
- data/lib/vedeu/bindings/movement.rb +4 -69
- data/lib/vedeu/bindings/refresh.rb +3 -33
- data/lib/vedeu/bindings/system.rb +14 -100
- data/lib/vedeu/bindings/visibility.rb +20 -71
- data/lib/vedeu/borders/all.rb +4 -3
- data/lib/vedeu/borders/border.rb +39 -33
- data/lib/vedeu/borders/dsl.rb +40 -33
- data/lib/vedeu/borders/null.rb +2 -2
- data/lib/vedeu/borders/render.rb +29 -24
- data/lib/vedeu/borders/repository.rb +2 -2
- data/lib/vedeu/buffers/all.rb +8 -7
- data/lib/vedeu/buffers/buffer.rb +47 -39
- data/lib/vedeu/buffers/null.rb +2 -2
- data/lib/vedeu/buffers/refresh.rb +4 -3
- data/lib/vedeu/buffers/virtual_buffer.rb +122 -118
- data/lib/vedeu/buffers/virtual_buffers.rb +62 -56
- data/lib/vedeu/colours/background.rb +2 -1
- data/lib/vedeu/colours/colour.rb +21 -19
- data/lib/vedeu/colours/foreground.rb +2 -1
- data/lib/vedeu/colours/repository.rb +6 -5
- data/lib/vedeu/colours/translator.rb +39 -35
- data/lib/vedeu/configuration/api.rb +59 -51
- data/lib/vedeu/configuration/cli.rb +9 -7
- data/lib/vedeu/configuration/configuration.rb +41 -32
- data/lib/vedeu/cursors/cursor.rb +1 -1
- data/lib/vedeu/cursors/refresh.rb +20 -16
- data/lib/vedeu/distributed/server.rb +8 -6
- data/lib/vedeu/distributed/subprocess.rb +90 -86
- data/lib/vedeu/distributed/uri.rb +4 -3
- data/lib/vedeu/dsl/composition.rb +2 -2
- data/lib/vedeu/dsl/group.rb +4 -4
- data/lib/vedeu/dsl/interface.rb +5 -5
- data/lib/vedeu/dsl/presentation.rb +2 -2
- data/lib/vedeu/dsl/text.rb +1 -1
- data/lib/vedeu/editor/cropper.rb +4 -4
- data/lib/vedeu/editor/cursor.rb +6 -4
- data/lib/vedeu/editor/document.rb +20 -18
- data/lib/vedeu/editor/editor.rb +2 -2
- data/lib/vedeu/editor/line.rb +10 -5
- data/lib/vedeu/editor/lines.rb +2 -2
- data/lib/vedeu/internal_api.rb +4 -4
- data/lib/vedeu/models/focus.rb +197 -191
- data/lib/vedeu/models/group.rb +171 -159
- data/lib/vedeu/models/groups.rb +14 -10
- data/lib/vedeu/models/interface.rb +116 -110
- data/lib/vedeu/models/interfaces.rb +24 -20
- data/lib/vedeu/models/toggleable.rb +4 -4
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/composition.rb +1 -1
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/models/views/stream.rb +1 -1
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/null/interface.rb +1 -1
- data/lib/vedeu/null/view.rb +1 -1
- data/lib/vedeu/output/clear/named_interface.rb +1 -1
- data/lib/vedeu/output/compressor.rb +78 -73
- data/lib/vedeu/output/direct.rb +61 -57
- data/lib/vedeu/output/output.rb +34 -29
- data/lib/vedeu/output/{presentation.rb → presentation/presentation.rb} +2 -1
- data/lib/vedeu/output/presentation/style.rb +64 -18
- data/lib/vedeu/output/presentation/styles.rb +39 -0
- data/lib/vedeu/output/renderers/html.rb +2 -2
- data/lib/vedeu/output/renderers/json.rb +2 -1
- data/lib/vedeu/output/renderers/terminal.rb +3 -3
- data/lib/vedeu/output/renderers/text.rb +3 -3
- data/lib/vedeu/output/text.rb +186 -180
- data/lib/vedeu/output/wordwrap.rb +142 -138
- data/lib/vedeu/refresh/refresh.rb +2 -2
- data/lib/vedeu/templating/helpers.rb +11 -6
- data/lib/vedeu/templating/view_template.rb +1 -1
- data/lib/vedeu/terminal/terminal.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/render_test.rb +1 -1
- data/test/lib/vedeu/buffers/buffer_test.rb +16 -14
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +105 -101
- data/test/lib/vedeu/buffers/virtual_buffers_test.rb +43 -39
- data/test/lib/vedeu/colours/colour_test.rb +4 -4
- data/test/lib/vedeu/cursors/cursor_test.rb +2 -2
- data/test/lib/vedeu/cursors/repository_test.rb +3 -3
- data/test/lib/vedeu/distributed/subprocess_test.rb +33 -29
- data/test/lib/vedeu/dsl/group_test.rb +3 -3
- data/test/lib/vedeu/dsl/interface_test.rb +6 -5
- data/test/lib/vedeu/dsl/line_test.rb +4 -2
- data/test/lib/vedeu/dsl/presentation_test.rb +2 -2
- data/test/lib/vedeu/dsl/text_test.rb +8 -8
- data/test/lib/vedeu/editor/document_test.rb +10 -6
- data/test/lib/vedeu/input/keymap_test.rb +1 -10
- data/test/lib/vedeu/models/focus_test.rb +177 -170
- data/test/lib/vedeu/models/group_test.rb +99 -95
- data/test/lib/vedeu/models/groups_test.rb +13 -9
- data/test/lib/vedeu/models/interface_test.rb +93 -87
- data/test/lib/vedeu/models/interfaces_test.rb +24 -20
- data/test/lib/vedeu/models/views/char_test.rb +2 -2
- data/test/lib/vedeu/models/views/line_test.rb +11 -7
- data/test/lib/vedeu/models/views/stream_test.rb +1 -1
- data/test/lib/vedeu/models/views/view_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_group_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_interface_test.rb +3 -1
- data/test/lib/vedeu/output/compressor_test.rb +126 -122
- data/test/lib/vedeu/output/direct_test.rb +49 -43
- data/test/lib/vedeu/output/output_test.rb +35 -31
- data/test/lib/vedeu/output/{presentation_test.rb → presentation/presentation_test.rb} +11 -7
- data/test/lib/vedeu/output/presentation/style_test.rb +88 -48
- data/test/lib/vedeu/output/presentation/styles_test.rb +84 -0
- data/test/lib/vedeu/output/text_test.rb +109 -105
- data/test/lib/vedeu/output/viewport_test.rb +3 -1
- data/test/lib/vedeu/output/wordwrap_test.rb +209 -205
- data/test/lib/vedeu/refresh/refresh_test.rb +3 -1
- data/test/lib/vedeu/templating/helpers_test.rb +6 -6
- data/test/lib/vedeu/templating/view_template_test.rb +1 -1
- metadata +17 -8
- data/lib/vedeu/output/style.rb +0 -76
- data/test/lib/vedeu/output/style_test.rb +0 -120
@@ -2,15 +2,12 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Bindings
|
4
4
|
|
5
|
-
# Creates system events which when called provide a variety of core
|
6
|
-
# functions and behaviours. They are soft-namespaced using underscores.
|
7
|
-
#
|
8
|
-
# :nocov:
|
9
5
|
module System
|
10
6
|
|
11
7
|
extend self
|
12
8
|
|
13
|
-
# Setup events relating to running Vedeu. This method is called
|
9
|
+
# Setup events relating to running Vedeu. This method is called
|
10
|
+
# by Vedeu.
|
14
11
|
#
|
15
12
|
# @return [TrueClass]
|
16
13
|
def setup!
|
@@ -30,15 +27,7 @@ module Vedeu
|
|
30
27
|
|
31
28
|
private
|
32
29
|
|
33
|
-
#
|
34
|
-
# into this to perform a special action before the application
|
35
|
-
# terminates. Saving the user's work, session or preferences might be
|
36
|
-
# popular here.
|
37
|
-
#
|
38
|
-
# @example
|
39
|
-
# Vedeu.trigger(:_exit_)
|
40
|
-
#
|
41
|
-
# @return [TrueClass]
|
30
|
+
# See {file:docs/events/system.md#\_cleanup_}
|
42
31
|
def cleanup!
|
43
32
|
Vedeu.bind(:_cleanup_) do
|
44
33
|
Vedeu.trigger(:_drb_stop_)
|
@@ -46,14 +35,7 @@ module Vedeu
|
|
46
35
|
end
|
47
36
|
end
|
48
37
|
|
49
|
-
#
|
50
|
-
# interface area will be cleared.
|
51
|
-
#
|
52
|
-
# @example
|
53
|
-
# Vedeu.trigger(:_clear_)
|
54
|
-
# Vedeu.clear_by_name(name)
|
55
|
-
#
|
56
|
-
# @return [TrueClass]
|
38
|
+
# See {file:docs/events/system.md#\_cleanup_}
|
57
39
|
def clear!
|
58
40
|
Vedeu.bind(:_clear_) do |name|
|
59
41
|
if name
|
@@ -66,48 +48,24 @@ module Vedeu
|
|
66
48
|
end
|
67
49
|
end
|
68
50
|
|
69
|
-
#
|
70
|
-
# define to 'do things'
|
71
|
-
#
|
72
|
-
# @example
|
73
|
-
# Vedeu.trigger(:_command_, command)
|
74
|
-
#
|
75
|
-
# @return [TrueClass]
|
51
|
+
# See {file:docs/events/system.md#\_command_}
|
76
52
|
def command!
|
77
53
|
Vedeu.bind(:_command_) { |command| Vedeu.trigger(:command, command) }
|
78
54
|
end
|
79
55
|
|
80
|
-
#
|
81
|
-
# invoked, the key will be passed to the editor for currently
|
82
|
-
# focussed view.
|
83
|
-
#
|
84
|
-
# @example
|
85
|
-
# Vedeu.trigger(:_editor_, key)
|
86
|
-
#
|
87
|
-
# @return [TrueClass]
|
56
|
+
# See {file:docs/events/system.md#\_editor_}
|
88
57
|
def editor!
|
89
58
|
Vedeu.bind(:_editor_) do |key|
|
90
59
|
Vedeu::Editor::Editor.keypress(name: Vedeu.focus, input: key)
|
91
60
|
end
|
92
61
|
end
|
93
62
|
|
94
|
-
#
|
95
|
-
# define (to save files, etc) and attempt to exit.
|
96
|
-
#
|
97
|
-
# @example
|
98
|
-
# Vedeu.trigger(:_exit_)
|
99
|
-
# Vedeu.exit
|
100
|
-
#
|
101
|
-
# @return [TrueClass]
|
63
|
+
# See {file:docs/events/system.md#\_exit_}
|
102
64
|
def exit!
|
103
65
|
Vedeu.bind(:_exit_) { Vedeu::Runtime::Application.stop }
|
104
66
|
end
|
105
67
|
|
106
|
-
#
|
107
|
-
# Client applications can listen for this event and perform some
|
108
|
-
# action(s), like render the first screen, interface or make a sound.
|
109
|
-
#
|
110
|
-
# @return [TrueClass]
|
68
|
+
# See {file:docs/events/system.md#\_initialize_}
|
111
69
|
def initialize!
|
112
70
|
Vedeu.bind(:_initialize_) do
|
113
71
|
Vedeu.ready!
|
@@ -115,77 +73,34 @@ module Vedeu
|
|
115
73
|
end
|
116
74
|
end
|
117
75
|
|
118
|
-
#
|
119
|
-
# to 'do things'. If the `escape` key is pressed, then `key` is triggered
|
120
|
-
# with the argument `:escape`, also an internal event `_mode_switch_` is
|
121
|
-
# triggered. Vedeu recognises most key presses and some 'extended'
|
122
|
-
# keypress (eg. Ctrl+J), a list of supported keypresses can be found here:
|
123
|
-
# {Vedeu::Input::Input#specials} and {Vedeu::Input::Input#f_keys}.
|
124
|
-
#
|
125
|
-
# @example
|
126
|
-
# Vedeu.trigger(:_keypress_, key)
|
127
|
-
#
|
128
|
-
# @return [TrueClass]
|
76
|
+
# See {file:docs/events/system.md#\_keypress_}
|
129
77
|
def keypress!
|
130
78
|
Vedeu.bind(:_keypress_) { |key| Vedeu.keypress(key) }
|
131
79
|
end
|
132
80
|
|
133
|
-
#
|
134
|
-
# logging is enabled in the configuration.
|
135
|
-
#
|
136
|
-
# @example
|
137
|
-
# Vedeu.trigger(:_log_, message)
|
138
|
-
#
|
139
|
-
# @return [TrueClass]
|
81
|
+
# See {file:docs/events/system.md#\_log_}
|
140
82
|
def log!
|
141
83
|
Vedeu.bind(:_log_) { |msg| Vedeu.log(type: :debug, message: msg) }
|
142
84
|
end
|
143
85
|
|
144
|
-
#
|
145
|
-
#
|
146
|
-
# @example
|
147
|
-
# Vedeu.trigger(:_maximise_, name)
|
148
|
-
#
|
149
|
-
# @return [TrueClass]
|
150
|
-
# @see Vedeu::Geometry::Geometry#maximise
|
86
|
+
# See {file:docs/events/system.md#\_maximise_}
|
151
87
|
def maximise!
|
152
88
|
Vedeu.bind(:_maximise_) do |name|
|
153
89
|
Vedeu.geometries.by_name(name).maximise
|
154
90
|
end
|
155
91
|
end
|
156
92
|
|
157
|
-
#
|
158
|
-
# switches between modes of the terminal. The idea here being
|
159
|
-
# that the raw mode is for single keypress actions, whilst fake and cooked
|
160
|
-
# modes allow the user to enter more elaborate commands- such as commands
|
161
|
-
# with arguments.
|
162
|
-
#
|
163
|
-
# @example
|
164
|
-
# Vedeu.trigger(:_mode_switch_)
|
165
|
-
#
|
166
|
-
# @return [TrueClass]
|
93
|
+
# See {file:docs/events/system.md#\_mode_switch_}
|
167
94
|
def mode_switch!
|
168
95
|
Vedeu.bind(:_mode_switch_) { fail Vedeu::Error::ModeSwitch }
|
169
96
|
end
|
170
97
|
|
171
|
-
#
|
172
|
-
# `:_refresh_` events. Please see those events for their behaviour.
|
173
|
-
#
|
174
|
-
# @example
|
175
|
-
# Vedeu.trigger(:_resize_)
|
176
|
-
#
|
177
|
-
# @return [TrueClass]
|
98
|
+
# See {file:docs/events/system.md#\_resize_}
|
178
99
|
def resize!
|
179
100
|
Vedeu.bind(:_resize_, delay: 0.25) { Vedeu.resize }
|
180
101
|
end
|
181
102
|
|
182
|
-
#
|
183
|
-
#
|
184
|
-
# @example
|
185
|
-
# Vedeu.trigger(:_unmaximise_, name)
|
186
|
-
#
|
187
|
-
# @return [TrueClass]
|
188
|
-
# @see Vedeu::Geometry::Geometry#unmaximise
|
103
|
+
# See {file:docs/events/system.md#\_unmaximise_}
|
189
104
|
def unmaximise!
|
190
105
|
Vedeu.bind(:_unmaximise_) do |name|
|
191
106
|
Vedeu.geometries.by_name(name).unmaximise
|
@@ -193,7 +108,6 @@ module Vedeu
|
|
193
108
|
end
|
194
109
|
|
195
110
|
end # System
|
196
|
-
# :nocov:
|
197
111
|
|
198
112
|
end # Bindings
|
199
113
|
|
@@ -5,7 +5,6 @@ module Vedeu
|
|
5
5
|
# System events relating to the visibility of cursors or
|
6
6
|
# interfaces.
|
7
7
|
#
|
8
|
-
# :nocov:
|
9
8
|
module Visibility
|
10
9
|
|
11
10
|
extend self
|
@@ -29,29 +28,14 @@ module Vedeu
|
|
29
28
|
|
30
29
|
private
|
31
30
|
|
32
|
-
#
|
33
|
-
# named group.
|
34
|
-
#
|
35
|
-
# @example
|
36
|
-
# Vedeu.trigger(:_clear_group_, name)
|
37
|
-
# Vedeu.clear_by_group(name)
|
38
|
-
#
|
39
|
-
# @return [TrueClass]
|
31
|
+
# See {file:docs/events/visibility.md#\_clear_group_}
|
40
32
|
def clear_group!
|
41
33
|
Vedeu.bind(:_clear_group_) do |name|
|
42
34
|
Vedeu::Clear::NamedGroup.render(name)
|
43
35
|
end
|
44
36
|
end
|
45
37
|
|
46
|
-
#
|
47
|
-
# given, the interface currently in focus.
|
48
|
-
#
|
49
|
-
# @example
|
50
|
-
# Vedeu.trigger(:_hide_cursor_, name)
|
51
|
-
# Vedeu.trigger(:_cursor_hide_, name)
|
52
|
-
# Vedeu.hide_cursor(name)
|
53
|
-
#
|
54
|
-
# @return [TrueClass]
|
38
|
+
# See {file:docs/events/visibility.md#\_hide_cursor_}
|
55
39
|
def hide_cursor!
|
56
40
|
Vedeu.bind(:_hide_cursor_) do |name|
|
57
41
|
Vedeu::Cursors::Cursor.hide_cursor(name)
|
@@ -60,33 +44,21 @@ module Vedeu
|
|
60
44
|
Vedeu.bind_alias(:_cursor_hide_, :_hide_cursor_)
|
61
45
|
end
|
62
46
|
|
63
|
-
#
|
47
|
+
# See {file:docs/events/visibility.md#\_hide_group_}
|
64
48
|
def hide_group!
|
65
|
-
Vedeu.bind(:_hide_group_)
|
49
|
+
Vedeu.bind(:_hide_group_) do |name|
|
50
|
+
Vedeu::Models::Group.hide_group(name)
|
51
|
+
end
|
66
52
|
end
|
67
53
|
|
68
|
-
#
|
69
|
-
#
|
70
|
-
# @example
|
71
|
-
# Vedeu.trigger(:_hide_interface_, name)
|
72
|
-
# Vedeu.hide_interface(name)
|
73
|
-
#
|
74
|
-
# @return [TrueClass]
|
54
|
+
# See {file:docs/events/visibility.md#\_hide_interface_}
|
75
55
|
def hide_interface!
|
76
56
|
Vedeu.bind(:_hide_interface_) do |name|
|
77
|
-
Vedeu::Interface.hide_interface(name)
|
57
|
+
Vedeu::Models::Interface.hide_interface(name)
|
78
58
|
end
|
79
59
|
end
|
80
60
|
|
81
|
-
#
|
82
|
-
# given, the interface currently in focus.
|
83
|
-
#
|
84
|
-
# @example
|
85
|
-
# Vedeu.trigger(:_show_cursor_, name)
|
86
|
-
# Vedeu.trigger(:_cursor_show_, name)
|
87
|
-
# Vedeu.show_cursor(name)
|
88
|
-
#
|
89
|
-
# @return [TrueClass]
|
61
|
+
# See {file:docs/events/visibility.md#\_show_cursor_}
|
90
62
|
def show_cursor!
|
91
63
|
Vedeu.bind(:_show_cursor_) do |name|
|
92
64
|
Vedeu::Cursors::Cursor.show_cursor(name)
|
@@ -95,65 +67,42 @@ module Vedeu
|
|
95
67
|
Vedeu.bind_alias(:_cursor_show_, :_show_cursor_)
|
96
68
|
end
|
97
69
|
|
98
|
-
#
|
70
|
+
# See {file:docs/events/visibility.md#\_show_group_}
|
99
71
|
def show_group!
|
100
|
-
Vedeu.bind(:_show_group_)
|
72
|
+
Vedeu.bind(:_show_group_) do |name|
|
73
|
+
Vedeu::Models::Group.show_group(name)
|
74
|
+
end
|
101
75
|
end
|
102
76
|
|
103
|
-
#
|
104
|
-
#
|
105
|
-
# @example
|
106
|
-
# Vedeu.trigger(:_show_interface_, name)
|
107
|
-
# Vedeu.show_interface(name)
|
108
|
-
#
|
109
|
-
# @return [TrueClass]
|
77
|
+
# See {file:docs/events/visibility.md#\_show_interface_}
|
110
78
|
def show_interface!
|
111
79
|
Vedeu.bind(:_show_interface_) do |name|
|
112
|
-
Vedeu::Interface.show_interface(name)
|
80
|
+
Vedeu::Models::Interface.show_interface(name)
|
113
81
|
end
|
114
82
|
end
|
115
83
|
|
116
|
-
#
|
117
|
-
#
|
118
|
-
# @example
|
119
|
-
# Vedeu.trigger(:_toggle_cursor_, name)
|
120
|
-
# Vedeu.toggle_cursor(name)
|
121
|
-
#
|
122
|
-
# @return [TrueClass]
|
84
|
+
# See {file:docs/events/visibility.md#\_toggle_cursor_}
|
123
85
|
def toggle_cursor!
|
124
86
|
Vedeu.bind(:_toggle_cursor_) do |name|
|
125
87
|
Vedeu::Cursors::Cursor.toggle_cursor(name)
|
126
88
|
end
|
127
89
|
end
|
128
90
|
|
129
|
-
#
|
130
|
-
#
|
131
|
-
# @example
|
132
|
-
# Vedeu.trigger(:_toggle_group_, name)
|
133
|
-
# Vedeu.toggle_group(name)
|
134
|
-
#
|
135
|
-
# @return [TrueClass]
|
91
|
+
# See {file:docs/events/visibility.md#\_toggle_group_}
|
136
92
|
def toggle_group!
|
137
93
|
Vedeu.bind(:_toggle_group_) do |name|
|
138
|
-
Vedeu::Group.toggle_group(name)
|
94
|
+
Vedeu::Models::Group.toggle_group(name)
|
139
95
|
end
|
140
96
|
end
|
141
97
|
|
142
|
-
#
|
143
|
-
#
|
144
|
-
# @example
|
145
|
-
# Vedeu.trigger(:_toggle_interface_, name)
|
146
|
-
# Vedeu.toggle_interface(name)
|
147
|
-
#
|
148
|
-
# @return [TrueClass]
|
98
|
+
# See {file:docs/events/visibility.md#\_toggle_interface_}
|
149
99
|
def toggle_interface!
|
150
100
|
Vedeu.bind(:_toggle_interface_) do |name|
|
151
|
-
Vedeu::Interface.toggle_interface(name)
|
101
|
+
Vedeu::Models::Interface.toggle_interface(name)
|
152
102
|
end
|
153
103
|
end
|
154
104
|
|
155
105
|
end # Visibility
|
156
|
-
# :nocov:
|
157
106
|
|
158
107
|
end # Bindings
|
159
108
|
|
data/lib/vedeu/borders/all.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
3
|
# Borders are defined by name for each of the client application's
|
4
|
-
# interfaces or views. They can be enabled or disabled (which
|
5
|
-
# whether they are rendered or not), they have their own
|
6
|
-
# and each aspect of the border can be
|
4
|
+
# interfaces or views. They can be enabled or disabled (which
|
5
|
+
# controls whether they are rendered or not), they have their own
|
6
|
+
# colours and styles, and each aspect of the border can be
|
7
|
+
# controlled.
|
7
8
|
#
|
8
9
|
# @example
|
9
10
|
# # Borders can be defined when defining your interface...
|
data/lib/vedeu/borders/border.rb
CHANGED
@@ -2,13 +2,15 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Borders
|
4
4
|
|
5
|
-
# Provides the mechanism to decorate an interface with a border on
|
6
|
-
# edges, or specific edges. The characters which are used for
|
7
|
-
# parts (e.g. the corners, verticals and horizontals)
|
8
|
-
# can the colours and styles.
|
5
|
+
# Provides the mechanism to decorate an interface with a border on
|
6
|
+
# all edges, or specific edges. The characters which are used for
|
7
|
+
# the border parts (e.g. the corners, verticals and horizontals)
|
8
|
+
# can be customised as can the colours and styles.
|
9
9
|
#
|
10
|
-
# @note
|
11
|
-
#
|
10
|
+
# @note
|
11
|
+
# Refer to UTF-8 U+2500 to U+257F for border characters.
|
12
|
+
# More details can be found at:
|
13
|
+
# http://en.wikipedia.org/wiki/Box-drawing_character
|
12
14
|
#
|
13
15
|
class Border
|
14
16
|
|
@@ -95,30 +97,34 @@ module Vedeu
|
|
95
97
|
# @param attributes [Hash]
|
96
98
|
# @option attributes bottom_left [String] The bottom left border
|
97
99
|
# character.
|
98
|
-
# @option attributes bottom_right [String] The bottom right
|
99
|
-
# character.
|
100
|
+
# @option attributes bottom_right [String] The bottom right
|
101
|
+
# border character.
|
100
102
|
# @option attributes colour [Hash]
|
101
|
-
# @option attributes enabled [Boolean] Indicate whether the
|
102
|
-
# be shown for this interface.
|
103
|
-
# @option attributes horizontal [String] The horizontal border
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
# @option attributes
|
108
|
-
#
|
109
|
-
# @option attributes show_left [Boolean] Indicate whether the left border
|
110
|
-
# is to be shown.
|
111
|
-
# @option attributes show_right [Boolean] Indicate whether the right
|
112
|
-
# border is to be shown.
|
113
|
-
# @option attributes show_top [Boolean] Indicate whether the top border is
|
114
|
-
# to be shown.
|
115
|
-
# @option attributes title [String] An optional title for when the top
|
116
|
-
# border is to be shown.
|
117
|
-
# @option attributes caption [String] An optional caption for when the
|
103
|
+
# @option attributes enabled [Boolean] Indicate whether the
|
104
|
+
# border is to be shown for this interface.
|
105
|
+
# @option attributes horizontal [String] The horizontal border
|
106
|
+
# character.
|
107
|
+
# @option attributes name [String] The name of the interface to
|
108
|
+
# which this border relates.
|
109
|
+
# @option attributes style [Vedeu::Presentation::Style]
|
110
|
+
# @option attributes show_bottom [Boolean] Indicate whether the
|
118
111
|
# bottom border is to be shown.
|
119
|
-
# @option attributes
|
120
|
-
#
|
121
|
-
# @option attributes
|
112
|
+
# @option attributes show_left [Boolean] Indicate whether the
|
113
|
+
# left border is to be shown.
|
114
|
+
# @option attributes show_right [Boolean] Indicate whether the
|
115
|
+
# right border is to be shown.
|
116
|
+
# @option attributes show_top [Boolean] Indicate whether the top
|
117
|
+
# border is to be shown.
|
118
|
+
# @option attributes title [String] An optional title for when
|
119
|
+
# the top border is to be shown.
|
120
|
+
# @option attributes caption [String] An optional caption for
|
121
|
+
# when the bottom border is to be shown.
|
122
|
+
# @option attributes top_left [String] The top left border
|
123
|
+
# character.
|
124
|
+
# @option attributes top_right [String] The top right border
|
125
|
+
# character.
|
126
|
+
# @option attributes vertical [String] The vertical border
|
127
|
+
# character.
|
122
128
|
# @return [Vedeu::Borders::Border]
|
123
129
|
def initialize(attributes = {})
|
124
130
|
@attributes = defaults.merge!(attributes)
|
@@ -148,16 +154,16 @@ module Vedeu
|
|
148
154
|
(enabled? && bottom?) ? yn - 1 : yn
|
149
155
|
end
|
150
156
|
|
151
|
-
# Returns the width of the interface determined by whether a
|
152
|
-
# both or neither borders are shown.
|
157
|
+
# Returns the width of the interface determined by whether a
|
158
|
+
# left, right, both or neither borders are shown.
|
153
159
|
#
|
154
160
|
# @return [Fixnum]
|
155
161
|
def width
|
156
162
|
(bx..bxn).size
|
157
163
|
end
|
158
164
|
|
159
|
-
# Returns the height of the interface determined by whether a
|
160
|
-
# both or neither borders are shown.
|
165
|
+
# Returns the height of the interface determined by whether a
|
166
|
+
# top, bottom, both or neither borders are shown.
|
161
167
|
#
|
162
168
|
# @return [Fixnum]
|
163
169
|
def height
|
@@ -176,7 +182,7 @@ module Vedeu
|
|
176
182
|
Vedeu.geometries.by_name(name)
|
177
183
|
end
|
178
184
|
|
179
|
-
# @return [Vedeu::Interface]
|
185
|
+
# @return [Vedeu::Models::Interface]
|
180
186
|
def interface
|
181
187
|
@interface ||= Vedeu.interfaces.by_name(name)
|
182
188
|
end
|