vedeu 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/examples/views/_interfaces.rb +127 -0
  3. data/examples/views/empty_template.rb +10 -0
  4. data/examples/views/expected/vedeu_full_screen.html +140 -0
  5. data/examples/views/expected/vedeu_full_screen.json +96050 -0
  6. data/examples/views/expected/vedeu_full_screen.out +1 -0
  7. data/examples/views/expected/vedeu_full_screen.txt +50 -0
  8. data/examples/views/expected/vedeu_line.html +140 -0
  9. data/examples/views/expected/vedeu_line.json +96050 -0
  10. data/examples/views/expected/vedeu_line.out +1 -0
  11. data/examples/views/expected/vedeu_line.txt +58 -0
  12. data/examples/views/expected/vedeu_lines.html +140 -0
  13. data/examples/views/expected/vedeu_lines.json +96050 -0
  14. data/examples/views/expected/{lines.out → vedeu_lines.out} +1 -1
  15. data/examples/views/expected/vedeu_lines_alignment.html +80 -0
  16. data/examples/views/expected/vedeu_lines_alignment.json +46370 -0
  17. data/examples/views/expected/vedeu_lines_alignment.out +1 -0
  18. data/examples/views/full_screen.rb +10 -0
  19. data/examples/views/line.rb +11 -106
  20. data/examples/views/lines.rb +8 -127
  21. data/examples/views/lines_alignment.rb +17 -125
  22. data/examples/views/runner.sh +65 -19
  23. data/lib/vedeu/borders/border.rb +6 -6
  24. data/lib/vedeu/borders/refresh.rb +4 -6
  25. data/lib/vedeu/buffers/buffer.rb +1 -1
  26. data/lib/vedeu/buffers/terminal.rb +4 -4
  27. data/lib/vedeu/buffers/view.rb +2 -2
  28. data/lib/vedeu/cells/all.rb +2 -2
  29. data/lib/vedeu/cells/border.rb +5 -0
  30. data/lib/vedeu/cells/borders/all.rb +2 -8
  31. data/lib/vedeu/cells/borders/edges/all.rb +6 -0
  32. data/lib/vedeu/cells/borders/{bottom_horizontal.rb → edges/bottom_horizontal.rb} +0 -0
  33. data/lib/vedeu/cells/borders/{left_vertical.rb → edges/left_vertical.rb} +0 -0
  34. data/lib/vedeu/cells/borders/{right_vertical.rb → edges/right_vertical.rb} +0 -0
  35. data/lib/vedeu/cells/borders/{top_horizontal.rb → edges/top_horizontal.rb} +0 -0
  36. data/lib/vedeu/cells/borders/horizontal.rb +5 -0
  37. data/lib/vedeu/cells/borders/vertical.rb +5 -0
  38. data/lib/vedeu/cells/borders/vertices/all.rb +6 -0
  39. data/lib/vedeu/cells/borders/{bottom_left.rb → vertices/bottom_left.rb} +5 -0
  40. data/lib/vedeu/cells/borders/{bottom_right.rb → vertices/bottom_right.rb} +5 -0
  41. data/lib/vedeu/cells/borders/{top_left.rb → vertices/top_left.rb} +5 -0
  42. data/lib/vedeu/cells/borders/{top_right.rb → vertices/top_right.rb} +5 -0
  43. data/lib/vedeu/cells/char.rb +16 -0
  44. data/lib/vedeu/cells/clear.rb +5 -0
  45. data/lib/vedeu/cells/cursor.rb +70 -0
  46. data/lib/vedeu/cells/empty.rb +24 -14
  47. data/lib/vedeu/cells/escape.rb +8 -7
  48. data/lib/vedeu/cells/support/all.rb +3 -0
  49. data/lib/vedeu/cells/support/html.rb +98 -0
  50. data/lib/vedeu/colours/background.rb +21 -1
  51. data/lib/vedeu/colours/colour.rb +10 -2
  52. data/lib/vedeu/colours/foreground.rb +21 -1
  53. data/lib/vedeu/colours/translator.rb +17 -24
  54. data/lib/vedeu/colours/validator.rb +9 -9
  55. data/lib/vedeu/configuration/api.rb +1 -1
  56. data/lib/vedeu/cursors/cursor.rb +5 -5
  57. data/lib/vedeu/dsl/elements.rb +22 -79
  58. data/lib/vedeu/dsl/string/text.rb +3 -3
  59. data/lib/vedeu/editor/cropper.rb +2 -2
  60. data/lib/vedeu/editor/cursor.rb +1 -1
  61. data/lib/vedeu/editor/document.rb +1 -1
  62. data/lib/vedeu/geometries/area/dimension.rb +1 -1
  63. data/lib/vedeu/geometries/position.rb +5 -2
  64. data/lib/vedeu/interfaces/clear.rb +5 -5
  65. data/lib/vedeu/models/row.rb +4 -3
  66. data/lib/vedeu/output/compressor.rb +7 -7
  67. data/lib/vedeu/output/output.rb +8 -13
  68. data/lib/vedeu/output/viewport.rb +1 -1
  69. data/lib/vedeu/presentation/background.rb +2 -2
  70. data/lib/vedeu/presentation/colour.rb +0 -4
  71. data/lib/vedeu/presentation/foreground.rb +2 -2
  72. data/lib/vedeu/presentation/style.rb +1 -1
  73. data/lib/vedeu/presentation/styles.rb +0 -3
  74. data/lib/vedeu/renderers/file.rb +10 -68
  75. data/lib/vedeu/renderers/html.rb +28 -96
  76. data/lib/vedeu/renderers/json.rb +15 -31
  77. data/lib/vedeu/renderers/options.rb +160 -14
  78. data/lib/vedeu/renderers/templates/html_renderer.vedeu +1 -0
  79. data/lib/vedeu/renderers/terminal.rb +16 -17
  80. data/lib/vedeu/renderers/text.rb +32 -41
  81. data/lib/vedeu/version.rb +1 -1
  82. data/lib/vedeu/views/all.rb +0 -2
  83. data/lib/vedeu/views/chars.rb +6 -3
  84. data/lib/vedeu/views/stream.rb +3 -2
  85. data/test/lib/vedeu/borders/caption_test.rb +17 -17
  86. data/test/lib/vedeu/borders/title_test.rb +12 -12
  87. data/test/lib/vedeu/cells/border_test.rb +6 -0
  88. data/test/lib/vedeu/cells/borders/{bottom_horizontal_test.rb → edges/bottom_horizontal_test.rb} +0 -0
  89. data/test/lib/vedeu/cells/borders/{left_vertical_test.rb → edges/left_vertical_test.rb} +0 -0
  90. data/test/lib/vedeu/cells/borders/{right_vertical_test.rb → edges/right_vertical_test.rb} +0 -0
  91. data/test/lib/vedeu/cells/borders/{top_horizontal_test.rb → edges/top_horizontal_test.rb} +0 -0
  92. data/test/lib/vedeu/cells/borders/horizontal_test.rb +6 -0
  93. data/test/lib/vedeu/cells/borders/vertical_test.rb +6 -0
  94. data/test/lib/vedeu/cells/borders/{bottom_left_test.rb → vertices/bottom_left_test.rb} +6 -0
  95. data/test/lib/vedeu/cells/borders/{bottom_right_test.rb → vertices/bottom_right_test.rb} +6 -0
  96. data/test/lib/vedeu/cells/borders/{top_left_test.rb → vertices/top_left_test.rb} +6 -0
  97. data/test/lib/vedeu/cells/borders/{top_right_test.rb → vertices/top_right_test.rb} +6 -0
  98. data/test/lib/vedeu/cells/char_test.rb +18 -0
  99. data/test/lib/vedeu/cells/clear_test.rb +6 -0
  100. data/test/lib/vedeu/cells/cursor_test.rb +113 -0
  101. data/test/lib/vedeu/cells/empty_test.rb +100 -7
  102. data/test/lib/vedeu/cells/escape_test.rb +29 -13
  103. data/test/lib/vedeu/cells/support/html_test.rb +100 -0
  104. data/test/lib/vedeu/colours/background_test.rb +35 -3
  105. data/test/lib/vedeu/colours/colour_test.rb +66 -0
  106. data/test/lib/vedeu/colours/foreground_test.rb +35 -3
  107. data/test/lib/vedeu/colours/translator_test.rb +0 -34
  108. data/test/lib/vedeu/colours/validator_test.rb +84 -6
  109. data/test/lib/vedeu/cursors/cursor_test.rb +4 -4
  110. data/test/lib/vedeu/cursors/refresh_test.rb +4 -1
  111. data/test/lib/vedeu/dsl/string/text_test.rb +36 -36
  112. data/test/lib/vedeu/editor/cropper_test.rb +15 -15
  113. data/test/lib/vedeu/geometries/position_test.rb +14 -1
  114. data/test/lib/vedeu/models/page_test.rb +10 -10
  115. data/test/lib/vedeu/models/row_test.rb +7 -7
  116. data/test/lib/vedeu/output/compressor_test.rb +63 -50
  117. data/test/lib/vedeu/renderers/file_test.rb +64 -35
  118. data/test/lib/vedeu/renderers/html_test.rb +15 -12
  119. data/test/lib/vedeu/renderers/json_test.rb +79 -56
  120. data/test/lib/vedeu/renderers/options_test.rb +74 -26
  121. data/test/lib/vedeu/renderers/terminal_test.rb +34 -4
  122. data/test/lib/vedeu/renderers/text_test.rb +35 -3
  123. data/test/lib/vedeu/views/chars_test.rb +6 -0
  124. metadata +50 -41
  125. data/examples/views/expected/line.out +0 -1
  126. data/examples/views/expected/lines_alignment.out +0 -1
  127. data/lib/vedeu/cells/html.rb +0 -21
  128. data/lib/vedeu/cells/json.rb +0 -21
  129. data/lib/vedeu/views/char.rb +0 -180
  130. data/lib/vedeu/views/html_char.rb +0 -133
  131. data/test/lib/vedeu/cells/html_test.rb +0 -15
  132. data/test/lib/vedeu/cells/json_test.rb +0 -15
  133. data/test/lib/vedeu/views/char_test.rb +0 -283
  134. data/test/lib/vedeu/views/html_char_test.rb +0 -125
