vedeu 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/docs/borders.md +2 -2
  3. data/examples/284_slow_rendering.rb +2 -2
  4. data/examples/dsl_alignment.rb +9 -9
  5. data/examples/dsl_colours.rb +13 -13
  6. data/examples/dsl_editor.rb +10 -10
  7. data/lib/vedeu/borders/dsl.rb +84 -0
  8. data/lib/vedeu/buffers/empty.rb +3 -3
  9. data/lib/vedeu/buffers/terminal.rb +1 -1
  10. data/lib/vedeu/buffers/view.rb +1 -1
  11. data/lib/vedeu/cells/borders/all.rb +1 -0
  12. data/lib/vedeu/cells/borders/bottom_left.rb +1 -6
  13. data/lib/vedeu/cells/borders/bottom_right.rb +1 -6
  14. data/lib/vedeu/cells/borders/corner.rb +20 -0
  15. data/lib/vedeu/cells/borders/top_left.rb +1 -6
  16. data/lib/vedeu/cells/borders/top_right.rb +1 -6
  17. data/lib/vedeu/cells/empty.rb +22 -0
  18. data/lib/vedeu/cells/escape.rb +47 -0
  19. data/lib/vedeu/cursors/cursor.rb +6 -6
  20. data/lib/vedeu/dsl/text.rb +12 -1
  21. data/lib/vedeu/events/trigger.rb +4 -2
  22. data/lib/vedeu/input/capture.rb +1 -1
  23. data/lib/vedeu/input/mouse.rb +3 -2
  24. data/lib/vedeu/models/all.rb +0 -2
  25. data/lib/vedeu/models/row.rb +1 -1
  26. data/lib/vedeu/output/output.rb +8 -8
  27. data/lib/vedeu/output/text.rb +23 -2
  28. data/lib/vedeu/renderers/html.rb +4 -4
  29. data/lib/vedeu/runtime/launcher.rb +1 -1
  30. data/lib/vedeu/version.rb +1 -1
  31. data/test/lib/vedeu/borders/dsl_test.rb +40 -0
  32. data/test/lib/vedeu/buffers/empty_test.rb +1 -1
  33. data/test/lib/vedeu/cells/borders/bottom_left_test.rb +0 -14
  34. data/test/lib/vedeu/cells/borders/bottom_right_test.rb +0 -14
  35. data/test/lib/vedeu/cells/borders/corner_test.rb +57 -0
  36. data/test/lib/vedeu/cells/borders/top_left_test.rb +0 -14
  37. data/test/lib/vedeu/cells/borders/top_right_test.rb +0 -14
  38. data/test/lib/vedeu/cells/empty_test.rb +33 -0
  39. data/test/lib/vedeu/cells/escape_test.rb +74 -0
  40. data/test/lib/vedeu/cursors/cursor_test.rb +17 -11
  41. data/test/lib/vedeu/dsl/text_test.rb +1 -0
  42. data/test/lib/vedeu/models/row_test.rb +1 -1
  43. data/test/lib/vedeu/output/compressor_test.rb +2 -2
  44. data/test/lib/vedeu/output/output_test.rb +2 -2
  45. data/test/lib/vedeu/renderers/all_test.rb +2 -2
  46. data/test/lib/vedeu/renderers/terminal_test.rb +6 -6
  47. data/test/support/examples/material_colours_app.rb +13 -10
  48. metadata +4 -7
  49. data/lib/vedeu/models/cell.rb +0 -91
  50. data/lib/vedeu/models/escape.rb +0 -90
  51. data/test/lib/vedeu/models/cell_test.rb +0 -117
  52. data/test/lib/vedeu/models/escape_test.rb +0 -87
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3bb700b808027ae0199e3f275aa59204c356e2c4
4
- data.tar.gz: 269a2f124899846454acefe97fe50a95dc28ef8d
3
+ metadata.gz: 4c9a714b2238fa3c5bbdeeccef8713918b40f4f5
4
+ data.tar.gz: 2f3dd1b000581dacd7f007347333fc5bc6028701
5
5
  SHA512:
