vedeu 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/views/_interfaces.rb +127 -0
- data/examples/views/empty_template.rb +10 -0
- data/examples/views/expected/vedeu_full_screen.html +140 -0
- data/examples/views/expected/vedeu_full_screen.json +96050 -0
- data/examples/views/expected/vedeu_full_screen.out +1 -0
- data/examples/views/expected/vedeu_full_screen.txt +50 -0
- data/examples/views/expected/vedeu_line.html +140 -0
- data/examples/views/expected/vedeu_line.json +96050 -0
- data/examples/views/expected/vedeu_line.out +1 -0
- data/examples/views/expected/vedeu_line.txt +58 -0
- data/examples/views/expected/vedeu_lines.html +140 -0
- data/examples/views/expected/vedeu_lines.json +96050 -0
- data/examples/views/expected/{lines.out → vedeu_lines.out} +1 -1
- data/examples/views/expected/vedeu_lines_alignment.html +80 -0
- data/examples/views/expected/vedeu_lines_alignment.json +46370 -0
- data/examples/views/expected/vedeu_lines_alignment.out +1 -0
- data/examples/views/full_screen.rb +10 -0
- data/examples/views/line.rb +11 -106
- data/examples/views/lines.rb +8 -127
- data/examples/views/lines_alignment.rb +17 -125
- data/examples/views/runner.sh +65 -19
- data/lib/vedeu/borders/border.rb +6 -6
- data/lib/vedeu/borders/refresh.rb +4 -6
- data/lib/vedeu/buffers/buffer.rb +1 -1
- data/lib/vedeu/buffers/terminal.rb +4 -4
- data/lib/vedeu/buffers/view.rb +2 -2
- data/lib/vedeu/cells/all.rb +2 -2
- data/lib/vedeu/cells/border.rb +5 -0
- data/lib/vedeu/cells/borders/all.rb +2 -8
- data/lib/vedeu/cells/borders/edges/all.rb +6 -0
- data/lib/vedeu/cells/borders/{bottom_horizontal.rb → edges/bottom_horizontal.rb} +0 -0
- data/lib/vedeu/cells/borders/{left_vertical.rb → edges/left_vertical.rb} +0 -0
- data/lib/vedeu/cells/borders/{right_vertical.rb → edges/right_vertical.rb} +0 -0
- data/lib/vedeu/cells/borders/{top_horizontal.rb → edges/top_horizontal.rb} +0 -0
- data/lib/vedeu/cells/borders/horizontal.rb +5 -0
- data/lib/vedeu/cells/borders/vertical.rb +5 -0
- data/lib/vedeu/cells/borders/vertices/all.rb +6 -0
- data/lib/vedeu/cells/borders/{bottom_left.rb → vertices/bottom_left.rb} +5 -0
- data/lib/vedeu/cells/borders/{bottom_right.rb → vertices/bottom_right.rb} +5 -0
- data/lib/vedeu/cells/borders/{top_left.rb → vertices/top_left.rb} +5 -0
- data/lib/vedeu/cells/borders/{top_right.rb → vertices/top_right.rb} +5 -0
- data/lib/vedeu/cells/char.rb +16 -0
- data/lib/vedeu/cells/clear.rb +5 -0
- data/lib/vedeu/cells/cursor.rb +70 -0
- data/lib/vedeu/cells/empty.rb +24 -14
- data/lib/vedeu/cells/escape.rb +8 -7
- data/lib/vedeu/cells/support/all.rb +3 -0
- data/lib/vedeu/cells/support/html.rb +98 -0
- data/lib/vedeu/colours/background.rb +21 -1
- data/lib/vedeu/colours/colour.rb +10 -2
- data/lib/vedeu/colours/foreground.rb +21 -1
- data/lib/vedeu/colours/translator.rb +17 -24
- data/lib/vedeu/colours/validator.rb +9 -9
- data/lib/vedeu/configuration/api.rb +1 -1
- data/lib/vedeu/cursors/cursor.rb +5 -5
- data/lib/vedeu/dsl/elements.rb +22 -79
- data/lib/vedeu/dsl/string/text.rb +3 -3
- data/lib/vedeu/editor/cropper.rb +2 -2
- data/lib/vedeu/editor/cursor.rb +1 -1
- data/lib/vedeu/editor/document.rb +1 -1
- data/lib/vedeu/geometries/area/dimension.rb +1 -1
- data/lib/vedeu/geometries/position.rb +5 -2
- data/lib/vedeu/interfaces/clear.rb +5 -5
- data/lib/vedeu/models/row.rb +4 -3
- data/lib/vedeu/output/compressor.rb +7 -7
- data/lib/vedeu/output/output.rb +8 -13
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/presentation/background.rb +2 -2
- data/lib/vedeu/presentation/colour.rb +0 -4
- data/lib/vedeu/presentation/foreground.rb +2 -2
- data/lib/vedeu/presentation/style.rb +1 -1
- data/lib/vedeu/presentation/styles.rb +0 -3
- data/lib/vedeu/renderers/file.rb +10 -68
- data/lib/vedeu/renderers/html.rb +28 -96
- data/lib/vedeu/renderers/json.rb +15 -31
- data/lib/vedeu/renderers/options.rb +160 -14
- data/lib/vedeu/renderers/templates/html_renderer.vedeu +1 -0
- data/lib/vedeu/renderers/terminal.rb +16 -17
- data/lib/vedeu/renderers/text.rb +32 -41
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu/views/all.rb +0 -2
- data/lib/vedeu/views/chars.rb +6 -3
- data/lib/vedeu/views/stream.rb +3 -2
- data/test/lib/vedeu/borders/caption_test.rb +17 -17
- data/test/lib/vedeu/borders/title_test.rb +12 -12
- data/test/lib/vedeu/cells/border_test.rb +6 -0
- data/test/lib/vedeu/cells/borders/{bottom_horizontal_test.rb → edges/bottom_horizontal_test.rb} +0 -0
- data/test/lib/vedeu/cells/borders/{left_vertical_test.rb → edges/left_vertical_test.rb} +0 -0
- data/test/lib/vedeu/cells/borders/{right_vertical_test.rb → edges/right_vertical_test.rb} +0 -0
- data/test/lib/vedeu/cells/borders/{top_horizontal_test.rb → edges/top_horizontal_test.rb} +0 -0
- data/test/lib/vedeu/cells/borders/horizontal_test.rb +6 -0
- data/test/lib/vedeu/cells/borders/vertical_test.rb +6 -0
- data/test/lib/vedeu/cells/borders/{bottom_left_test.rb → vertices/bottom_left_test.rb} +6 -0
- data/test/lib/vedeu/cells/borders/{bottom_right_test.rb → vertices/bottom_right_test.rb} +6 -0
- data/test/lib/vedeu/cells/borders/{top_left_test.rb → vertices/top_left_test.rb} +6 -0
- data/test/lib/vedeu/cells/borders/{top_right_test.rb → vertices/top_right_test.rb} +6 -0
- data/test/lib/vedeu/cells/char_test.rb +18 -0
- data/test/lib/vedeu/cells/clear_test.rb +6 -0
- data/test/lib/vedeu/cells/cursor_test.rb +113 -0
- data/test/lib/vedeu/cells/empty_test.rb +100 -7
- data/test/lib/vedeu/cells/escape_test.rb +29 -13
- data/test/lib/vedeu/cells/support/html_test.rb +100 -0
- data/test/lib/vedeu/colours/background_test.rb +35 -3
- data/test/lib/vedeu/colours/colour_test.rb +66 -0
- data/test/lib/vedeu/colours/foreground_test.rb +35 -3
- data/test/lib/vedeu/colours/translator_test.rb +0 -34
- data/test/lib/vedeu/colours/validator_test.rb +84 -6
- data/test/lib/vedeu/cursors/cursor_test.rb +4 -4
- data/test/lib/vedeu/cursors/refresh_test.rb +4 -1
- data/test/lib/vedeu/dsl/string/text_test.rb +36 -36
- data/test/lib/vedeu/editor/cropper_test.rb +15 -15
- data/test/lib/vedeu/geometries/position_test.rb +14 -1
- data/test/lib/vedeu/models/page_test.rb +10 -10
- data/test/lib/vedeu/models/row_test.rb +7 -7
- data/test/lib/vedeu/output/compressor_test.rb +63 -50
- data/test/lib/vedeu/renderers/file_test.rb +64 -35
- data/test/lib/vedeu/renderers/html_test.rb +15 -12
- data/test/lib/vedeu/renderers/json_test.rb +79 -56
- data/test/lib/vedeu/renderers/options_test.rb +74 -26
- data/test/lib/vedeu/renderers/terminal_test.rb +34 -4
- data/test/lib/vedeu/renderers/text_test.rb +35 -3
- data/test/lib/vedeu/views/chars_test.rb +6 -0
- metadata +50 -41
- data/examples/views/expected/line.out +0 -1
- data/examples/views/expected/lines_alignment.out +0 -1
- data/lib/vedeu/cells/html.rb +0 -21
- data/lib/vedeu/cells/json.rb +0 -21
- data/lib/vedeu/views/char.rb +0 -180
- data/lib/vedeu/views/html_char.rb +0 -133
- data/test/lib/vedeu/cells/html_test.rb +0 -15
- data/test/lib/vedeu/cells/json_test.rb +0 -15
- data/test/lib/vedeu/views/char_test.rb +0 -283
- data/test/lib/vedeu/views/html_char_test.rb +0 -125
data/examples/views/runner.sh
CHANGED
@@ -2,26 +2,72 @@
|
|
2
2
|
|
3
3
|
set -e
|
4
4
|
|
5
|
-
function
|
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
|
-
|
15
|
-
|
16
|
-
du -b /tmp/
|
17
|
-
|
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
|
-
|
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
|
-
|
25
|
-
|
26
|
-
du -b /tmp/
|
27
|
-
|
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"
|
data/lib/vedeu/borders/border.rb
CHANGED
@@ -179,11 +179,11 @@ module Vedeu
|
|
179
179
|
bottom_right: bottom_right,
|
180
180
|
caption: @caption,
|
181
181
|
client: @client,
|
182
|
-
colour:
|
182
|
+
colour: colour,
|
183
183
|
enabled: @enabled,
|
184
184
|
horizontal: @horizontal,
|
185
185
|
left_vertical: left_vertical,
|
186
|
-
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:
|
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:
|
286
|
-
name:
|
287
|
-
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::
|
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::
|
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
|
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
|
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
|
data/lib/vedeu/buffers/buffer.rb
CHANGED
@@ -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::
|
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::
|
56
|
-
# @return [Array<Array<Vedeu::
|
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::
|
71
|
-
# @return [Array<Array<Vedeu::
|
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
|
|
data/lib/vedeu/buffers/view.rb
CHANGED
@@ -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::
|
39
|
-
# Vedeu::
|
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|
|
data/lib/vedeu/cells/all.rb
CHANGED
@@ -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'
|
data/lib/vedeu/cells/border.rb
CHANGED
@@ -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/
|
21
|
-
require 'vedeu/cells/borders/
|
14
|
+
require 'vedeu/cells/borders/vertices/all'
|
15
|
+
require 'vedeu/cells/borders/edges/all'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/vedeu/cells/char.rb
CHANGED
@@ -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
|
data/lib/vedeu/cells/clear.rb
CHANGED
@@ -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
|