@@ -2,26 +2,72 @@
2
2
 
3
3
  set -e
4
4
 
5
- function test_output() {
6
- "$@"
7
- local status=$?
8
- if [ $status -ne 0 ]; then
9
- echo "Error with $1" >&2
10
- fi
11
- return $status
5
+ function expected {
6
+ printf "\e[32mExpected:\e[39m "
12
7
  }
8
+ function actual {
9
+ printf "\e[31mActual:\e[39m "
10
+ }
11
+
12
+ ./line.rb
13
+ ./lines.rb
14
+ ./lines_alignment.rb
15
+ ./full_screen.rb
16
+
17
+ echo -ne "\e[34mline out\e[39m\n"
18
+ echo -ne "$(expected) $(du -b ./expected/vedeu_line.out | cut -f1)\n"
19
+ echo -ne "$(actual) $(du -b /tmp/vedeu_line.out | cut -f1)\n"
20
+ echo -ne "\e[33mhtml\e[39m\n"
21
+ echo -ne "$(expected) $(du -b ./expected/vedeu_line.html | cut -f1)\n"
22
+ echo -ne "$(actual) $(du -b /tmp/vedeu_line.html | cut -f1)\n"
23
+ echo -ne "\e[33mjson\e[39m\n"
24
+ echo -ne "$(expected) $(du -b ./expected/vedeu_line.json | cut -f1)\n"
25
+ echo -ne "$(actual) $(du -b /tmp/vedeu_line.json | cut -f1)\n"
26
+ echo -ne "\e[33mtxt\e[39m\n"
27
+ echo -ne "$(expected) $(du -b ./expected/vedeu_line.txt | cut -f1)\n"
28
+ echo -ne "$(actual) $(du -b /tmp/vedeu_line.txt | cut -f1)\n"
29
+
30
+ echo -ne "\n"
31
+
32
+ echo -ne "\e[34mlines out\e[39m\n"
33
+ echo -ne "$(expected) $(du -b ./expected/vedeu_lines.out | cut -f1)\n"
34
+ echo -ne "$(actual) $(du -b /tmp/vedeu_lines.out | cut -f1)\n"
35
+ echo -ne "\e[33mhtml\e[39m\n"
36
+ echo -ne "$(expected) $(du -b ./expected/vedeu_lines.html | cut -f1)\n"
37
+ echo -ne "$(actual) $(du -b /tmp/vedeu_lines.html | cut -f1)\n"
38
+ echo -ne "\e[33mjson\e[39m\n"
39
+ echo -ne "$(expected) $(du -b ./expected/vedeu_lines.json | cut -f1)\n"
40
+ echo -ne "$(actual) $(du -b /tmp/vedeu_lines.json | cut -f1)\n"
41
+ echo -ne "\e[33mtxt\e[39m\n"
42
+ echo -ne "$(expected) $(du -b ./expected/vedeu_lines.txt | cut -f1)\n"
43
+ echo -ne "$(actual) $(du -b /tmp/vedeu_lines.txt | cut -f1)\n"
44
+
45
+ echo -ne "\n"
13
46
 
14
- test_output ./line.rb
15
- test_output diff -q /tmp/line.out ./expected/line.out
16
- du -b /tmp/line.out | cut -f1
17
- du -b ./expected/line.out | cut -f1
47
+ echo -ne "\e[34mlines alignment out\e[39m\n"
48
+ echo -ne "$(expected) $(du -b ./expected/vedeu_lines_alignment.out | cut -f1)\n"
49
+ echo -ne "$(actual) $(du -b /tmp/vedeu_lines_alignment.out | cut -f1)\n"
50
+ echo -ne "\e[33mhtml\e[39m\n"
51
+ echo -ne "$(expected) $(du -b ./expected/vedeu_lines_alignment.html | cut -f1)\n"
52
+ echo -ne "$(actual) $(du -b /tmp/vedeu_lines_alignment.html | cut -f1)\n"
53
+ echo -ne "\e[33mjson\e[39m\n"
54
+ echo -ne "$(expected) $(du -b ./expected/vedeu_lines_alignment.json | cut -f1)\n"
55
+ echo -ne "$(actual) $(du -b /tmp/vedeu_lines_alignment.json | cut -f1)\n"
56
+ echo -ne "\e[33mtxt\e[39m\n"
57
+ echo -ne "$(expected) $(du -b ./expected/vedeu_lines_alignment.txt | cut -f1)\n"
58
+ echo -ne "$(actual) $(du -b /tmp/vedeu_lines_alignment.txt | cut -f1)\n"
18
59
 
19
- test_output ./lines.rb
20
- test_output diff -q /tmp/lines.out ./expected/lines.out
21
- du -b /tmp/lines.out | cut -f1
22
- du -b ./expected/lines.out | cut -f1
60
+ echo -ne "\n"
23
61
 
24
- test_output ./lines_alignment.rb
25
- test_output diff -q /tmp/lines_alignment.out ./expected/lines_alignment.out
26
- du -b /tmp/lines_alignment.out | cut -f1
27
- du -b ./expected/lines_alignment.out | cut -f1
62
+ echo -ne "\e[34mfull screen out\e[39m\n"
63
+ echo -ne "$(expected) $(du -b ./expected/vedeu_full_screen.out | cut -f1)\n"
64
+ echo -ne "$(actual) $(du -b /tmp/vedeu_full_screen.out | cut -f1)\n"
65
+ echo -ne "\e[33mhtml\e[39m\n"
66
+ echo -ne "$(expected) $(du -b ./expected/vedeu_full_screen.html | cut -f1)\n"
67
+ echo -ne "$(actual) $(du -b /tmp/vedeu_full_screen.html | cut -f1)\n"
68
+ echo -ne "\e[33mjson\e[39m\n"
69
+ echo -ne "$(expected) $(du -b ./expected/vedeu_full_screen.json | cut -f1)\n"
70
+ echo -ne "$(actual) $(du -b /tmp/vedeu_full_screen.json | cut -f1)\n"
71
+ echo -ne "\e[33mtxt\e[39m\n"
72
+ echo -ne "$(expected) $(du -b ./expected/vedeu_full_screen.txt | cut -f1)\n"
73
+ echo -ne "$(actual) $(du -b /tmp/vedeu_full_screen.txt | cut -f1)\n"
@@ -179,11 +179,11 @@ module Vedeu
179
179
  bottom_right: bottom_right,
180
180
  caption: @caption,
181
181
  client: @client,
182
- colour: @colour,
182
+ colour: colour,
183
183
  enabled: @enabled,
184
184
  horizontal: @horizontal,
185
185
  left_vertical: left_vertical,
186
- name: @name,
186
+ name: name,
187
187
  parent: @parent,
188
188
  repository: @repository,
189
189
  right_vertical: right_vertical,
@@ -191,7 +191,7 @@ module Vedeu
191
191
  show_left: @show_left,
192
192
  show_right: @show_right,
193
193
  show_top: @show_top,
194
- style: @style,
194
+ style: style,
195
195
  title: @title,
196
196
  top_horizontal: top_horizontal,
197
197
  top_left: top_left,
@@ -282,9 +282,9 @@ module Vedeu
282
282
  # @return [Hash<Symbol => void>]
283
283
  def cell_attributes
284
284
  {
285
- colour: @colour,
286
- name: @name,
287
- style: @style,
285
+ colour: colour,
286
+ name: name,
287
+ style: style,
288
288
  }
289
289
  end
290
290
 
@@ -71,7 +71,7 @@ module Vedeu
71
71
  @name = present?(name) ? name : Vedeu.focus
72
72
  end
73
73
 
74
- # @return [Array<Array<Vedeu::Views::Char>>]
74
+ # @return [Array<Array<Vedeu::Cells::Char>>]
75
75
  def by_name
76
76
  Vedeu.render_output(output) if enabled? && visible?
77
77
  end
@@ -101,7 +101,7 @@ module Vedeu
101
101
  @border ||= Vedeu.borders.by_name(name)
102
102
  end
103
103
 
104
- # @return [Array<Array<Vedeu::Views::Char>>]
104
+ # @return [Array<Array<Vedeu::Cells::Char>>]
105
105
  def output
106
106
  Vedeu.timer("Drawing border: '#{name}'") do
107
107
  [
@@ -179,8 +179,7 @@ module Vedeu
179
179
 
180
180
  # An optional caption for when the bottom border is to be shown.
181
181
  #
182
- # @return [Array<Vedeu::Views::Char>]
183
- # @see [Vedeu::Borders::Caption#render]
182
+ # @return (see Vedeu::Borders::Caption#render)
184
183
  def captionbar
185
184
  characters = build_collection(bordered_width) do |ix|
186
185
  cell = bottom_horizontal.dup
@@ -195,8 +194,7 @@ module Vedeu
195
194
 
196
195
  # An optional title for when the top border is to be shown.
197
196
  #
198
- # @return [Array<Vedeu::Views::Char>]
199
- # @see [Vedeu::Borders::Title#render]
197
+ # @return (see Vedeu::Borders::Title#render)
200
198
  def titlebar
201
199
  characters = build_collection(bordered_width) do |ix|
202
200
  cell = top_horizontal.dup
@@ -131,7 +131,7 @@ module Vedeu
131
131
  # - If the 'previous' buffer is empty, return an empty
132
132
  # collection.
133
133
  #
134
- # @return [Array<Array<Array<Vedeu::Views::Char>>>]
134
+ # @return [Array<Array<Array<Vedeu::Cells::Char>>>]
135
135
  def render
136
136
  current = if back?
137
137
  swap
@@ -52,8 +52,8 @@ module Vedeu
52
52
  # Write a collection of cells to the virtual terminal, but do
53
53
  # not send to a renderer.
54
54
  #
55
- # @param value_or_values [Array<Array<Vedeu::Views::Char>>]
56
- # @return [Array<Array<Vedeu::Views::Char>>]
55
+ # @param value_or_values [Array<Array<Vedeu::Cells::Char>>]
56
+ # @return [Array<Array<Vedeu::Cells::Char>>]
57
57
  def update(value_or_values)
58
58
  buffer.update(value_or_values)
59
59
  end
@@ -67,8 +67,8 @@ module Vedeu
67
67
  # @example
68
68
  # Vedeu.trigger(:_drb_store_output_, value_or_values)
69
69
  #
70
- # @param value_or_values [Array<Array<Vedeu::Views::Char>>]
71
- # @return [Array<Array<Vedeu::Views::Char>>]
70
+ # @param value_or_values [Array<Array<Vedeu::Cells::Char>>]
71
+ # @return [Array<Array<Vedeu::Cells::Char>>]
72
72
  def write(value_or_values)
73
73
  buffer.update(value_or_values)
74
74
 
@@ -35,8 +35,8 @@ module Vedeu
35
35
  Vedeu::Buffers::View.new(attributes)
36
36
  end
37
37
 
38
- # @param value_or_values [Array<Array<Vedeu::Views::Char>>|
39
- # Vedeu::Views::Char]
38
+ # @param value_or_values [Array<Array<Vedeu::Cells::Char>>|
39
+ # Vedeu::Cells::Char]
40
40
  # @return [Vedeu::Buffers::View]
41
41
  def update(value_or_values)
42
42
  Array(value_or_values).flatten.each do |value|
@@ -15,11 +15,11 @@ module Vedeu
15
15
 
16
16
  end # Vedeu
17
17
 
18
+ require 'vedeu/cells/support/all'
18
19
  require 'vedeu/cells/empty'
19
20
  require 'vedeu/cells/border'
20
21
  require 'vedeu/cells/borders/all'
21
22
  require 'vedeu/cells/char'
22
23
  require 'vedeu/cells/clear'
24
+ require 'vedeu/cells/cursor'
23
25
  require 'vedeu/cells/escape'
24
- require 'vedeu/cells/html'
25
- require 'vedeu/cells/json'
@@ -42,6 +42,11 @@ module Vedeu
42
42
  self
43
43
  end
44
44
 
45
+ # @return [Symbol]
46
+ def type
47
+ :border
48
+ end
49
+
45
50
  # @return [String]
46
51
  def value
47
52
  return '' unless present?(@value)
@@ -10,12 +10,6 @@ end # Vedeu
10
10
 
11
11
  require 'vedeu/cells/borders/corner'
12
12
  require 'vedeu/cells/borders/horizontal'
13
- require 'vedeu/cells/borders/bottom_horizontal'
14
- require 'vedeu/cells/borders/bottom_left'
15
- require 'vedeu/cells/borders/bottom_right'
16
- require 'vedeu/cells/borders/top_horizontal'
17
- require 'vedeu/cells/borders/top_left'
18
- require 'vedeu/cells/borders/top_right'
19
13
  require 'vedeu/cells/borders/vertical'
20
- require 'vedeu/cells/borders/left_vertical'
21
- require 'vedeu/cells/borders/right_vertical'
14
+ require 'vedeu/cells/borders/vertices/all'
15
+ require 'vedeu/cells/borders/edges/all'
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'vedeu/cells/borders/edges/bottom_horizontal'
4
+ require 'vedeu/cells/borders/edges/top_horizontal'
5
+ require 'vedeu/cells/borders/edges/left_vertical'
6
+ require 'vedeu/cells/borders/edges/right_vertical'
@@ -11,6 +11,11 @@ module Vedeu
11
11
  #
12
12
  class Horizontal < Vedeu::Cells::Border
13
13
 
14
+ # @return [String]
15
+ def as_html
16
+ '&#x2500;'
17
+ end
18
+
14
19
  # @return [String]
15
20
  def text
16
21
  '-'
@@ -11,6 +11,11 @@ module Vedeu
11
11
  #
12
12
  class Vertical < Vedeu::Cells::Border
13
13
 
14
+ # @return [String]
15
+ def as_html
16
+ '&#x2502;'
17
+ end
18
+
14
19
  # @return [String]
15
20
  def text
16
21
  '|'
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'vedeu/cells/borders/vertices/bottom_left'
4
+ require 'vedeu/cells/borders/vertices/bottom_right'
5
+ require 'vedeu/cells/borders/vertices/top_left'
6
+ require 'vedeu/cells/borders/vertices/top_right'
@@ -11,6 +11,11 @@ module Vedeu
11
11
  #
12
12
  class BottomLeft < Vedeu::Cells::Corner
13
13
 
14
+ # @return [String]
15
+ def as_html
16
+ '&#x2514;'
17
+ end
18
+
14
19
  # @return [Symbol]
15
20
  def type
16
21
  :bottom_left
@@ -11,6 +11,11 @@ module Vedeu
11
11
  #
12
12
  class BottomRight < Vedeu::Cells::Corner
13
13
 
14
+ # @return [String]
15
+ def as_html
16
+ '&#x2518;'
17
+ end
18
+
14
19
  # @return [Symbol]
15
20
  def type
16
21
  :bottom_right
@@ -11,6 +11,11 @@ module Vedeu
11
11
  #
12
12
  class TopLeft < Vedeu::Cells::Corner
13
13
 
14
+ # @return [String]
15
+ def as_html
16
+ '&#x250C;'
17
+ end
18
+
14
19
  # @return [Symbol]
15
20
  def type
16
21
  :top_left
@@ -11,6 +11,11 @@ module Vedeu
11
11
  #
12
12
  class TopRight < Vedeu::Cells::Corner
13
13
 
14
+ # @return [String]
15
+ def as_html
16
+ '&#x2510;'
17
+ end
18
+
14
19
  # @return [Symbol]
15
20
  def type
16
21
  :top_right
@@ -14,6 +14,17 @@ module Vedeu
14
14
  #
15
15
  class Char < Vedeu::Cells::Empty
16
16
 
17
+ # @return [String]
18
+ def as_html
19
+ if present?(value)
20
+ value
21
+
22
+ else
23
+ super
24
+
25
+ end
26
+ end
27
+
17
28
  # @return [Boolean]
18
29
  def cell?
19
30
  false
@@ -24,6 +35,11 @@ module Vedeu
24
35
  @value || ' '
25
36
  end
26
37
 
38
+ # @return [Symbol]
39
+ def type
40
+ :char
41
+ end
42
+
27
43
  end # Char
28
44
 
29
45
  end # Cells
@@ -19,6 +19,11 @@ module Vedeu
19
19
  false
20
20
  end
21
21
 
22
+ # @return [Symbol]
23
+ def type
24
+ :clear
25
+ end
26
+
22
27
  # @return [String]
23
28
  def value
24
29
  ' '
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vedeu
4
+
5
+ module Cells
6
+
7
+ # Provides the position and visibility escape sequence for a
8
+ # {Vedeu::Cursors::Cursor}
9
+ #
10
+ # @api private
11
+ #
12
+ class Cursor < Vedeu::Cells::Empty
13
+
14
+ include Vedeu::Geometries::Positionable
15
+
16
+ # @return [Boolean]
17
+ def cell?
18
+ false
19
+ end
20
+
21
+ # @return [NilClass]
22
+ def null
23
+ nil
24
+ end
25
+ alias_method :background, :null
26
+ alias_method :colour, :null
27
+ alias_method :foreground, :null
28
+ alias_method :style, :null
29
+
30
+ # Return an empty hash as most escape sequences won't make
31
+ # sense as JSON.
32
+ #
33
+ # @return [Hash<void>]
34
+ def to_h
35
+ {}.merge!(position.to_h).merge!(value: value)
36
+ end
37
+ alias_method :to_hash, :to_h
38
+
39
+ # Return an empty string as most escape sequences won't make
40
+ # sense as HTML.
41
+ #
42
+ # @param _options [Hash] Ignored.
43
+ # @return [String]
44
+ def to_html(_options = {})
45
+ ''
46
+ end
47
+
48
+ # @return [String]
49
+ def to_s
50
+ "#{position}#{value}"
51
+ end
52
+ alias_method :to_str, :to_s
53
+
54
+ # @return [Symbol]
55
+ def type
56
+ :cursor
57
+ end
58
+
59
+ private
60
+
61
+ # @return [Hash]
62
+ def defaults
63
+ super.merge!(position: [1, 1])
64
+ end
65
+
66
+ end # Cursor
67
+
68
+ end # Cells
69
+
70
+ end # Vedeu