6
- metadata.gz: 79c2059ccd86e0afdf0b4998bb4528ff5a9d0cdf9266583db8b8ae976f7a04c2079e3f362cf503f42e6193f32cbcd95a96edefe47ed9bb5f4fd051b76ad7bf8a
7
- data.tar.gz: fc2a6a223a6e9a8b098d02b0c74f08d07d56a3ee0cef6870229ba87f1756d7075e393cd3eb8a409159afc3b8249ce64a1c298e997458000097a385cd033c40e1
6
+ metadata.gz: e823c499c813c68bf11108eaf1c96de24ec984aff02afa56d240ca00fae273698b51d08b04c9fd85f730a78f9b7e713459b70cecd7316d6affa8e183fd669efb
7
+ data.tar.gz: 2b92ab94bf23c05680545fdb6e3a2beccda9484809a82b416ef04354e74d6f13113e031c1077ba7c716407c5c1485717a7a0955192890e00152f508ce04134c8
data/docs/borders.md CHANGED
@@ -5,8 +5,8 @@ The interfaces of Vedeu can each have their own border.
5
5
 
6
6
  - It has a name. This name associates it with an
7
7
  {file:docs/interface.md Interface}.
8
- - Each of its corners, the horizontal, and the vertical character can
9
- be defined as different characters.
8
+ - Each of its corners, the horizontal, and the vertical characters can
9
+ be defined as different characters, with custom colours and styles.
10
10
  - It can have a foreground and a background and style, independent of
11
11
  the interface to which it belongs.
12
12
  - Each of the sides of the border can be shown or hidden
@@ -58,9 +58,9 @@ class EditorApp
58
58
  key(:enter) { Vedeu.trigger(:_editor_execute_, :editor_view) }
59
59
  key(:insert) do
60
60
  Vedeu.log(type: :debug,
61
- message: "Commands: #{Vedeu.all_commands.inspect}")
61
+ message: "Commands: #{Vedeu.all_commands.inspect}".freeze)
62
62
  Vedeu.log(type: :debug,
63
- message: "Keypresses: #{Vedeu.all_keypresses.inspect}")
63
+ message: "Keypresses: #{Vedeu.all_keypresses.inspect}".freeze)
64
64
  end
65
65
  end
66
66
 
@@ -100,55 +100,55 @@ class AlignmentApp
100
100
  Vedeu.render do
101
101
  view(:top_left_view) do
102
102
  lines do
103
- line "top left"
103
+ line "top left".freeze
104
104
  end
105
105
  end
106
106
 
107
107
  view(:top_centre_view) do
108
108
  lines do
109
- line "top centre"
109
+ line "top centre".freeze
110
110
  end
111
111
  end
112
112
 
113
113
  view(:top_right_view) do
114
114
  lines do
115
- line "top right"
115
+ line "top right".freeze
116
116
  end
117
117
  end
118
118
 
119
119
  view(:middle_left_view) do
120
120
  lines do
121
- line "middle left"
121
+ line "middle left".freeze
122
122
  end
123
123
  end
124
124
 
125
125
  view(:middle_centre_view) do
126
126
  lines do
127
- line "middle centre"
127
+ line "middle centre".freeze
128
128
  end
129
129
  end
130
130
 
131
131
  view(:middle_right_view) do
132
132
  lines do
133
- line "middle right"
133
+ line "middle right".freeze
134
134
  end
135
135
  end
136
136
 
137
137
  view(:bottom_left_view) do
138
138
  lines do
139
- line "bottom left"
139
+ line "bottom left".freeze
140
140
  end
141
141
  end
142
142
 
143
143
  view(:bottom_centre_view) do
144
144
  lines do
145
- line "bottom centre"
145
+ line "bottom centre".freeze
146
146
  end
147
147
  end
148
148
 
149
149
  view(:bottom_right_view) do
150
150
  lines do
151
- line "bottom right"
151
+ line "bottom right".freeze
152
152
  end
153
153
  end
154
154
  end
@@ -35,34 +35,34 @@ class ColoursApp
35
35
  # line "test" - does not work, (wrong number of args for lines dsl/view.rb:240)
36
36
 
37
37
  lines do
