vedeu 0.5.5 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/examples/material_colours_app.rb +25 -0
  3. data/lib/vedeu/all.rb +0 -1
  4. data/lib/vedeu/colours/colour_translator.rb +6 -6
  5. data/lib/vedeu/cursor/cursor.rb +0 -12
  6. data/lib/vedeu/dsl.rb +23 -0
  7. data/lib/vedeu/dsl/border.rb +0 -10
  8. data/lib/vedeu/dsl/composition.rb +1 -19
  9. data/lib/vedeu/dsl/geometry.rb +0 -10
  10. data/lib/vedeu/dsl/group.rb +0 -10
  11. data/lib/vedeu/dsl/interface.rb +0 -20
  12. data/lib/vedeu/dsl/keymap.rb +0 -10
  13. data/lib/vedeu/dsl/line.rb +3 -21
  14. data/lib/vedeu/dsl/menu.rb +0 -10
  15. data/lib/vedeu/dsl/stream.rb +4 -10
  16. data/lib/vedeu/dsl/view.rb +0 -20
  17. data/lib/vedeu/geometry/geometry.rb +0 -13
  18. data/lib/vedeu/geometry/position.rb +11 -0
  19. data/lib/vedeu/models/escape.rb +0 -7
  20. data/lib/vedeu/models/interface.rb +4 -16
  21. data/lib/vedeu/models/views/all.rb +4 -5
  22. data/lib/vedeu/models/views/char.rb +21 -22
  23. data/lib/vedeu/models/views/{chars.rb → collections/chars.rb} +0 -0
  24. data/lib/vedeu/models/views/{lines.rb → collections/lines.rb} +0 -0
  25. data/lib/vedeu/models/views/{streams.rb → collections/streams.rb} +0 -0
  26. data/lib/vedeu/models/views/{view_collection.rb → collections/view_collection.rb} +0 -0
  27. data/lib/vedeu/models/views/composition.rb +17 -19
  28. data/lib/vedeu/models/views/line.rb +19 -31
  29. data/lib/vedeu/models/views/stream.rb +7 -20
  30. data/lib/vedeu/models/views/view.rb +22 -35
  31. data/lib/vedeu/output/html_char.rb +38 -28
  32. data/lib/vedeu/output/presentation/colour.rb +15 -44
  33. data/lib/vedeu/output/presentation/style.rb +7 -14
  34. data/lib/vedeu/output/viewport.rb +0 -3
  35. data/lib/vedeu/output/virtual_terminal.rb +2 -2
  36. data/lib/vedeu/repositories/repository.rb +0 -7
  37. data/lib/vedeu/version.rb +1 -1
  38. data/test/lib/vedeu/buffers/buffer_test.rb +4 -4
  39. data/test/lib/vedeu/colours/colour_translator_test.rb +14 -0
  40. data/test/lib/vedeu/cursor/cursor_test.rb +0 -9
  41. data/test/lib/vedeu/dsl/line_test.rb +15 -13
  42. data/test/lib/vedeu/geometry/geometry_test.rb +0 -13
  43. data/test/lib/vedeu/geometry/position_test.rb +18 -0
  44. data/test/lib/vedeu/models/escape_test.rb +0 -8
  45. data/test/lib/vedeu/models/interface_test.rb +0 -12
  46. data/test/lib/vedeu/models/views/char_test.rb +4 -23
  47. data/test/lib/vedeu/models/views/{chars_test.rb → collections/chars_test.rb} +0 -0
  48. data/test/lib/vedeu/models/views/{lines_test.rb → collections/lines_test.rb} +0 -0
  49. data/test/lib/vedeu/models/views/{streams_test.rb → collections/streams_test.rb} +0 -0
  50. data/test/lib/vedeu/models/views/collections/view_collection_test.rb +22 -0
  51. data/test/lib/vedeu/models/views/composition_test.rb +23 -17
  52. data/test/lib/vedeu/models/views/line_test.rb +13 -42
  53. data/test/lib/vedeu/models/views/stream_test.rb +4 -33
  54. data/test/lib/vedeu/output/html_char_test.rb +16 -39
  55. data/test/lib/vedeu/output/presentation/colour_test.rb +63 -60
  56. data/test/lib/vedeu/output/presentation/style_test.rb +30 -29
  57. data/test/lib/vedeu/output/presentation_test.rb +1 -1
  58. data/test/lib/vedeu/output/renderers/html_test.rb +4 -8
  59. data/test/lib/vedeu/output/renderers/json_test.rb +37 -3
  60. data/test/lib/vedeu/output/wordwrap_test.rb +4 -4
  61. data/test/lib/vedeu/repositories/repository_test.rb +0 -26
  62. data/test/lib/vedeu/templating/view_template_test.rb +8 -8
  63. metadata +13 -17
  64. data/lib/vedeu/geometry/position_index.rb +0 -68
  65. data/lib/vedeu/models/interface_collection.rb +0 -9
  66. data/test/lib/vedeu/geometry/position_index_test.rb +0 -82
  67. data/test/lib/vedeu/models/interface_collection_test.rb +0 -18
