vedeu 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu.rb +1 -1
- data/lib/vedeu/all.rb +2 -0
- data/lib/vedeu/buffers/buffer.rb +0 -11
- data/lib/vedeu/configuration/api.rb +4 -6
- data/lib/vedeu/configuration/cli.rb +1 -3
- data/lib/vedeu/configuration/configuration.rb +15 -0
- data/lib/vedeu/cursor/cursor.rb +2 -9
- data/lib/vedeu/cursor/move_cursor.rb +7 -9
- data/lib/vedeu/cursor/toggle_cursor.rb +2 -2
- data/lib/vedeu/debug.rb +3 -0
- data/lib/vedeu/distributed/test_application.rb +4 -8
- data/lib/vedeu/dsl/components/keymap.rb +1 -3
- data/lib/vedeu/dsl/composition.rb +2 -2
- data/lib/vedeu/dsl/interface.rb +2 -2
- data/lib/vedeu/dsl/shared/text.rb +2 -2
- data/lib/vedeu/events/event.rb +1 -1
- data/lib/vedeu/geometry/all.rb +10 -0
- data/lib/vedeu/{support → geometry}/bounding_area.rb +1 -0
- data/lib/vedeu/{support → geometry}/content_geometry.rb +0 -7
- data/lib/vedeu/{support → geometry}/coordinate.rb +0 -14
- data/lib/vedeu/{support → geometry}/grid.rb +0 -0
- data/lib/vedeu/{support → geometry}/limit.rb +0 -0
- data/lib/vedeu/{support → geometry}/position.rb +3 -5
- data/lib/vedeu/{support → geometry}/position_validator.rb +2 -0
- data/lib/vedeu/input/input.rb +1 -1
- data/lib/vedeu/input/key.rb +0 -13
- data/lib/vedeu/input/keymap.rb +1 -1
- data/lib/vedeu/models/focus.rb +2 -2
- data/lib/vedeu/models/geometry.rb +4 -51
- data/lib/vedeu/models/menu.rb +1 -1
- data/lib/vedeu/models/model.rb +1 -1
- data/lib/vedeu/models/view/char.rb +2 -9
- data/lib/vedeu/models/view/composition.rb +3 -10
- data/lib/vedeu/models/view/interface.rb +5 -13
- data/lib/vedeu/models/view/line.rb +3 -10
- data/lib/vedeu/models/view/stream.rb +18 -11
- data/lib/vedeu/output/background.rb +6 -21
- data/lib/vedeu/output/border.rb +26 -17
- data/lib/vedeu/output/colour.rb +1 -1
- data/lib/vedeu/output/foreground.rb +6 -21
- data/lib/vedeu/output/html_renderer.rb +3 -9
- data/lib/vedeu/output/output.rb +38 -11
- data/lib/vedeu/output/style.rb +1 -1
- data/lib/vedeu/output/translator.rb +45 -15
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/output/virtual_buffer.rb +2 -2
- data/lib/vedeu/output/wordwrap.rb +1 -1
- data/lib/vedeu/repositories/all.rb +9 -9
- data/lib/vedeu/repositories/repository.rb +0 -7
- data/lib/vedeu/support/all.rb +1 -7
- data/lib/vedeu/support/esc.rb +33 -11
- data/lib/vedeu/support/template.rb +39 -0
- data/lib/vedeu/support/terminal.rb +3 -3
- data/lib/vedeu/support/text.rb +1 -1
- data/lib/vedeu/support/trace.rb +4 -4
- data/lib/vedeu/support/visible.rb +2 -7
- data/test/lib/vedeu/buffers/buffer_test.rb +0 -6
- data/test/lib/vedeu/cursor/cursor_test.rb +0 -6
- data/test/lib/vedeu/{support → geometry}/bounding_area_test.rb +0 -0
- data/test/lib/vedeu/{support → geometry}/content_geometry_test.rb +0 -6
- data/test/lib/vedeu/{support → geometry}/coordinate_test.rb +0 -8
- data/test/lib/vedeu/{support → geometry}/grid_test.rb +0 -0
- data/test/lib/vedeu/{support → geometry}/limit_test.rb +0 -0
- data/test/lib/vedeu/{support → geometry}/position_test.rb +8 -6
- data/test/lib/vedeu/{support → geometry}/position_validator_test.rb +0 -0
- data/test/lib/vedeu/input/key_test.rb +0 -12
- data/test/lib/vedeu/models/geometry_test.rb +0 -47
- data/test/lib/vedeu/models/view/char_test.rb +5 -9
- data/test/lib/vedeu/models/view/composition_test.rb +2 -8
- data/test/lib/vedeu/models/view/interface_test.rb +2 -8
- data/test/lib/vedeu/models/view/line_test.rb +0 -6
- data/test/lib/vedeu/models/view/stream_test.rb +0 -6
- data/test/lib/vedeu/output/border_test.rb +2 -2
- data/test/lib/vedeu/output/html_renderer_test.rb +0 -1
- data/test/lib/vedeu/output/output_test.rb +39 -0
- data/test/lib/vedeu/repositories/repository_test.rb +0 -6
- data/test/lib/vedeu/support/template_test.rb +24 -0
- data/test/lib/vedeu/support/visible_test.rb +0 -6
- data/test/support/helpers/model_test_class.rb +1 -1
- data/vedeu.gemspec +1 -1
- metadata +27 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 194c0ec69e43bc4197b9cbd3be152b8be8c66ca5
|
4
|
+
data.tar.gz: 58b06a162a3b038247f82d69714e0a8cc601a38d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6438bc4ad946856c2a3f552e8256c9aeb05413d3f8d5d1a055a27fc7d7b88c08eeb1dbbf4d30c7aebd59852cb70b524d868dbbf89742eb64b3694acf41eb34c2
|
7
|
+
data.tar.gz: 8ff06714885c53271469daaa1a0b09825ad2aa1829090e66100c3820f03a7d7d3cca1a72d851f4512f57ea11217401389ecb1b2c9cf02cd586a1dfde18cf6673
|
data/lib/vedeu.rb
CHANGED
data/lib/vedeu/all.rb
CHANGED
data/lib/vedeu/buffers/buffer.rb
CHANGED
@@ -38,17 +38,6 @@ module Vedeu
|
|
38
38
|
@repository = repository || Vedeu.buffers
|
39
39
|
end
|
40
40
|
|
41
|
-
# Returns log friendly output.
|
42
|
-
#
|
43
|
-
# @return [String]
|
44
|
-
def inspect
|
45
|
-
"<#{self.class.name} ( " \
|
46
|
-
"back?:#{content_for?(:back)} " \
|
47
|
-
"front?:#{content_for?(:front)} " \
|
48
|
-
"previous?:#{content_for?(:previous)} " \
|
49
|
-
")>"
|
50
|
-
end
|
51
|
-
|
52
41
|
# Add the content to the back buffer, then update the repository. Returns
|
53
42
|
# boolean indicating that the repository was updated.
|
54
43
|
#
|
@@ -40,12 +40,10 @@ module Vedeu
|
|
40
40
|
# @return [Hash]
|
41
41
|
def configuration
|
42
42
|
options.merge!({
|
43
|
-
system_keys: Configuration.default_system_keys.merge(system_keys)
|
43
|
+
system_keys: Configuration.default_system_keys.merge!(system_keys)
|
44
44
|
}) if system_keys.any?
|
45
45
|
|
46
|
-
|
47
|
-
Vedeu.log(type: :config, message: "API #{option.to_s}: #{value.to_s}")
|
48
|
-
end
|
46
|
+
Vedeu::Config.log('API', options)
|
49
47
|
end
|
50
48
|
|
51
49
|
# Sets boolean to allow user input. The default behaviour of Vedeu is to
|
@@ -389,7 +387,7 @@ module Vedeu
|
|
389
387
|
#
|
390
388
|
# @return [Hash]
|
391
389
|
def options
|
392
|
-
@
|
390
|
+
@options ||= {}
|
393
391
|
end
|
394
392
|
|
395
393
|
# Returns the system keys set via the configuration API DSL or an empty
|
@@ -397,7 +395,7 @@ module Vedeu
|
|
397
395
|
#
|
398
396
|
# @return [Hash]
|
399
397
|
def system_keys
|
400
|
-
@
|
398
|
+
@system_keys ||= {}
|
401
399
|
end
|
402
400
|
|
403
401
|
# Checks that the value provided to {#colour_mode} is valid.
|
@@ -8,6 +8,21 @@ module Vedeu
|
|
8
8
|
# Namespace for the API configuration and CLI configuration classes.
|
9
9
|
#
|
10
10
|
module Config
|
11
|
+
|
12
|
+
extend self
|
13
|
+
|
14
|
+
# Custom log for configuration.
|
15
|
+
#
|
16
|
+
# @param from [String] Which configuration set the options ('API' or 'CLI').
|
17
|
+
# @param options [Hash] The configuration options set.
|
18
|
+
# @return [Hash] The options param.
|
19
|
+
def log(from, options)
|
20
|
+
options.each do |option, value|
|
21
|
+
Vedeu.log(type: :config,
|
22
|
+
message: "#{from} #{option.to_s}: #{value.to_s}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
11
26
|
end
|
12
27
|
|
13
28
|
# Allows the customisation of Vedeu's behaviour through the configuration API
|
data/lib/vedeu/cursor/cursor.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'vedeu/cursor/all'
|
2
2
|
require 'vedeu/models/model'
|
3
|
-
require 'vedeu/
|
3
|
+
require 'vedeu/geometry/position'
|
4
4
|
require 'vedeu/support/visible'
|
5
5
|
|
6
6
|
module Vedeu
|
@@ -41,7 +41,7 @@ module Vedeu
|
|
41
41
|
attributes = { name: attributes }
|
42
42
|
end
|
43
43
|
|
44
|
-
@attributes = defaults.merge(attributes)
|
44
|
+
@attributes = defaults.merge!(attributes)
|
45
45
|
|
46
46
|
@name = @attributes.fetch(:name)
|
47
47
|
@ox = @attributes.fetch(:ox)
|
@@ -54,13 +54,6 @@ module Vedeu
|
|
54
54
|
@position = Vedeu::Position.new(@y, @x)
|
55
55
|
end
|
56
56
|
|
57
|
-
# Returns log friendly output.
|
58
|
-
#
|
59
|
-
# @return [String]
|
60
|
-
def inspect
|
61
|
-
"<#{self.class.name} (#{@name}: x:#{@x} y:#{@y} ox:#{@ox} oy:#{@oy})>"
|
62
|
-
end
|
63
|
-
|
64
57
|
# Returns an escape sequence to position the cursor and set its visibility.
|
65
58
|
# When passed a block, will position the cursor, yield and return the
|
66
59
|
# original position.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'vedeu/cursor/cursor'
|
2
|
-
require 'vedeu/
|
3
|
-
require 'vedeu/
|
2
|
+
require 'vedeu/geometry/coordinate'
|
3
|
+
require 'vedeu/geometry/position_validator'
|
4
4
|
|
5
5
|
module Vedeu
|
6
6
|
|
@@ -17,19 +17,17 @@ module Vedeu
|
|
17
17
|
def_delegators :geometry, :left,
|
18
18
|
:top,
|
19
19
|
:height,
|
20
|
-
:width
|
21
|
-
:x,
|
22
|
-
:y
|
20
|
+
:width
|
23
21
|
|
24
22
|
# @param cursor [Cursor]
|
25
23
|
# @param interface [Interface]
|
26
24
|
# @param dy [Fixnum] Move up (-1), or down (1), or no action (0).
|
27
25
|
# @param dx [Fixnum] Move left (-1), or right (1), or no action (0).
|
28
26
|
# @return [MoveCursor]
|
29
|
-
def initialize(cursor, interface, dy, dx)
|
27
|
+
def initialize(cursor, interface, dy = 0, dx = 0)
|
30
28
|
@cursor = cursor
|
31
|
-
@dy = dy
|
32
|
-
@dx = dx
|
29
|
+
@dy = dy || 0
|
30
|
+
@dx = dx || 0
|
33
31
|
@interface = interface
|
34
32
|
end
|
35
33
|
|
@@ -76,7 +74,7 @@ module Vedeu
|
|
76
74
|
#
|
77
75
|
# @return [Cursor]
|
78
76
|
def move
|
79
|
-
Cursor.new(cursor.attributes.merge(moved_attributes)).store
|
77
|
+
Cursor.new(cursor.attributes.merge!(moved_attributes)).store
|
80
78
|
end
|
81
79
|
|
82
80
|
private
|
@@ -34,14 +34,14 @@ module Vedeu
|
|
34
34
|
#
|
35
35
|
# @return [Cursor]
|
36
36
|
def hide
|
37
|
-
cursor.class.new(cursor.attributes.merge({ state: false })).store
|
37
|
+
cursor.class.new(cursor.attributes.merge!({ state: false })).store
|
38
38
|
end
|
39
39
|
|
40
40
|
# Shows the cursor.
|
41
41
|
#
|
42
42
|
# @return [Cursor]
|
43
43
|
def show
|
44
|
-
cursor.class.new(cursor.attributes.merge({ state: true })).store
|
44
|
+
cursor.class.new(cursor.attributes.merge!({ state: true })).store
|
45
45
|
end
|
46
46
|
|
47
47
|
private
|
data/lib/vedeu/debug.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
1
|
module Vedeu
|
4
2
|
|
5
3
|
# Create a test application as a string.
|
@@ -45,7 +43,7 @@ module Vedeu
|
|
45
43
|
# @option attributes views [String]
|
46
44
|
# @return [TestApplication]
|
47
45
|
def initialize(attributes = {})
|
48
|
-
@attributes = defaults.merge(attributes)
|
46
|
+
@attributes = defaults.merge!(attributes)
|
49
47
|
|
50
48
|
@attributes.each do |k, v|
|
51
49
|
instance_variable_set("@#{k.to_s}", @attributes[k])
|
@@ -57,9 +55,7 @@ module Vedeu
|
|
57
55
|
def build(&block)
|
58
56
|
self.instance_eval(&block) if block_given?
|
59
57
|
|
60
|
-
|
61
|
-
|
62
|
-
ERB.new(application, nil, '-').result(binding)
|
58
|
+
Template.parse(self, template)
|
63
59
|
end
|
64
60
|
|
65
61
|
# @return [String]
|
@@ -70,8 +66,8 @@ module Vedeu
|
|
70
66
|
private
|
71
67
|
|
72
68
|
# @return [String]
|
73
|
-
def
|
74
|
-
|
69
|
+
def template
|
70
|
+
File.dirname(__FILE__) + '/templates/default_application.vedeu'
|
75
71
|
end
|
76
72
|
|
77
73
|
# @todo Don't like all this file reading.
|
@@ -38,10 +38,10 @@ module Vedeu
|
|
38
38
|
|
39
39
|
new_member = if Vedeu.interfaces.registered?(name)
|
40
40
|
existing_member = Vedeu.interfaces.find(name)
|
41
|
-
model.member.build(attributes.merge(existing_member.attributes), &block)
|
41
|
+
model.member.build(attributes.merge!(existing_member.attributes), &block)
|
42
42
|
|
43
43
|
else
|
44
|
-
model.member.build(attributes.merge({ name: name }), &block)
|
44
|
+
model.member.build(attributes.merge!({ name: name }), &block)
|
45
45
|
|
46
46
|
end
|
47
47
|
|
data/lib/vedeu/dsl/interface.rb
CHANGED
@@ -39,8 +39,8 @@ module Vedeu
|
|
39
39
|
def border(&block)
|
40
40
|
fail InvalidSyntax, 'block not given' unless block_given?
|
41
41
|
|
42
|
-
border_attrs = attributes.merge({ enabled: true,
|
43
|
-
|
42
|
+
border_attrs = attributes.merge!({ enabled: true,
|
43
|
+
name: model.name })
|
44
44
|
|
45
45
|
Vedeu::Border.build(border_attrs, &block).store
|
46
46
|
end
|
@@ -54,7 +54,7 @@ module Vedeu
|
|
54
54
|
# than the specified width.
|
55
55
|
# @return [String]
|
56
56
|
def text(value = '', options = {})
|
57
|
-
output = Vedeu::Text.with(value, options.merge({ anchor: __callee__ }))
|
57
|
+
output = Vedeu::Text.with(value, options.merge!({ anchor: __callee__ }))
|
58
58
|
|
59
59
|
content = if model.is_a?(Vedeu::Interface)
|
60
60
|
stream = stream_builder({ value: output })
|
@@ -94,7 +94,7 @@ module Vedeu
|
|
94
94
|
colour: model.colour,
|
95
95
|
parent: model,
|
96
96
|
style: model.style,
|
97
|
-
}.merge(attrs)
|
97
|
+
}.merge!(attrs)
|
98
98
|
end
|
99
99
|
|
100
100
|
end # Text
|
data/lib/vedeu/events/event.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'vedeu/geometry/bounding_area'
|
2
|
+
require 'vedeu/geometry/content_geometry'
|
3
|
+
require 'vedeu/geometry/coordinate'
|
4
|
+
require 'vedeu/geometry/grid'
|
5
|
+
require 'vedeu/geometry/limit'
|
6
|
+
require 'vedeu/geometry/position'
|
7
|
+
require 'vedeu/geometry/position_validator'
|
8
|
+
|
9
|
+
module Vedeu
|
10
|
+
end # Vedeu
|
@@ -23,13 +23,6 @@ module Vedeu
|
|
23
23
|
@interface = interface
|
24
24
|
end
|
25
25
|
|
26
|
-
# Returns log friendly output.
|
27
|
-
#
|
28
|
-
# @return [String]
|
29
|
-
def inspect
|
30
|
-
"<#{self.class.name} (y:#{y} x:#{x} yn:#{yn} xn:#{xn})>"
|
31
|
-
end
|
32
|
-
|
33
26
|
# Returns the height of the content, or when no content, the visible height
|
34
27
|
# of the interface.
|
35
28
|
#
|
@@ -21,20 +21,6 @@ module Vedeu
|
|
21
21
|
@y = y
|
22
22
|
end
|
23
23
|
|
24
|
-
# Returns log friendly output.
|
25
|
-
#
|
26
|
-
# @return [String]
|
27
|
-
def inspect
|
28
|
-
"<#{self.class.name} ( " \
|
29
|
-
"height:#{height} " \
|
30
|
-
"width:#{width} " \
|
31
|
-
"x:#{x} " \
|
32
|
-
"xn:#{xn} " \
|
33
|
-
"y:#{y} " \
|
34
|
-
"yn:#{yn} " \
|
35
|
-
")>"
|
36
|
-
end
|
37
|
-
|
38
24
|
# Returns the maximum y coordinate for an area.
|
39
25
|
#
|
40
26
|
# @example
|
File without changes
|
File without changes
|
@@ -21,6 +21,9 @@ module Vedeu
|
|
21
21
|
elsif value.is_a?(Array)
|
22
22
|
new(*value)
|
23
23
|
|
24
|
+
elsif value.is_a?(Hash)
|
25
|
+
new(value.fetch(:y, 1), value.fetch(:x, 1))
|
26
|
+
|
24
27
|
else
|
25
28
|
# not sure how to proceed
|
26
29
|
|
@@ -37,11 +40,6 @@ module Vedeu
|
|
37
40
|
@x = (x.nil? || x < 1) ? 1 : x
|
38
41
|
end
|
39
42
|
|
40
|
-
# @return [String]
|
41
|
-
def inspect
|
42
|
-
"<#{self.class.name} (y:#{@y} x:#{@x})>"
|
43
|
-
end
|
44
|
-
|
45
43
|
# @param other [Vedeu::Position]
|
46
44
|
# @return [Boolean]
|
47
45
|
def ==(other)
|
data/lib/vedeu/input/input.rb
CHANGED
data/lib/vedeu/input/key.rb
CHANGED
@@ -4,19 +4,6 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
class Key
|
6
6
|
|
7
|
-
class << self
|
8
|
-
|
9
|
-
# Creates a new instance of Key.
|
10
|
-
#
|
11
|
-
# @see Vedeu::Key#initialize
|
12
|
-
def build(input = nil, &block)
|
13
|
-
fail InvalidSyntax, 'block not given' unless block_given?
|
14
|
-
|
15
|
-
new(input, &block)
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
7
|
# Returns a new instance of Key.
|
21
8
|
#
|
22
9
|
# @param input [String|Symbol]
|