38
- line "A line using interface colours."
38
+ line "A line using interface colours.".freeze
39
39
  line ""
40
40
  line do
41
41
  stream do
42
- text "Stream { "
43
- text "background", background: '#001177'
44
- text " }"
42
+ text "Stream { ".freeze
43
+ text "background".freeze, background: '#001177'
44
+ text " }".freeze
45
45
  end
46
46
  end
47
47
  line do
48
48
  stream do
49
- text "Stream { "
50
- text "foreground", foreground: '#aa00ff'
51
- text " }"
49
+ text "Stream { ".freeze
50
+ text "foreground".freeze, foreground: '#aa00ff'
51
+ text " }".freeze
52
52
  end
53
53
  end
54
54
  line do
55
55
  stream do
56
- text "Stream { "
57
- text "background", background: '#117700'
58
- text " }"
56
+ text "Stream { ".freeze
57
+ text "background".freeze, background: '#117700'
58
+ text " }".freeze
59
59
  end
60
60
  end
61
61
  line do
62
62
  stream do
63
- text "Stream { "
64
- text "foreground", foreground: '#00aaff'
65
- text " }"
63
+ text "Stream { ".freeze
64
+ text "foreground".freeze, foreground: '#00aaff'
65
+ text " }".freeze
66
66
  end
67
67
  end
68
68
  end
@@ -9,8 +9,8 @@ class EditorApp
9
9
 
10
10
  Vedeu.configure do
11
11
  debug!
12
- log '/tmp/editor.log'
13
- renderers Vedeu::Renderers::File.new(filename: '/tmp/editor.out')
12
+ log '/tmp/editor.log'.freeze
13
+ renderers Vedeu::Renderers::File.new(filename: '/tmp/editor.out'.freeze)
14
14
  fake!
15
15
  end
16
16
 
@@ -49,14 +49,14 @@ class EditorApp
49
49
  key(:enter) { Vedeu.trigger(:_editor_insert_line_, :editor_view) }
50
50
  key(:insert) do
51
51
  Vedeu.log(type: :debug,
52
- message: "Commands: #{Vedeu.all_commands.inspect}")
52
+ message: "Commands: #{Vedeu.all_commands.inspect}".freeze)
53
53
  Vedeu.log(type: :debug,
54
- message: "Keypresses: #{Vedeu.all_keypresses.inspect}")
54
+ message: "Keypresses: #{Vedeu.all_keypresses.inspect}".freeze)
55
55
  end
56
56
  end
57
57
 
58
- Vedeu.keymap '_global_' do
59
- key('q') { Vedeu.exit }
58
+ Vedeu.keymap '_global_'.freeze do
59
+ key('q'.freeze) { Vedeu.exit }
60
60
  end
61
61
 
62
62
  Vedeu.render do
@@ -67,10 +67,10 @@ class EditorApp
67
67
  Vedeu.render do
68
68
  view(:help_view) do
69
69
  lines do
70
- line 'Type into the editor dialog above,'
71
- line 'and press Escape. This will trigger the'
72
- line ':command event with the contents of '
73
- line 'the view.'
70
+ line 'Type into the editor dialog above,'.freeze
71
+ line 'and press Escape. This will trigger the'.freeze
72
+ line ':command event with the contents of '.freeze
73
+ line 'the view.'.freeze
74
74
 
75
75
  # @todo Not implemented yet:
76
76
  #
@@ -110,6 +110,48 @@ module Vedeu
110
110
  model.enabled
111
111
  end
112
112
 