@@ -9,6 +9,10 @@ module Vedeu
9
9
  include Vedeu::Presentation
10
10
  include Vedeu::Toggleable
11
11
 
12
+ # @!attribute [r] attributes
13
+ # @return [Hash]
14
+ attr_reader :attributes
15
+
12
16
  # @!attribute [rw] client
13
17
  # @return [Fixnum|Float]
14
18
  attr_accessor :client
@@ -33,10 +37,6 @@ module Vedeu
33
37
  # @return [Fixnum]
34
38
  attr_accessor :zindex
35
39
 
36
- # @!attribute [r] attributes
37
- # @return [Hash]
38
- attr_reader :attributes
39
-
40
40
  # Return a new instance of Vedeu::Interface.
41
41
  #
42
42
  # @param attributes [Hash]
@@ -70,18 +70,6 @@ module Vedeu
70
70
  Vedeu.buffers.by_name(name).hide
71
71
  end
72
72
 
73
- # Override Ruby's Object#inspect method to provide a more helpful output.
74
- #
75
- # @return [String]
76
- def inspect
77
- '<Vedeu::Interface ' \
78
- "name: '#{name}', " \
79
- "group: '#{group}', " \
80
- "visible: '#{visible}', " \
81
- "zindex: '#{zindex}'" \
82
- '>'
83
- end
84
-
85
73
  # Show the named interface buffer, or without a name, the buffer of the
86
74
  # currently focussed interface.
87
75
  #
@@ -8,15 +8,14 @@ module Vedeu
8
8
 
9
9
  end # Vedeu
10
10
 
11
- require 'vedeu/models/interface_collection'
12
11
  require 'vedeu/models/views/char'
13
- require 'vedeu/models/views/chars'
12
+ require 'vedeu/models/views/collections/chars'
14
13
  require 'vedeu/models/views/stream'
15
- require 'vedeu/models/views/streams'
14
+ require 'vedeu/models/views/collections/streams'
16
15
  require 'vedeu/models/views/line'
17
- require 'vedeu/models/views/lines'
16
+ require 'vedeu/models/views/collections/lines'
18
17
  require 'vedeu/models/interface'
19
18
  require 'vedeu/models/interfaces'
20
- require 'vedeu/models/views/view_collection'
19
+ require 'vedeu/models/views/collections/view_collection'
21
20
  require 'vedeu/models/views/view'
22
21
  require 'vedeu/models/views/composition'
@@ -13,6 +13,10 @@ module Vedeu
13
13
  include Comparable
14
14
  include Vedeu::Presentation
15
15
 
16
+ # @!attribute [r] attributes
17
+ # @return [Hash]
18
+ attr_reader :attributes
19
+
16
20
  # @!attribute [rw] border
17
21
  # @return [NilClass|Symbol]
18
22
  attr_accessor :border
@@ -21,10 +25,6 @@ module Vedeu
21
25
  # @return [Vedeu::Views::Line]
22
26
  attr_accessor :parent
23
27
 
24
- # @!attribute [r] attributes
25
- # @return [Hash]
26
- attr_reader :attributes
27
-
28
28
  # @!attribute [r] position
29
29
  # @return [Vedeu::Position]
30
30
  attr_reader :position
@@ -36,13 +36,13 @@ module Vedeu
36
36
  # Returns a new instance of Vedeu::Views::Char.
37
37
  #
38
38
  # @param attributes [Hash]
39
- # @option attributes value [String]
40
- # @option attributes parent [Vedeu::Views::Line]
41
- # @option attributes colour [Vedeu::Colour]
42
- # @option attributes style [Vedeu::Style]
43
- # @option attributes position [Vedeu::Position]
44
- # @option attributes border [NilClass|Symbol] A symbol representing the
39
+ # @option attributes border [NilClass|Symbol] A symbol representing the
45
40
  # border 'piece' this Vedeu::Views::Char represents.
