vedeu 0.4.13 → 0.4.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/.travis.yml +2 -1
- data/Guardfile +6 -5
- data/README.md +3 -30
- data/Rakefile +5 -5
- data/bin/vedeu_drb_client +1 -1
- data/bin/vedeu_drb_server +91 -89
- data/bin/vedeu_test +4 -0
- data/config/rubocop_enabled.yml +5 -10
- data/examples/borders_app.rb +2 -1
- data/examples/colours_app.rb +13 -8
- data/examples/configuration_app.rb +3 -2
- data/examples/cursor_app.rb +16 -11
- data/examples/drb_app.rb +88 -89
- data/examples/focus_app.rb +31 -32
- data/examples/geometry_app.rb +2 -1
- data/examples/hello_world.rb +2 -1
- data/examples/lines_app.rb +2 -1
- data/examples/material_colours_app.rb +126 -0
- data/examples/typed_commands/typed_commands_app.rb +5 -1
- data/examples/view_templates_app/view_templates_app.rb +6 -3
- data/lib/vedeu/all.rb +1 -1
- data/lib/vedeu/api.rb +18 -10
- data/lib/vedeu/application.rb +0 -1
- data/lib/vedeu/bindings.rb +77 -16
- data/lib/vedeu/buffers/all.rb +2 -5
- data/lib/vedeu/buffers/buffer.rb +69 -25
- data/lib/vedeu/buffers/display_buffer.rb +3 -7
- data/lib/vedeu/configuration/all.rb +3 -6
- data/lib/vedeu/configuration/api.rb +28 -4
- data/lib/vedeu/configuration/cli.rb +9 -9
- data/lib/vedeu/configuration/configuration.rb +11 -7
- data/lib/vedeu/cursor/all.rb +3 -6
- data/lib/vedeu/cursor/cursor.rb +22 -14
- data/lib/vedeu/cursor/move.rb +32 -22
- data/lib/vedeu/cursor/refresh_cursor.rb +1 -1
- data/lib/vedeu/debug.rb +2 -1
- data/lib/vedeu/distributed/client.rb +1 -7
- data/lib/vedeu/distributed/server.rb +0 -4
- data/lib/vedeu/distributed/subprocess.rb +1 -1
- data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -1
- data/lib/vedeu/distributed/test_application.rb +3 -5
- data/lib/vedeu/distributed/uri.rb +2 -2
- data/lib/vedeu/dsl/all.rb +6 -6
- data/lib/vedeu/dsl/components/all.rb +0 -3
- data/lib/vedeu/dsl/components/border.rb +20 -12
- data/lib/vedeu/dsl/components/geometry.rb +68 -3
- data/lib/vedeu/dsl/components/keymap.rb +1 -2
- data/lib/vedeu/dsl/composition.rb +8 -1
- data/lib/vedeu/dsl/interface.rb +61 -11
- data/lib/vedeu/dsl/line.rb +12 -12
- data/lib/vedeu/dsl/shared/all.rb +4 -7
- data/lib/vedeu/dsl/shared/colour.rb +2 -2
- data/lib/vedeu/dsl/shared/text.rb +2 -35
- data/lib/vedeu/dsl/shared/use.rb +2 -2
- data/lib/vedeu/dsl/view.rb +4 -4
- data/lib/vedeu/events/all.rb +3 -5
- data/lib/vedeu/events/event.rb +5 -5
- data/lib/vedeu/geometry/all.rb +11 -16
- data/lib/vedeu/geometry/area.rb +2 -5
- data/lib/vedeu/geometry/canvas.rb +12 -16
- data/lib/vedeu/geometry/dimension.rb +20 -22
- data/lib/vedeu/geometry/geometry.rb +28 -30
- data/lib/vedeu/geometry/grid.rb +1 -1
- data/lib/vedeu/geometry/index_position.rb +7 -0
- data/lib/vedeu/geometry/null_geometry.rb +61 -0
- data/lib/vedeu/geometry/position.rb +0 -3
- data/lib/vedeu/geometry/position_index.rb +7 -0
- data/lib/vedeu/geometry/position_validator.rb +44 -33
- data/lib/vedeu/input/all.rb +5 -4
- data/lib/vedeu/input/keymap.rb +0 -1
- data/lib/vedeu/input/mapper.rb +1 -3
- data/lib/vedeu/launcher.rb +6 -7
- data/lib/vedeu/main_loop.rb +1 -2
- data/lib/vedeu/models/all.rb +1 -0
- data/lib/vedeu/models/cell.rb +5 -8
- data/lib/vedeu/models/char.rb +50 -15
- data/lib/vedeu/models/composition.rb +8 -1
- data/lib/vedeu/models/focus.rb +4 -4
- data/lib/vedeu/models/group.rb +3 -3
- data/lib/vedeu/models/interface.rb +62 -46
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/models/null.rb +48 -0
- data/lib/vedeu/models/stream.rb +5 -5
- data/lib/vedeu/output/all.rb +20 -30
- data/lib/vedeu/output/border.rb +93 -40
- data/lib/vedeu/output/clear.rb +100 -15
- data/lib/vedeu/output/colour.rb +56 -12
- data/lib/vedeu/output/compressor.rb +59 -0
- data/lib/vedeu/output/html_char.rb +4 -2
- data/lib/vedeu/output/null_border.rb +16 -4
- data/lib/vedeu/output/output.rb +13 -21
- data/lib/vedeu/output/presentation.rb +28 -23
- data/lib/vedeu/output/refresh.rb +2 -2
- data/lib/vedeu/output/renderers/all.rb +80 -3
- data/lib/vedeu/output/renderers/file_renderer.rb +38 -2
- data/lib/vedeu/output/renderers/html_renderer.rb +6 -4
- data/lib/vedeu/output/renderers/json_renderer.rb +52 -0
- data/lib/vedeu/output/renderers/null_renderer.rb +14 -0
- data/lib/vedeu/output/renderers/terminal_renderer.rb +2 -12
- data/lib/vedeu/output/style.rb +33 -3
- data/lib/vedeu/output/text.rb +98 -1
- data/lib/vedeu/output/translator.rb +30 -7
- data/lib/vedeu/output/viewport.rb +43 -79
- data/lib/vedeu/output/wordwrap.rb +4 -4
- data/lib/vedeu/repositories/all.rb +22 -179
- data/lib/vedeu/repositories/collection.rb +11 -13
- data/lib/vedeu/repositories/collections/all.rb +8 -0
- data/lib/vedeu/repositories/collections/chars.rb +9 -0
- data/lib/vedeu/repositories/collections/events.rb +9 -0
- data/lib/vedeu/repositories/collections/interfaces.rb +9 -0
- data/lib/vedeu/repositories/collections/keys.rb +9 -0
- data/lib/vedeu/repositories/collections/lines.rb +9 -0
- data/lib/vedeu/repositories/collections/streams.rb +9 -0
- data/lib/vedeu/repositories/model.rb +7 -2
- data/lib/vedeu/repositories/repositories/all.rb +14 -0
- data/lib/vedeu/repositories/repositories/background_colours.rb +14 -0
- data/lib/vedeu/repositories/repositories/borders.rb +38 -0
- data/lib/vedeu/repositories/repositories/buffers.rb +36 -0
- data/lib/vedeu/repositories/repositories/colours.rb +63 -0
- data/lib/vedeu/repositories/repositories/cursors.rb +29 -0
- data/lib/vedeu/repositories/repositories/events_repository.rb +24 -0
- data/lib/vedeu/repositories/repositories/foreground_colours.rb +14 -0
- data/lib/vedeu/repositories/repositories/geometries.rb +37 -0
- data/lib/vedeu/repositories/repositories/groups.rb +24 -0
- data/lib/vedeu/repositories/repositories/interfaces_repository.rb +24 -0
- data/lib/vedeu/repositories/repositories/keymaps.rb +24 -0
- data/lib/vedeu/repositories/repositories/menus.rb +24 -0
- data/lib/vedeu/repositories/repository.rb +29 -47
- data/lib/vedeu/storage/all.rb +6 -0
- data/lib/vedeu/storage/associative_store.rb +47 -0
- data/lib/vedeu/storage/conveyor_store.rb +69 -0
- data/lib/vedeu/storage/fifo_store.rb +37 -0
- data/lib/vedeu/storage/store.rb +58 -0
- data/lib/vedeu/support/all.rb +5 -10
- data/lib/vedeu/support/common.rb +0 -8
- data/lib/vedeu/support/log.rb +13 -24
- data/lib/vedeu/support/template.rb +4 -1
- data/lib/vedeu/support/terminal.rb +10 -10
- data/lib/vedeu/support/trace.rb +15 -88
- data/lib/vedeu/support/visibility.rb +73 -0
- data/lib/vedeu.rb +37 -0
- data/test/lib/vedeu/api_test.rb +7 -3
- data/test/lib/vedeu/application_test.rb +9 -3
- data/test/lib/vedeu/bindings_test.rb +21 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +110 -134
- data/test/lib/vedeu/buffers/display_buffer_test.rb +8 -0
- data/test/lib/vedeu/configuration/api_test.rb +5 -1
- data/test/lib/vedeu/configuration/configuration_test.rb +4 -6
- data/test/lib/vedeu/cursor/cursor_test.rb +25 -17
- data/test/lib/vedeu/cursor/move_test.rb +7 -7
- data/test/lib/vedeu/distributed/client_test.rb +1 -1
- data/test/lib/vedeu/distributed/subprocess_test.rb +3 -1
- data/test/lib/vedeu/distributed/uri_test.rb +5 -5
- data/test/lib/vedeu/dsl/components/geometry_test.rb +43 -0
- data/test/lib/vedeu/dsl/components/keymap_test.rb +1 -1
- data/test/lib/vedeu/dsl/composition_test.rb +6 -5
- data/test/lib/vedeu/dsl/interface_test.rb +81 -16
- data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -4
- data/test/lib/vedeu/dsl/shared/text_test.rb +87 -9
- data/test/lib/vedeu/dsl/stream_test.rb +1 -1
- data/test/lib/vedeu/events/event_test.rb +3 -1
- data/test/lib/vedeu/events/trigger_test.rb +8 -4
- data/test/lib/vedeu/geometry/dimension_test.rb +1 -1
- data/test/lib/vedeu/geometry/geometry_test.rb +5 -3
- data/test/lib/vedeu/geometry/index_position_test.rb +30 -7
- data/test/lib/vedeu/geometry/null_geometry_test.rb +57 -0
- data/test/lib/vedeu/geometry/position_index_test.rb +14 -0
- data/test/lib/vedeu/geometry/position_validator_test.rb +17 -3
- data/test/lib/vedeu/input/keymap_test.rb +3 -1
- data/test/lib/vedeu/input/mapper_test.rb +8 -4
- data/test/lib/vedeu/launcher_test.rb +1 -1
- data/test/lib/vedeu/models/cell_test.rb +10 -8
- data/test/lib/vedeu/models/char_test.rb +52 -28
- data/test/lib/vedeu/models/composition_test.rb +26 -4
- data/test/lib/vedeu/models/group_test.rb +11 -5
- data/test/lib/vedeu/models/interface_test.rb +32 -19
- data/test/lib/vedeu/models/line_test.rb +21 -25
- data/test/lib/vedeu/models/menu_test.rb +10 -6
- data/test/lib/vedeu/models/null_test.rb +66 -0
- data/test/lib/vedeu/models/stream_test.rb +13 -10
- data/test/lib/vedeu/output/border_test.rb +29 -8
- data/test/lib/vedeu/output/clear_test.rb +23 -4
- data/test/lib/vedeu/output/colour_test.rb +20 -4
- data/test/lib/vedeu/output/compressor_test.rb +43 -0
- data/test/lib/vedeu/output/html_char_test.rb +29 -17
- data/test/lib/vedeu/output/null_border_test.rb +2 -1
- data/test/lib/vedeu/output/output_test.rb +20 -30
- data/test/lib/vedeu/output/presentation_test.rb +39 -16
- data/test/lib/vedeu/output/refresh_test.rb +14 -10
- data/test/lib/vedeu/output/renderers/all_test.rb +96 -0
- data/test/lib/vedeu/output/renderers/file_renderer_test.rb +1 -1
- data/test/lib/vedeu/output/renderers/html_renderer_test.rb +13 -9
- data/test/lib/vedeu/output/renderers/json_renderer_test.rb +52 -0
- data/test/lib/vedeu/output/renderers/null_renderer_test.rb +19 -0
- data/test/lib/vedeu/output/style_test.rb +41 -1
- data/test/lib/vedeu/output/text_test.rb +61 -10
- data/test/lib/vedeu/output/translator_test.rb +14 -0
- data/test/lib/vedeu/output/viewport_test.rb +22 -3
- data/test/lib/vedeu/output/virtual_terminal_test.rb +3 -3
- data/test/lib/vedeu/output/wordwrap_test.rb +58 -45
- data/test/lib/vedeu/repositories/collections/chars_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/events_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/interfaces_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/keys_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/lines_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/streams_test.rb +16 -0
- data/test/lib/vedeu/repositories/repositories/background_colours_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/borders_test.rb +51 -0
- data/test/lib/vedeu/repositories/repositories/buffers_test.rb +52 -0
- data/test/lib/vedeu/repositories/repositories/colours_test.rb +16 -0
- data/test/lib/vedeu/repositories/repositories/cursors_test.rb +39 -0
- data/test/lib/vedeu/repositories/repositories/events_repository_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/foreground_colours_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/geometries_test.rb +42 -0
- data/test/lib/vedeu/repositories/repositories/groups_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/interfaces_repositories_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/keymaps_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/menus_test.rb +17 -0
- data/test/lib/vedeu/repositories/repository_test.rb +16 -36
- data/test/lib/vedeu/storage/associative_store_test.rb +69 -0
- data/test/lib/vedeu/storage/conveyor_store_test.rb +135 -0
- data/test/lib/vedeu/storage/fifo_store_test.rb +47 -0
- data/test/lib/vedeu/storage/store_test.rb +123 -0
- data/test/lib/vedeu/support/common_test.rb +0 -9
- data/test/lib/vedeu/support/terminal_test.rb +78 -55
- data/test/lib/vedeu/support/visibility_test.rb +80 -0
- data/test/test_helper.rb +13 -11
- data/vedeu.gemspec +4 -3
- metadata +92 -32
- data/lib/vedeu/cursor/toggle.rb +0 -55
- data/lib/vedeu/exceptions.rb +0 -37
- data/lib/vedeu/geometry/centre.rb +0 -85
- data/lib/vedeu/geometry/content.rb +0 -70
- data/lib/vedeu/geometry/limit.rb +0 -58
- data/lib/vedeu/output/compositor.rb +0 -62
- data/lib/vedeu/repositories/collections.rb +0 -41
- data/lib/vedeu/support/coercions.rb +0 -60
- data/lib/vedeu/support/sentence.rb +0 -91
- data/lib/vedeu/support/visible.rb +0 -90
- data/test/lib/vedeu/cursor/toggle_test.rb +0 -63
- data/test/lib/vedeu/geometry/centre_test.rb +0 -58
- data/test/lib/vedeu/geometry/content_test.rb +0 -98
- data/test/lib/vedeu/geometry/limit_test.rb +0 -30
- data/test/lib/vedeu/output/compositor_test.rb +0 -48
- data/test/lib/vedeu/repositories/all_test.rb +0 -135
- data/test/lib/vedeu/repositories/collections_test.rb +0 -71
- data/test/lib/vedeu/support/coercions_test.rb +0 -84
- data/test/lib/vedeu/support/sentence_test.rb +0 -56
- data/test/lib/vedeu/support/visible_test.rb +0 -161
data/lib/vedeu/events/event.rb
CHANGED
@@ -40,7 +40,7 @@ module Vedeu
|
|
40
40
|
# Register an event by name with optional delay (throttling) which when
|
41
41
|
# triggered will execute the code contained within the passed block.
|
42
42
|
#
|
43
|
-
# @param name [Symbol] The name of the event
|
43
|
+
# @param name [Symbol] The name of the event to be triggered later.
|
44
44
|
# @param options [Hash] The options to register the event with.
|
45
45
|
# @option options :delay [Fixnum|Float] Limits the execution of the
|
46
46
|
# triggered event to only execute when first triggered, with subsequent
|
@@ -49,8 +49,8 @@ module Vedeu
|
|
49
49
|
# triggered event to only execute once the debounce has expired.
|
50
50
|
# Subsequent triggers before debounce expiry are ignored.
|
51
51
|
# @param block [Proc] The event to be executed when triggered. This block
|
52
|
-
# could be a method call, or the triggering of another event, or
|
53
|
-
# of either/both.
|
52
|
+
# could be a method call, or the triggering of another event, or
|
53
|
+
# sequence of either/both.
|
54
54
|
#
|
55
55
|
# @example
|
56
56
|
# Vedeu.bind :my_event do |some, args|
|
@@ -218,7 +218,7 @@ module Vedeu
|
|
218
218
|
def debouncing?
|
219
219
|
set_time
|
220
220
|
|
221
|
-
set_deadline unless
|
221
|
+
set_deadline unless deadline?
|
222
222
|
|
223
223
|
options[:debounce] > 0
|
224
224
|
end
|
@@ -259,7 +259,7 @@ module Vedeu
|
|
259
259
|
# Returns a boolean indicating if this event has a deadline.
|
260
260
|
#
|
261
261
|
# @return [Boolean]
|
262
|
-
def
|
262
|
+
def deadline?
|
263
263
|
@deadline > 0
|
264
264
|
end
|
265
265
|
|
data/lib/vedeu/geometry/all.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
require 'vedeu/geometry/position'
|
13
|
-
require 'vedeu/geometry/position_validator'
|
14
|
-
|
15
|
-
module Vedeu
|
16
|
-
end # Vedeu
|
1
|
+
require_relative 'area'
|
2
|
+
require_relative 'canvas'
|
3
|
+
require_relative 'coordinate'
|
4
|
+
require_relative 'dimension'
|
5
|
+
require_relative 'geometry'
|
6
|
+
require_relative 'grid'
|
7
|
+
require_relative 'index_position'
|
8
|
+
require_relative 'null_geometry'
|
9
|
+
require_relative 'position_index'
|
10
|
+
require_relative 'position'
|
11
|
+
require_relative 'position_validator'
|
data/lib/vedeu/geometry/area.rb
CHANGED
@@ -58,11 +58,8 @@ module Vedeu
|
|
58
58
|
# @param other [Vedeu::Area]
|
59
59
|
# @return [Boolean]
|
60
60
|
def eql?(other)
|
61
|
-
self.class == other.class &&
|
62
|
-
|
63
|
-
yn == other.yn &&
|
64
|
-
x == other.x &&
|
65
|
-
xn == other.xn
|
61
|
+
self.class == other.class && y == other.y && yn == other.yn &&
|
62
|
+
x == other.x && xn == other.xn
|
66
63
|
end
|
67
64
|
alias_method :==, :eql?
|
68
65
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
|
3
1
|
module Vedeu
|
4
2
|
|
5
3
|
# The size of the terminal is a limitation. Defining a canvas means we have
|
@@ -9,6 +7,18 @@ module Vedeu
|
|
9
7
|
|
10
8
|
include Singleton
|
11
9
|
|
10
|
+
# @!attribute [r] yn
|
11
|
+
# @return [Fixnum]
|
12
|
+
attr_reader :yn
|
13
|
+
alias_method :bottom, :yn
|
14
|
+
alias_method :height, :yn
|
15
|
+
|
16
|
+
# @!attribute [r] xn
|
17
|
+
# @return [Fixnum]
|
18
|
+
attr_reader :xn
|
19
|
+
alias_method :right, :xn
|
20
|
+
alias_method :width, :xn
|
21
|
+
|
12
22
|
# @return [Vedeu::Canvas]
|
13
23
|
def self.canvas
|
14
24
|
instance
|
@@ -64,26 +74,12 @@ module Vedeu
|
|
64
74
|
end
|
65
75
|
alias_method :top, :y
|
66
76
|
|
67
|
-
# @return [Fixnum]
|
68
|
-
def yn
|
69
|
-
@yn
|
70
|
-
end
|
71
|
-
alias_method :bottom, :yn
|
72
|
-
alias_method :height, :yn
|
73
|
-
|
74
77
|
# @return [Fixnum]
|
75
78
|
def x
|
76
79
|
1
|
77
80
|
end
|
78
81
|
alias_method :left, :x
|
79
82
|
|
80
|
-
# @return [Fixnum]
|
81
|
-
def xn
|
82
|
-
@xn
|
83
|
-
end
|
84
|
-
alias_method :right, :xn
|
85
|
-
alias_method :width, :xn
|
86
|
-
|
87
83
|
end # Canvas
|
88
84
|
|
89
85
|
end # Vedeu
|
@@ -45,50 +45,51 @@ module Vedeu
|
|
45
45
|
private
|
46
46
|
|
47
47
|
# @!attribute [r] d
|
48
|
-
# @return [Fixnum]
|
48
|
+
# @return [Fixnum|NilClass]
|
49
49
|
attr_reader :d
|
50
50
|
|
51
51
|
# @!attribute [r] dn
|
52
|
-
# @return [Fixnum]
|
52
|
+
# @return [Fixnum|NilClass]
|
53
53
|
attr_reader :dn
|
54
54
|
|
55
55
|
# @!attribute [r] d_dn
|
56
|
-
# @return [Fixnum]
|
56
|
+
# @return [Fixnum|NilClass]
|
57
57
|
attr_reader :d_dn
|
58
58
|
|
59
59
|
# @!attribute [r] default
|
60
|
-
# @return [Fixnum]
|
60
|
+
# @return [Fixnum|NilClass]
|
61
61
|
attr_reader :default
|
62
62
|
|
63
63
|
# @return [Array<Fixnum>]
|
64
64
|
def dimension
|
65
65
|
@dimension ||= if centred? && length?
|
66
|
-
|
66
|
+
[(default / 2) - (length / 2),
|
67
|
+
(default / 2) + (length / 2)]
|
67
68
|
|
68
|
-
|
69
|
-
|
69
|
+
elsif d && dn
|
70
|
+
[d, dn]
|
70
71
|
|
71
|
-
|
72
|
-
|
72
|
+
elsif d && d_dn
|
73
|
+
[d, ((d + d_dn) - 1)]
|
73
74
|
|
74
|
-
|
75
|
-
|
75
|
+
elsif d_dn
|
76
|
+
[1, d_dn]
|
76
77
|
|
77
|
-
|
78
|
-
|
78
|
+
elsif d
|
79
|
+
[d, default]
|
79
80
|
|
80
|
-
|
81
|
-
|
81
|
+
elsif dn
|
82
|
+
[1, dn]
|
82
83
|
|
83
|
-
|
84
|
-
|
84
|
+
else
|
85
|
+
[1, default]
|
85
86
|
|
86
|
-
|
87
|
+
end
|
87
88
|
end
|
88
89
|
|
89
90
|
# @return [Boolean]
|
90
91
|
def length?
|
91
|
-
|
92
|
+
default && length
|
92
93
|
end
|
93
94
|
|
94
95
|
# @return [Fixnum|NilClass]
|
@@ -102,9 +103,6 @@ module Vedeu
|
|
102
103
|
elsif default
|
103
104
|
default
|
104
105
|
|
105
|
-
else
|
106
|
-
nil
|
107
|
-
|
108
106
|
end
|
109
107
|
end
|
110
108
|
|
@@ -33,24 +33,24 @@ module Vedeu
|
|
33
33
|
include Vedeu::Model
|
34
34
|
|
35
35
|
def_delegators :area,
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
36
|
+
:north,
|
37
|
+
:east,
|
38
|
+
:south,
|
39
|
+
:west,
|
40
|
+
:top,
|
41
|
+
:right,
|
42
|
+
:bottom,
|
43
|
+
:left,
|
44
|
+
:y,
|
45
|
+
:xn,
|
46
|
+
:yn,
|
47
|
+
:x,
|
48
|
+
:height,
|
49
|
+
:width,
|
50
|
+
:top_left,
|
51
|
+
:top_right,
|
52
|
+
:bottom_left,
|
53
|
+
:bottom_right
|
54
54
|
|
55
55
|
# @!attribute [rw] centred
|
56
56
|
# @return [Boolean]
|
@@ -122,22 +122,20 @@ module Vedeu
|
|
122
122
|
|
123
123
|
# @return [Array<Fixnum>]
|
124
124
|
def x_xn
|
125
|
-
@x_xn ||= Vedeu::Dimension.pair(
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
})
|
125
|
+
@x_xn ||= Vedeu::Dimension.pair(d: _x,
|
126
|
+
dn: _xn,
|
127
|
+
d_dn: @width,
|
128
|
+
default: Vedeu::Terminal.width,
|
129
|
+
options: { centred: centred })
|
131
130
|
end
|
132
131
|
|
133
132
|
# @return [Array<Fixnum>]
|
134
133
|
def y_yn
|
135
|
-
@y_yn ||= Vedeu::Dimension.pair(
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
})
|
134
|
+
@y_yn ||= Vedeu::Dimension.pair(d: _y,
|
135
|
+
dn: _yn,
|
136
|
+
d_dn: @height,
|
137
|
+
default: Vedeu::Terminal.height,
|
138
|
+
options: { centred: centred })
|
141
139
|
end
|
142
140
|
|
143
141
|
# Returns the row/line start position for the interface.
|
data/lib/vedeu/geometry/grid.rb
CHANGED
@@ -51,6 +51,13 @@ module Vedeu
|
|
51
51
|
Vedeu::Position.new(y, x)
|
52
52
|
end
|
53
53
|
|
54
|
+
# @param other [Vedeu::IndexPosition]
|
55
|
+
# @return [Boolean]
|
56
|
+
def eql?(other)
|
57
|
+
self.class == other.class && (x == other.x && y == other.y)
|
58
|
+
end
|
59
|
+
alias_method :==, :eql?
|
60
|
+
|
54
61
|
# @return [Fixnum]
|
55
62
|
def y
|
56
63
|
(iy <= 0) ? oy : (iy + oy)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Provides geometry for interfaces that do not have geometry defined.
|
4
|
+
#
|
5
|
+
class NullGeometry
|
6
|
+
|
7
|
+
extend Forwardable
|
8
|
+
|
9
|
+
def_delegators :area,
|
10
|
+
:north,
|
11
|
+
:east,
|
12
|
+
:south,
|
13
|
+
:west,
|
14
|
+
:top,
|
15
|
+
:right,
|
16
|
+
:bottom,
|
17
|
+
:left,
|
18
|
+
:y,
|
19
|
+
:xn,
|
20
|
+
:yn,
|
21
|
+
:x,
|
22
|
+
:height,
|
23
|
+
:width,
|
24
|
+
:top_left,
|
25
|
+
:top_right,
|
26
|
+
:bottom_left,
|
27
|
+
:bottom_right
|
28
|
+
|
29
|
+
# @return [Vedeu::NullGeometry]
|
30
|
+
def initialize; end
|
31
|
+
|
32
|
+
# @return [FalseClass]
|
33
|
+
def centred
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [Vedeu::NullGeometry]
|
38
|
+
def store
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# @return [Vedeu::Area]
|
45
|
+
def area
|
46
|
+
@area ||= Vedeu::Area.from_dimensions(y_yn: y_yn, x_xn: x_xn)
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [Array<Fixnum>]
|
50
|
+
def x_xn
|
51
|
+
@x_xn ||= Vedeu::Dimension.pair(default: Vedeu::Terminal.width)
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [Array<Fixnum>]
|
55
|
+
def y_yn
|
56
|
+
@y_yn ||= Vedeu::Dimension.pair(default: Vedeu::Terminal.height)
|
57
|
+
end
|
58
|
+
|
59
|
+
end # NullGeometry
|
60
|
+
|
61
|
+
end # Vedeu
|
@@ -35,6 +35,13 @@ module Vedeu
|
|
35
35
|
[y, x]
|
36
36
|
end
|
37
37
|
|
38
|
+
# @param other [Vedeu::PositionIndex]
|
39
|
+
# @return [Boolean]
|
40
|
+
def eql?(other)
|
41
|
+
self.class == other.class && (x == other.x && y == other.y)
|
42
|
+
end
|
43
|
+
alias_method :==, :eql?
|
44
|
+
|
38
45
|
# @return [Vedeu::Position]
|
39
46
|
def to_position
|
40
47
|
Vedeu::Position.new(y, x)
|
@@ -3,34 +3,30 @@ require 'vedeu/support/terminal'
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
5
|
# Validates that the provided coordinates are within the terminal and
|
6
|
-
# interface (with or without a border).
|
6
|
+
# interface's geometry (with or without a border).
|
7
7
|
#
|
8
8
|
class PositionValidator
|
9
9
|
|
10
10
|
extend Forwardable
|
11
11
|
|
12
|
-
def_delegators
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def_delegators :interface,
|
19
|
-
:border?,
|
20
|
-
:border,
|
21
|
-
:geometry
|
12
|
+
def_delegators :terminal,
|
13
|
+
:tx,
|
14
|
+
:ty,
|
15
|
+
:txn,
|
16
|
+
:tyn
|
22
17
|
|
23
18
|
def_delegators :border,
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
:enabled?,
|
20
|
+
:left?,
|
21
|
+
:right?,
|
22
|
+
:top?,
|
23
|
+
:bottom?
|
28
24
|
|
29
25
|
def_delegators :geometry,
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
:left,
|
27
|
+
:right,
|
28
|
+
:top,
|
29
|
+
:bottom
|
34
30
|
|
35
31
|
# @!attribute [rw] x
|
36
32
|
# @return [Fixnum]
|
@@ -41,36 +37,41 @@ module Vedeu
|
|
41
37
|
attr_accessor :y
|
42
38
|
|
43
39
|
# @param (see #initialize)
|
44
|
-
def self.validate(
|
45
|
-
new(
|
40
|
+
def self.validate(name, x, y)
|
41
|
+
new(name, x, y).validate
|
46
42
|
end
|
47
43
|
|
48
44
|
# Returns a new instance of Vedeu::PositionValidator.
|
49
45
|
#
|
50
|
-
# @param
|
46
|
+
# @param name [String]
|
51
47
|
# @param x [Fixnum]
|
52
48
|
# @param y [Fixnum]
|
53
49
|
# @return [PositionValidator]
|
54
|
-
def initialize(
|
55
|
-
@
|
56
|
-
@x
|
57
|
-
@y
|
50
|
+
def initialize(name, x, y)
|
51
|
+
@name = name
|
52
|
+
@x = x
|
53
|
+
@y = y
|
58
54
|
end
|
59
55
|
|
60
56
|
# @return [PositionValidator]
|
61
57
|
def validate
|
62
58
|
terminal_validation
|
63
59
|
interface_validation
|
64
|
-
border_validation if
|
60
|
+
border_validation if enabled?
|
65
61
|
|
66
62
|
self
|
67
63
|
end
|
68
64
|
|
69
65
|
private
|
70
66
|
|
71
|
-
# @!attribute [r]
|
72
|
-
# @return [
|
73
|
-
attr_reader :
|
67
|
+
# @!attribute [r] name
|
68
|
+
# @return [String]
|
69
|
+
attr_reader :name
|
70
|
+
|
71
|
+
# @return [Vedeu::Terminal]
|
72
|
+
def terminal
|
73
|
+
Vedeu::Terminal
|
74
|
+
end
|
74
75
|
|
75
76
|
# Validate the x and y coordinates are within the dimensions of the
|
76
77
|
# terminal.
|
@@ -103,14 +104,24 @@ module Vedeu
|
|
103
104
|
#
|
104
105
|
# @return [PositionValidator]
|
105
106
|
def border_validation
|
106
|
-
@x = left + 1 if left?
|
107
|
-
@x = right - 2 if right?
|
108
|
-
@y = top + 1 if top?
|
107
|
+
@x = left + 1 if left? && x < (left + 1)
|
108
|
+
@x = right - 2 if right? && x > (right - 1)
|
109
|
+
@y = top + 1 if top? && y < (top + 1)
|
109
110
|
@y = bottom - 2 if bottom? && y > (bottom - 1)
|
110
111
|
|
111
112
|
self
|
112
113
|
end
|
113
114
|
|
115
|
+
# @return [Vedeu::Border|Vedeu::NullBorder|NilClass]
|
116
|
+
def border
|
117
|
+
@border ||= Vedeu.borders.by_name(name)
|
118
|
+
end
|
119
|
+
|
120
|
+
# @return [Vedeu::Geometry|Vedeu::NullGeometry]
|
121
|
+
def geometry
|
122
|
+
@geometry ||= Vedeu.geometries.by_name(name)
|
123
|
+
end
|
124
|
+
|
114
125
|
end # PositionValidator
|
115
126
|
|
116
127
|
end # Vedeu
|
data/lib/vedeu/input/all.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'vedeu/repositories/all'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
|
3
|
+
require_relative 'mapper'
|
4
|
+
require_relative 'key'
|
5
|
+
require_relative 'input'
|
6
|
+
require_relative 'keymap'
|
6
7
|
|
7
8
|
module Vedeu
|
8
9
|
|
data/lib/vedeu/input/keymap.rb
CHANGED
data/lib/vedeu/input/mapper.rb
CHANGED
data/lib/vedeu/launcher.rb
CHANGED
@@ -20,11 +20,7 @@ module Vedeu
|
|
20
20
|
stdout = STDOUT,
|
21
21
|
stderr = STDERR,
|
22
22
|
kernel = Kernel)
|
23
|
-
new(argv,
|
24
|
-
stdin = STDIN,
|
25
|
-
stdout = STDOUT,
|
26
|
-
stderr = STDERR,
|
27
|
-
kernel = Kernel).debug_execute!
|
23
|
+
new(argv, stdin, stdout, stderr, kernel).debug_execute!
|
28
24
|
end
|
29
25
|
|
30
26
|
# Returns a new instance of Vedeu::Launcher.
|
@@ -72,7 +68,6 @@ module Vedeu
|
|
72
68
|
rescue StandardError => uncaught_exception
|
73
69
|
puts uncaught_exception.message
|
74
70
|
puts uncaught_exception.backtrace.join("\n") if configuration.debug?
|
75
|
-
|
76
71
|
end
|
77
72
|
|
78
73
|
private
|
@@ -85,13 +80,17 @@ module Vedeu
|
|
85
80
|
#
|
86
81
|
# @return [void]
|
87
82
|
def terminate!
|
88
|
-
Vedeu.log(type: :info, message:
|
83
|
+
Vedeu.log(type: :info, message: 'Exiting gracefully.')
|
89
84
|
|
90
85
|
$stdin, $stdout, $stderr = STDIN, STDOUT, STDERR
|
91
86
|
|
92
87
|
@kernel.exit(exit_code)
|
93
88
|
end
|
94
89
|
|
90
|
+
# Use the arguments passed on the command-line along with those defined by
|
91
|
+
# the client application and Vedeu's defaults to configure the client
|
92
|
+
# application.
|
93
|
+
#
|
95
94
|
# @return [Vedeu::Configuration]
|
96
95
|
def configuration
|
97
96
|
Vedeu::Configuration.configure(argv)
|
data/lib/vedeu/main_loop.rb
CHANGED
data/lib/vedeu/models/all.rb
CHANGED
data/lib/vedeu/models/cell.rb
CHANGED
@@ -30,7 +30,8 @@ module Vedeu
|
|
30
30
|
|
31
31
|
# Returns a new instance of Vedeu::Cell.
|
32
32
|
#
|
33
|
-
# @param attributes [Hash<Symbol => Array<Symbol|String>,
|
33
|
+
# @param attributes [Hash<Symbol => Array<Symbol|String>,
|
34
|
+
# Fixnum, String, Symbol]
|
34
35
|
# @option attributes background [NilClass|String]
|
35
36
|
# @option attributes foreground [NilClass|String]
|
36
37
|
# @option attributes style [NilClass|Array<Symbol|String>|Symbol|String]
|
@@ -50,13 +51,9 @@ module Vedeu
|
|
50
51
|
# @param other [Vedeu::Cell]
|
51
52
|
# @return [Boolean]
|
52
53
|
def eql?(other)
|
53
|
-
self.class == other.class
|
54
|
-
|
55
|
-
|
56
|
-
style == other.style &&
|
57
|
-
value == other.value &&
|
58
|
-
x == other.x &&
|
59
|
-
y == other.y
|
54
|
+
self.class == other.class && background == other.background &&
|
55
|
+
foreground == other.foreground && style == other.style &&
|
56
|
+
value == other.value && x == other.x && y == other.y
|
60
57
|
end
|
61
58
|
alias_method :==, :eql?
|
62
59
|
|