113
+ # Set the character to be used to draw the top horizontal part
114
+ # of the border.
115
+ #
116
+ # Vedeu.border :border_demo do
117
+ # top_horizontal '-'
118
+ # # ... some code
119
+ # end
120
+ #
121
+ # @param char [String] Character to be used as the top
122
+ # horizontal border character.
123
+ # @param options [Hash<Symbol => Hash<Symbol => String>|String|
124
+ # Symbol]
125
+ # @option options colour [Hash<Symbol => String>]
126
+ # @option options style [String|Symbol]
127
+ # @return [String]
128
+ def top_horizontal(char, options = {})
129
+ model.top_horizontal = Vedeu::Cells::TopHorizontal
130
+ .new(attrs(char, options))
131
+ end
132
+ alias_method :top_horizontal=, :top_horizontal
133
+
134
+ # Set the character to be used to draw the bottom horizontal
135
+ # part of the border.
136
+ #
137
+ # Vedeu.border :border_demo do
138
+ # bottom_horizontal '-'
139
+ # # ... some code
140
+ # end
141
+ #
142
+ # @param char [String] Character to be used as the bottom
143
+ # horizontal border character.
144
+ # @param options [Hash<Symbol => Hash<Symbol => String>|String|
145
+ # Symbol]
146
+ # @option options colour [Hash<Symbol => String>]
147
+ # @option options style [String|Symbol]
148
+ # @return [String]
149
+ def bottom_horizontal(char, options = {})
150
+ model.bottom_horizontal = Vedeu::Cells::BottomHorizontal
151
+ .new(attrs(char, options))
152
+ end
153
+ alias_method :bottom_horizontal=, :bottom_horizontal
154
+
113
155
  # Set the character to be used to draw a horizontal part of the
114
156
  # border.
115
157
  #
@@ -350,6 +392,48 @@ module Vedeu
350
392
  end
351
393
  alias_method :top_right=, :top_right
352
394
 
395
+ # Set the character to be used to draw the left vertical part of
396
+ # the border.
397
+ #
398
+ # Vedeu.border :border_demo do
399
+ # left_vertical '|'
400
+ # # ... some code
401
+ # end
402
+ #
403
+ # @param char [String] Character to be used as the left vertical
404
+ # border character.
405
+ # @param options [Hash<Symbol => Hash<Symbol => String>|String|
406
+ # Symbol]
407
+ # @option options colour [Hash<Symbol => String>]
408
+ # @option options style [String|Symbol]
409
+ # @return [String]
410
+ def left_vertical(char, options = {})
411
+ model.left_vertical = Vedeu::Cells::LeftVertical
412
+ .new(attrs(char, options))
413
+ end
414
+ alias_method :left_vertical=, :left_vertical
415
+
416
+ # Set the character to be used to draw the right vertical part
417
+ # of the border.
418
+ #
419
+ # Vedeu.border :border_demo do
420
+ # right_vertical '|'
421
+ # # ... some code
422
+ # end
423
+ #
424
+ # @param char [String] Character to be used as the right
425
+ # vertical border character.
426
+ # @param options [Hash<Symbol => Hash<Symbol => String>|String|
427
+ # Symbol]
428
+ # @option options colour [Hash<Symbol => String>]
429
+ # @option options style [String|Symbol]
430
+ # @return [String]
431
+ def right_vertical(char, options = {})
432
+ model.right_vertical = Vedeu::Cells::RightVertical
433
+ .new(attrs(char, options))
434
+ end
435
+ alias_method :right_vertical=, :right_vertical
436
+
353
437
  # Set the character to be used to draw a vertical part of the
354
438
  # border.
355
439
  #
@@ -2,7 +2,7 @@ module Vedeu
2
2
 
3
3
  module Buffers
4
4
 
5
- # Provides a grid of Vedeu::Models::Cell objects at the given
5
+ # Provides a grid of Vedeu::Cells::Empty objects at the given
6
6
  # height and width.
7
7
  #
8
8
  # @api private
@@ -14,12 +14,12 @@ module Vedeu
14
14
  # @return [NilClass|String|Symbol]
15
15
  attr_reader :name
16
16
 
17
- # @return [Array<Array<Vedeu::Models::Cell>>]
17
+ # @return [Array<Array<Vedeu::Cells::Empty>>]
18
18
  def buffer
19
19
  Array.new(height) do |y|
20
20
  if y > 0
21
21
  Array.new(width) do |x|
22
- Vedeu::Models::Cell.new(name: name, position: [y, x]) if x > 0
22
+ Vedeu::Cells::Empty.new(name: name, position: [y, x]) if x > 0
23
23
  end.compact
24
24
  end
25
25
  end.compact
@@ -87,7 +87,7 @@ module Vedeu
87
87
 