41
+ # @option attributes colour [Vedeu::Colour]
42
+ # @option attributes parent [Vedeu::Views::Line]
43
+ # @option attributes position [Vedeu::Position]
44
+ # @option attributes style [Vedeu::Style]
45
+ # @option attributes value [String]
46
46
  # @return [Vedeu::Views::Char]
47
47
  def initialize(attributes = {})
48
48
  @attributes = attributes
@@ -72,13 +72,6 @@ module Vedeu
72
72
  end
73
73
  alias_method :==, :eql?
74
74
 
75
- # Override Ruby's Object#inspect method to provide a more helpful output.
76
- #
77
- # @return [String]
78
- def inspect
79
- "<Vedeu::Views::Char '#{Vedeu::Esc.escape(to_s)}'>"
80
- end
81
-
82
75
  # @return [Vedeu::Position]
83
76
  def position
84
77
  @position = Vedeu::Position.coerce(@attributes[:position])
@@ -153,11 +146,17 @@ module Vedeu
153
146
 
154
147
  # @return [Hash]
155
148
  def parent_to_hash
156
- {
157
- background: parent_background.to_s,
158
- foreground: parent_foreground.to_s,
159
- style: parent_style.to_s,
160
- }
149
+ if parent
150
+ {
151
+ background: parent.background.to_s,
152
+ foreground: parent.foreground.to_s,
153
+ style: parent.style.to_s,
154
+ }
155
+
156
+ else
157
+ {}
158
+
159
+ end
161
160
  end
162
161
 
163
162
  # @return [Hash]
@@ -16,14 +16,17 @@ module Vedeu
16
16
  # @return [Hash]
17
17
  attr_reader :attributes
18
18
 
19
+ # @!attribute [r] parent
20
+ # @return [NilClass] Composition objects do not have a parent.
21
+ attr_reader :parent
22
+
19
23
  # Returns a new instance of Vedeu::Views::Composition.
20
24
  #
21
25
  # @param attributes [Hash]
22
26
  # @option attributes client [void]
23
27
  # @option attributes colour [Vedeu::Colour]
24
- # @option attributes views [void]
25
- # @option attributes repository [void]
26
28
  # @option attributes style [Vedeu::Style]
29
+ # @option attributes value [Vedeu::Views::ViewCollection]
27
30
  # @return [Vedeu::Views::Composition]
28
31
  def initialize(attributes = {})
29
32
  @attributes = defaults.merge!(attributes)
@@ -34,23 +37,17 @@ module Vedeu
34
37
  end
35
38
 
36
39
  # @param child [Vedeu::Views::View]
37
- # @return [Vedeu::InterfaceCollection]
40
+ # @return [Vedeu::Views::ViewCollection]
38
41
  def add(child)
39
- @views = collection.coerce(@views, self).add(child)
40
- end
41
-
42
- # @return [Vedeu::Views::Views]
43
- def views
44
- collection.coerce(@views, self)
42
+ @value = value.add(child)
45
43
  end
46
- alias_method :value, :views
44
+ alias_method :<<, :add
47
45
 
48
- # Composition objects do not have a parent.
49
- #
50
- # @return [NilClass]
51
- def parent
52
- nil
46
+ # @return [Vedeu::Views::ViewCollection]
47
+ def value
48
+ collection.coerce(@value, self)
53
49
  end
50
+ alias_method :views, :value
54
51
 
55
52
  private
56
53
 
@@ -59,10 +56,11 @@ module Vedeu
59
56
  # @return [Hash]
60
57
  def defaults
61
58
  {
62
- client: nil,
63
- colour: nil,
64
- views: [],
65
- style: nil,
59
+ client: nil,
60
+ colour: nil,
61
+ parent: nil,
62
+ style: nil,
63
+ value: [],
66
64
  }
67
65
  end
68
66
 
@@ -14,21 +14,21 @@ module Vedeu
14
14
  collection Vedeu::Views::Streams
15
15
  member Vedeu::Views::Stream
16
16
 
17
- # @!attribute [rw] parent
18
- # @return [Vedeu::Views::View]
19
- attr_accessor :parent
20
-
21
17
  # @!attribute [r] attributes
22
18
  # @return [Hash]
23
19
  attr_reader :attributes
24
20
 
21
+ # @!attribute [rw] parent
22
+ # @return [Vedeu::Views::View]
23
+ attr_accessor :parent
24
+
25
25
  # Returns a new instance of Vedeu::Views::Line.
26
26
  #
27
27
  # @param attributes [Hash]
28
- # @option attributes streams [Vedeu::Views::Streams]
29
- # @option attributes parent [Vedeu::Views::View]
30
28
  # @option attributes colour [Vedeu::Colour]
29
+ # @option attributes parent [Vedeu::Views::View]
31
30
  # @option attributes style [Vedeu::Style]
31
+ # @option attributes value [Vedeu::Views::Streams]
32
32
  # @return [Vedeu::Views::Line]
33
33
  def initialize(attributes = {})
34
34
  @attributes = defaults.merge!(attributes)
@@ -41,7 +41,7 @@ module Vedeu
41
41
  # @param child [void]
42
42
  # @return [void]
43
43
  def add(child)
44
- @_streams = @streams = collection.coerce(streams, self).add(child)
44
+ @value = value.add(child)
45
45
  end
46
46
  alias_method :<<, :add
47
47
 
@@ -50,16 +50,9 @@ module Vedeu
50
50
  # @return [Array]
51
51
  # @see Vedeu::Views::Stream
52
52
  def chars
53
- return [] if empty?
54
-
55
- @chars ||= streams.flat_map(&:chars)
56
- end
53
+ return [] if value.empty?
57
54
 
58
- # Returns a boolean indicating whether the line has content.
59
- #
60
- # @return [Boolean]
61
- def empty?
62
- streams.empty?
55
+ @chars ||= value.flat_map(&:chars)
63
56
  end
64
57
 
65
58
  # An object is equal when its values are the same.
@@ -67,27 +60,22 @@ module Vedeu
67
60
  # @param other [Vedeu::Collection]
68
61
  # @return [Boolean]
69
62
  def eql?(other)
70
- self.class == other.class && streams == other.streams
63
+ self.class == other.class && value == other.value
71
64
  end
72
65
  alias_method :==, :eql?
73
66
 
74
- # @return [NilClass|String]
75
- def name
76
- parent.name if parent
77
- end
78
-
79
67
  # Returns the size of the content in characters without formatting.
80
68
  #
81
69
  # @return [Fixnum]
82
70
  def size
83
- streams.map(&:size).inject(0, :+)
71
+ value.map(&:size).inject(0, :+)
84
72
  end
85
73
 
86
74
  # @return [Vedeu::Views::Streams]
87
- def streams
88
- @_streams ||= collection.coerce(@streams, self)
75
+ def value
76
+ collection.coerce(@value, self)
89
77
  end
90
- alias_method :value, :streams
78
+ alias_method :streams, :value
91
79
 
92
80
  private
93
81
 
@@ -96,11 +84,11 @@ module Vedeu
96
84
  # @return [Hash]
97
85
  def defaults
98
86
  {
99
- client: nil,
100
- colour: nil,
101
- parent: nil,
102
- streams: [],
103
- style: nil,
87
+ client: nil,
88
+ colour: nil,
89
+ parent: nil,
90
+ style: nil,
91
+ value: [],
104
92
  }
105
93
  end
106
94
 
@@ -14,6 +14,10 @@ module Vedeu
14
14
  collection Vedeu::Views::Chars
15
15
  member Vedeu::Views::Char
16
16
 
17
+ # @!attribute [r] attributes
18
+ # @return [Hash]
19
+ attr_reader :attributes
20
+
17
21
  # @!attribute [rw] parent
18
22
  # @return [Vedeu::Views::Line]
19
23
  attr_accessor :parent
@@ -22,20 +26,15 @@ module Vedeu
22
26
  # @return [String]
23
27
  attr_accessor :value
24
28
  alias_method :content, :value
25
- alias_method :data, :value
26
29
  alias_method :text, :value
27
30
 
28
- # @!attribute [r] attributes
29
- # @return [Hash]
30
- attr_reader :attributes
31
-
32
31
  # Returns a new instance of Vedeu::Views::Stream.
33
32
  #
34
33
  # @param attributes [Hash]
35
- # @option attributes value [String]
36
- # @option attributes parent [Vedeu::Views::Line]
37
34
  # @option attributes colour [Vedeu::Colour]
38
35
  # @option attributes style [Vedeu::Style]
36
+ # @option attributes parent [Vedeu::Views::Line]
37
+ # @option attributes value [String]
39
38
  # @return [Vedeu::Views::Stream]
40
39
  def initialize(attributes = {})
41
40
  @attributes = defaults.merge!(attributes)
@@ -59,7 +58,7 @@ module Vedeu
59
58
  #