88
88
  private
89
89
 
90
- # Return a grid of {Vedeu::Models::Cell} objects defined by the
90
+ # Return a grid of {Vedeu::Cells::Empty} objects defined by the
91
91
  # height and width of this virtual terminal.
92
92
  #
93
93
  # @return [Vedeu::Buffers::View]
@@ -63,7 +63,7 @@ module Vedeu
63
63
  width: geometry.bordered_width).buffer
64
64
  end
65
65
 
66
- # @return [Array<Vedeu::Models::Cell>]
66
+ # @return [Array<Vedeu::Cells::Empty>]
67
67
  def current
68
68
  @current ||= buffer
69
69
  end
@@ -6,6 +6,7 @@ module Vedeu
6
6
 
7
7
  end # Vedeu
8
8
 
9
+ require 'vedeu/cells/borders/corner'
9
10
  require 'vedeu/cells/borders/horizontal'
10
11
  require 'vedeu/cells/borders/bottom_horizontal'
11
12
  require 'vedeu/cells/borders/bottom_left'
@@ -7,12 +7,7 @@ module Vedeu
7
7
  #
8
8
  # @api private
9
9
  #
10
- class BottomLeft < Vedeu::Cells::Border
11
-
12
- # @return [Vedeu::Geometries::Position]
13
- def position
14
- @position = defaults[:position]
15
- end
10
+ class BottomLeft < Vedeu::Cells::Corner
16
11
 
17
12
  # @return [Symbol]
18
13
  def type
@@ -7,12 +7,7 @@ module Vedeu
7
7
  #
8
8
  # @api private
9
9
  #
10
- class BottomRight < Vedeu::Cells::Border
11
-
12
- # @return [Vedeu::Geometries::Position]
13
- def position
14
- @position = defaults[:position]
15
- end
10
+ class BottomRight < Vedeu::Cells::Corner
16
11
 
17
12
  # @return [Symbol]
18
13
  def type
@@ -0,0 +1,20 @@
1
+ module Vedeu
2
+
3
+ module Cells
4
+
5
+ # Provides the position information to draw a border corner.
6
+ #
7
+ # @api private
8
+ #
9
+ class Corner < Vedeu::Cells::Border
10
+
11
+ # @return [Vedeu::Geometries::Position]
12
+ def position
13
+ @position = defaults[:position]
14
+ end
15
+
16
+ end # Corner
17
+
18
+ end # Cells
19
+
20
+ end # Vedeu
@@ -7,12 +7,7 @@ module Vedeu
7
7
  #
8
8
  # @api private
9
9
  #
10
- class TopLeft < Vedeu::Cells::Border
11
-
12
- # @return [Vedeu::Geometries::Position]
13
- def position
14
- @position = defaults[:position]
15
- end
10
+ class TopLeft < Vedeu::Cells::Corner
16
11
 
17
12
  # @return [Symbol]
18
13
  def type
@@ -7,12 +7,7 @@ module Vedeu
7
7
  #
8
8
  # @api private
9
9
  #
10
- class TopRight < Vedeu::Cells::Border
11
-
12
- # @return [Vedeu::Geometries::Position]
13
- def position
14
- @position = defaults[:position]
15
- end
10
+ class TopRight < Vedeu::Cells::Corner
16
11
 
17
12
  # @return [Symbol]
18
13
  def type
@@ -43,6 +43,28 @@ module Vedeu
43
43
  end
44
44
  alias_method :==, :eql?
45
45
 
46
+ # @return [Hash]
47
+ def to_hash
48
+ {
49
+ colour: colour.to_s,
50
+ style: style.to_s,
51
+ value: value.to_s,
52
+ position: position.to_s,
53
+ }
54
+ end
55
+
56
+ # @param _options [Hash] Ignored.
57
+ # @return [String]
58
+ def to_html(_options = {})
59
+ ''
60
+ end
61
+
62
+ # @return [String]
63
+ def to_s
64
+ value.to_s
65
+ end
66
+ alias_method :to_str, :to_s
67
+
46
68
  private
47
69
 
48
70
  # @return [Hash<Symbol => Hash<void>|NilClass|String>]