60
59
  # @return [Array]
61
60
  def chars
62
- return [] if empty?
61
+ return [] if value.empty?
63
62
 
64
63
  @chars ||= value.chars.map do |char|
65
64
  member.new(value: char,
@@ -70,13 +69,6 @@ module Vedeu
70
69
  end
71
70
  end
72
71
 
73
- # Returns a boolean indicating whether the stream has content.
74
- #
75
- # @return [Boolean]
76
- def empty?
77
- value.empty?
78
- end
79
-
80
72
  # An object is equal when its values are the same.
81
73
  #
82
74
  # @param other [Vedeu::Views::Char]
@@ -88,11 +80,6 @@ module Vedeu
88
80
  end
89
81
  alias_method :==, :eql?
90
82
 
91
- # @return [NilClass|String]
92
- def name
93
- parent.name if parent
94
- end
95
-
96
83
  # Returns the size of the content in characters without formatting.
97
84
  #
98
85
  # @return [Fixnum]
@@ -13,6 +13,10 @@ module Vedeu
13
13
  collection Vedeu::Views::Lines
14
14
  member Vedeu::Views::Line
15
15
 
16
+ # @!attribute [r] attributes
17
+ # @return [Hash]
18
+ attr_reader :attributes
19
+
16
20
  # @!attribute [rw] client
17
21
  # @return [Fixnum|Float]
18
22
  attr_accessor :client
@@ -25,24 +29,20 @@ module Vedeu
25
29
  # @return [Vedeu::Views::Composition]
26
30
  attr_accessor :parent
27
31
 
28
- # @!attribute [rw] zindex
29
- # @return [Fixnum]
30
- attr_accessor :zindex
31
-
32
- # @!attribute [r] attributes
33
- # @return [Hash]
34
- attr_reader :attributes
35
-
36
32
  # @!attribute [w] lines
37
33
  # @return [Array<Vedeu::Views::Line>]
38
34
  attr_writer :lines
39
35
 
36
+ # @!attribute [rw] zindex
37
+ # @return [Fixnum]
38
+ attr_accessor :zindex
39
+
40
40
  # Return a new instance of Vedeu::Views::View.
41
41
  #
42
42
  # @param attributes [Hash]
43
43
  # @option attributes client [Vedeu::Client]
44
44
  # @option attributes colour [Vedeu::Colour]
45
- # @option attributes lines [Vedeu::Views::Lines]
45
+ # @option attributes value [Vedeu::Views::Lines]
46
46
  # @option attributes name [String]
47
47
  # @option attributes parent [Vedeu::Views::Composition]
48
48
  # @option attributes style [Vedeu::Style]
@@ -57,31 +57,17 @@ module Vedeu
57
57
  end
58
58
 
59
59
  # @param child [Vedeu::Views::Line]
60
- # @return [void]
60
+ # @return [Vedeu::Views::Lines]
61
61
  def add(child)
62
- @lines = lines.add(child)
62
+ @value = value.add(child)
63
63
  end
64
64
  alias_method :<<, :add
65
65
 
66
- # Override Ruby's Object#inspect method to provide a more helpful output.
67
- #
68
- # @return [String]
69
- def inspect
70
- "<Vedeu::Views::View name: '#{name}', zindex: '#{zindex}'>"
71
- end
72
-
73
66
  # @return [Vedeu::Views::Lines]
74
- def lines
75
- collection.coerce(@lines, self)
76
- end
77
- alias_method :value, :lines
78
-
79
- # Returns a boolean indicating whether the interface has content.
80
- #
81
- # @return [Boolean]
82
- def lines?
83
- lines.any?
67
+ def value
68
+ collection.coerce(@value, self)
84
69
  end
70
+ alias_method :lines, :value
85
71
 
86
72
  # @return [Array<Array<Vedeu::Views::Char>>]
87
73
  def render
@@ -140,13 +126,14 @@ module Vedeu
140
126
  # @return [Hash]
141
127
  def defaults
142
128
  {
143
- client: nil,
144
- colour: Vedeu::Colour.coerce(background: :default,
145
- foreground: :default),
146
- name: '',
147
- parent: nil,
148
- style: :normal,
149
- zindex: 0,
129
+ client: nil,
130
+ colour: Vedeu::Colour.coerce(background: :default,
131
+ foreground: :default),
132
+ name: '',
133
+ parent: nil,
134
+ style: :normal,
135
+ value: [],
136
+ zindex: 0,
150
137
  }
151
138
  end
152
139