vedeu 0.4.18 → 0.4.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Rakefile +1 -0
- data/bin/vedeu_drb_server +0 -1
- data/bin/vedeu_test +0 -1
- data/config/rubocop_enabled.yml +1 -1
- data/examples/borders_app.rb +0 -1
- data/examples/colours_app.rb +0 -1
- data/examples/cursor_app.rb +0 -1
- data/examples/drb_app.rb +0 -1
- data/examples/geometry_app.rb +0 -1
- data/examples/hello_world.rb +0 -1
- data/examples/lines_app.rb +0 -1
- data/examples/material_colours_app.rb +0 -1
- data/examples/typed_commands/typed_commands_app.rb +0 -1
- data/examples/view_templates_app/view_templates_app.rb +0 -1
- data/lib/vedeu/api.rb +2 -1
- data/lib/vedeu/application.rb +3 -2
- data/lib/vedeu/bindings.rb +3 -5
- data/lib/vedeu/buffers/buffer.rb +8 -11
- data/lib/vedeu/buffers/display_buffer.rb +0 -2
- data/lib/vedeu/configuration/api.rb +1 -4
- data/lib/vedeu/configuration/cli.rb +153 -74
- data/lib/vedeu/configuration/configuration.rb +1 -2
- data/lib/vedeu/cursor/cursor.rb +0 -4
- data/lib/vedeu/cursor/move.rb +3 -6
- data/lib/vedeu/cursor/refresh_cursor.rb +12 -2
- data/lib/vedeu/distributed/client.rb +3 -2
- data/lib/vedeu/distributed/server.rb +4 -3
- data/lib/vedeu/distributed/subprocess.rb +3 -4
- data/lib/vedeu/distributed/test_application.rb +0 -1
- data/lib/vedeu/distributed/uri.rb +0 -1
- data/lib/vedeu/dsl/components/border.rb +3 -4
- data/lib/vedeu/dsl/components/geometry.rb +1 -5
- data/lib/vedeu/dsl/components/keymap.rb +1 -3
- data/lib/vedeu/dsl/components/menu.rb +1 -2
- data/lib/vedeu/dsl/composition.rb +3 -4
- data/lib/vedeu/dsl/group.rb +1 -4
- data/lib/vedeu/dsl/interface.rb +3 -10
- data/lib/vedeu/dsl/line.rb +3 -4
- data/lib/vedeu/dsl/shared/text.rb +0 -3
- data/lib/vedeu/dsl/stream.rb +3 -4
- data/lib/vedeu/dsl/view.rb +0 -3
- data/lib/vedeu/events/event.rb +3 -3
- data/lib/vedeu/events/trigger.rb +3 -2
- data/lib/vedeu/geometry/area.rb +0 -1
- data/lib/vedeu/geometry/canvas.rb +0 -1
- data/lib/vedeu/geometry/coordinate.rb +6 -7
- data/lib/vedeu/geometry/dimension.rb +3 -2
- data/lib/vedeu/geometry/geometry.rb +0 -6
- data/lib/vedeu/geometry/grid.rb +3 -2
- data/lib/vedeu/geometry/index_position.rb +0 -1
- data/lib/vedeu/geometry/position.rb +0 -1
- data/lib/vedeu/geometry/position_index.rb +0 -1
- data/lib/vedeu/geometry/position_validator.rb +6 -68
- data/lib/vedeu/input/all.rb +0 -2
- data/lib/vedeu/input/input.rb +3 -2
- data/lib/vedeu/input/key.rb +0 -1
- data/lib/vedeu/input/keymap.rb +4 -7
- data/lib/vedeu/input/mapper.rb +3 -2
- data/lib/vedeu/launcher.rb +3 -2
- data/lib/vedeu/main_loop.rb +1 -1
- data/lib/vedeu/models/cell.rb +0 -1
- data/lib/vedeu/models/char.rb +0 -1
- data/lib/vedeu/models/composition.rb +1 -7
- data/lib/vedeu/models/group.rb +0 -3
- data/lib/vedeu/models/interface.rb +0 -3
- data/lib/vedeu/models/line.rb +0 -4
- data/lib/vedeu/models/menu.rb +5 -8
- data/lib/vedeu/models/stream.rb +0 -4
- data/lib/vedeu/null/all.rb +11 -0
- data/lib/vedeu/null/border.rb +3 -1
- data/lib/vedeu/null/buffer.rb +0 -1
- data/lib/vedeu/null/generic.rb +4 -1
- data/lib/vedeu/null/geometry.rb +0 -1
- data/lib/vedeu/null/interface.rb +36 -7
- data/lib/vedeu/output/background.rb +0 -1
- data/lib/vedeu/output/border.rb +1 -6
- data/lib/vedeu/output/clear.rb +3 -2
- data/lib/vedeu/output/colour.rb +6 -18
- data/lib/vedeu/output/compressor.rb +5 -2
- data/lib/vedeu/output/esc.rb +4 -1
- data/lib/vedeu/output/foreground.rb +0 -5
- data/lib/vedeu/output/html_char.rb +3 -2
- data/lib/vedeu/output/output.rb +1 -5
- data/lib/vedeu/output/refresh.rb +1 -1
- data/lib/vedeu/output/renderers/all.rb +0 -1
- data/lib/vedeu/output/renderers/escape_sequence.rb +3 -2
- data/lib/vedeu/output/renderers/file.rb +85 -80
- data/lib/vedeu/output/renderers/html.rb +77 -72
- data/lib/vedeu/output/renderers/json.rb +45 -42
- data/lib/vedeu/output/renderers/null.rb +11 -8
- data/lib/vedeu/output/renderers/terminal.rb +41 -36
- data/lib/vedeu/output/renderers/text.rb +41 -36
- data/lib/vedeu/output/style.rb +0 -3
- data/lib/vedeu/output/text.rb +3 -2
- data/lib/vedeu/output/viewport.rb +3 -2
- data/lib/vedeu/output/virtual_terminal.rb +0 -1
- data/lib/vedeu/output/wordwrap.rb +3 -2
- data/lib/vedeu/repositories/all.rb +7 -6
- data/lib/vedeu/repositories/collection.rb +0 -1
- data/lib/vedeu/repositories/collections/chars.rb +0 -1
- data/lib/vedeu/repositories/collections/events.rb +0 -1
- data/lib/vedeu/repositories/collections/interfaces.rb +0 -1
- data/lib/vedeu/repositories/collections/keys.rb +0 -1
- data/lib/vedeu/repositories/collections/lines.rb +0 -1
- data/lib/vedeu/repositories/collections/streams.rb +0 -1
- data/lib/vedeu/repositories/model.rb +0 -1
- data/lib/vedeu/repositories/registerable.rb +29 -0
- data/lib/vedeu/repositories/repositories/background_colours.rb +0 -1
- data/lib/vedeu/repositories/repositories/borders.rb +2 -13
- data/lib/vedeu/repositories/repositories/buffers.rb +2 -13
- data/lib/vedeu/repositories/repositories/colours.rb +0 -1
- data/lib/vedeu/repositories/repositories/cursors.rb +1 -2
- data/lib/vedeu/repositories/repositories/events_repository.rb +0 -1
- data/lib/vedeu/repositories/repositories/foreground_colours.rb +0 -1
- data/lib/vedeu/repositories/repositories/geometries.rb +2 -13
- data/lib/vedeu/repositories/repositories/groups.rb +1 -2
- data/lib/vedeu/repositories/repositories/interfaces_repository.rb +2 -14
- data/lib/vedeu/repositories/repositories/keymaps.rb +1 -2
- data/lib/vedeu/repositories/repositories/menus.rb +1 -2
- data/lib/vedeu/repositories/repository.rb +14 -5
- data/lib/vedeu/storage/all.rb +0 -1
- data/lib/vedeu/storage/associative_store.rb +0 -1
- data/lib/vedeu/storage/conveyor_store.rb +0 -1
- data/lib/vedeu/storage/fifo_store.rb +0 -1
- data/lib/vedeu/support/log.rb +0 -3
- data/lib/vedeu/support/options.rb +3 -2
- data/lib/vedeu/support/template.rb +3 -4
- data/lib/vedeu/support/terminal.rb +0 -2
- data/lib/vedeu/support/trace.rb +6 -7
- data/lib/vedeu/support/visibility.rb +1 -2
- data/lib/vedeu.rb +3 -5
- data/test/lib/vedeu/buffers/buffer_test.rb +48 -13
- data/test/lib/vedeu/configuration/cli_test.rb +5 -4
- data/test/lib/vedeu/cursor/refresh_cursor_test.rb +37 -15
- data/test/lib/vedeu/distributed/subprocess_test.rb +1 -0
- data/test/lib/vedeu/dsl/shared/use_test.rb +1 -6
- data/test/lib/vedeu/main_loop_test.rb +11 -0
- data/test/lib/vedeu/null/interface_test.rb +27 -0
- data/test/lib/vedeu/output/output_test.rb +17 -10
- data/test/lib/vedeu/output/presentation_test.rb +35 -7
- data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +50 -0
- data/test/lib/vedeu/output/renderers/file_test.rb +34 -30
- data/test/lib/vedeu/output/renderers/html_test.rb +61 -57
- data/test/lib/vedeu/output/renderers/json_test.rb +40 -36
- data/test/lib/vedeu/output/renderers/null_test.rb +12 -8
- data/test/lib/vedeu/output/renderers/terminal_test.rb +17 -13
- data/test/lib/vedeu/output/renderers/text_test.rb +17 -13
- data/test/lib/vedeu/repositories/model_test.rb +1 -1
- data/test/lib/vedeu/repositories/registerable_test.rb +28 -0
- data/test/lib/vedeu/storage/associative_store_test.rb +7 -0
- data/test/lib/vedeu/storage/conveyor_store_test.rb +7 -0
- data/test/lib/vedeu/storage/fifo_store_test.rb +7 -0
- data/test/support/helpers/model_test_class.rb +6 -2
- data/test/test_helper.rb +2 -0
- data/vedeu.gemspec +3 -2
- metadata +23 -6
- data/test/lib/vedeu/output/renderers/escape_sequence_renderer_test.rb +0 -46
@@ -1,86 +1,91 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
3
|
+
module Renderers
|
4
|
+
|
5
|
+
# Converts a grid of {Vedeu::Char} objects into a stream of escape sequences
|
6
|
+
# and content suitable for a terminal, and writes them to a file in the /tmp
|
7
|
+
# directory.
|
8
|
+
class File
|
9
|
+
|
10
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
11
|
+
# @param options [Hash]
|
12
|
+
# @return [String]
|
13
|
+
def self.render(output, options = {})
|
14
|
+
new(output, options).render
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns a new instance of Vedeu::Renderers::File.
|
18
|
+
#
|
19
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
20
|
+
# @param options [Hash]
|
21
|
+
# @return [Vedeu::Renderers::File]
|
22
|
+
def initialize(output, options = {})
|
23
|
+
@output = output
|
24
|
+
@options = options
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [String]
|
28
|
+
def render
|
29
|
+
::File.open(path, 'w') { |f| f.write(parsed) }
|
30
|
+
|
31
|
+
parsed
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
# @!attribute [r] output
|
37
|
+
# @return [Array<Array<Vedeu::Char>>]
|
38
|
+
attr_reader :output
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
# @return [String]
|
43
|
+
def path
|
44
|
+
"/tmp/#{filename}"
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [String]
|
48
|
+
def filename
|
49
|
+
if timestamp?
|
50
|
+
"out_#{timestamp}"
|
51
|
+
|
52
|
+
else
|
53
|
+
'out'
|
51
54
|
|
55
|
+
end
|
52
56
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
57
|
+
|
58
|
+
# @return [String]
|
59
|
+
def parsed
|
60
|
+
@parsed ||= Vedeu::Compressor.new(output).render
|
61
|
+
end
|
62
|
+
|
63
|
+
# @return [Float]
|
64
|
+
def timestamp
|
65
|
+
@timestamp ||= Time.now.to_f
|
66
|
+
end
|
67
|
+
|
68
|
+
# @return [Boolean]
|
69
|
+
def timestamp?
|
70
|
+
return true if options[:timestamp]
|
71
|
+
|
72
|
+
false
|
73
|
+
end
|
74
|
+
|
75
|
+
# @return [Hash]
|
76
|
+
def options
|
77
|
+
defaults.merge!(@options)
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [Hash]
|
81
|
+
def defaults
|
82
|
+
{
|
83
|
+
timestamp: false,
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
end # File
|
88
|
+
|
89
|
+
end # Renderers
|
85
90
|
|
86
91
|
end # Vedeu
|
@@ -1,85 +1,90 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
3
|
+
module Renderers
|
4
|
+
|
5
|
+
# Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as a HTML table.
|
6
|
+
class HTML
|
7
|
+
|
8
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
9
|
+
# @return [String]
|
10
|
+
def self.render(output)
|
11
|
+
new(output).to_file
|
12
|
+
end
|
13
|
+
|
14
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
15
|
+
# @param path [String]
|
16
|
+
# @return [String]
|
17
|
+
def self.to_file(output, path = nil)
|
18
|
+
new(output).to_file(path)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns a new instance of Vedeu::Renderers::HTML.
|
22
|
+
#
|
23
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
24
|
+
# @return [Vedeu::Renderers::HTML]
|
25
|
+
def initialize(output)
|
26
|
+
@output = output
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [String]
|
30
|
+
def render
|
31
|
+
Vedeu::Template.parse(self, template)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Writes the parsed template to a file (at the given path) and returns the
|
35
|
+
# contents.
|
36
|
+
#
|
37
|
+
# @param path [String]
|
38
|
+
# @return [String]
|
39
|
+
def to_file(path = file_path)
|
40
|
+
content = render
|
41
|
+
|
42
|
+
::File.open(path, 'w') { |file| file.write(content) }
|
43
|
+
|
44
|
+
content
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [String]
|
48
|
+
def html_body
|
49
|
+
out = ''
|
50
|
+
Array(output).each do |line|
|
51
|
+
out << "<tr>\n"
|
52
|
+
line.each do |char|
|
53
|
+
if char.is_a?(Vedeu::Char)
|
54
|
+
out << char.to_html
|
55
|
+
out << "\n"
|
56
|
+
end
|
55
57
|
end
|
58
|
+
out << "</tr>\n"
|
56
59
|
end
|
57
|
-
out
|
60
|
+
out
|
58
61
|
end
|
59
|
-
out
|
60
|
-
end
|
61
62
|
|
62
|
-
|
63
|
+
protected
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
# @!attribute [r] output
|
66
|
+
# @return [Array<Array<Vedeu::Char>>]
|
67
|
+
attr_reader :output
|
67
68
|
|
68
|
-
|
69
|
-
def template
|
70
|
-
File.dirname(__FILE__) + '/../templates/html_renderer.vedeu'
|
71
|
-
end
|
69
|
+
private
|
72
70
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
# @return [String]
|
72
|
+
def template
|
73
|
+
::File.dirname(__FILE__) + '/../templates/html_renderer.vedeu'
|
74
|
+
end
|
75
|
+
|
76
|
+
# @return [String]
|
77
|
+
def file_path
|
78
|
+
"/tmp/vedeu_html_#{timestamp}.html"
|
79
|
+
end
|
80
|
+
|
81
|
+
# return [Fixnum]
|
82
|
+
def timestamp
|
83
|
+
@timestamp ||= Time.now.to_i
|
84
|
+
end
|
77
85
|
|
78
|
-
#
|
79
|
-
def timestamp
|
80
|
-
@timestamp ||= Time.now.to_i
|
81
|
-
end
|
86
|
+
end # HTML
|
82
87
|
|
83
|
-
end # Renderers
|
88
|
+
end # Renderers
|
84
89
|
|
85
90
|
end # Vedeu
|
@@ -1,52 +1,55 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
3
|
+
module Renderers
|
4
|
+
|
5
|
+
# Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as JSON.
|
6
|
+
class JSON
|
7
|
+
|
8
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
9
|
+
# @return [String]
|
10
|
+
def self.render(output)
|
11
|
+
new(output).render
|
12
|
+
end
|
13
|
+
|
14
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
15
|
+
# @param path [String]
|
16
|
+
# @return [String]
|
17
|
+
# def self.to_file(output, path = nil)
|
18
|
+
# new(output).to_file(path)
|
19
|
+
# end
|
20
|
+
|
21
|
+
# Returns a new instance of Vedeu::Renderers::JSON.
|
22
|
+
#
|
23
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
24
|
+
# @return [Vedeu::Renderers::JSON]
|
25
|
+
def initialize(output)
|
26
|
+
@output = output
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [String]
|
30
|
+
def render
|
31
|
+
return '' if output.nil? || output.empty?
|
32
|
+
|
33
|
+
out = ''
|
34
|
+
Array(output).each do |line|
|
35
|
+
out << ''
|
36
|
+
line.each do |char|
|
37
|
+
out << char.to_json
|
38
|
+
out << "\n"
|
39
|
+
end
|
37
40
|
out << "\n"
|
38
41
|
end
|
39
|
-
out
|
42
|
+
out
|
40
43
|
end
|
41
|
-
out
|
42
|
-
end
|
43
44
|
|
44
|
-
|
45
|
+
protected
|
46
|
+
|
47
|
+
# @!attribute [r] output
|
48
|
+
# @return [Array<Array<Vedeu::Char>>]
|
49
|
+
attr_reader :output
|
45
50
|
|
46
|
-
#
|
47
|
-
# @return [Array<Array<Vedeu::Char>>]
|
48
|
-
attr_reader :output
|
51
|
+
end # JSON
|
49
52
|
|
50
|
-
end # Renderers
|
53
|
+
end # Renderers
|
51
54
|
|
52
55
|
end # Vedeu
|
@@ -1,14 +1,17 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
class Renderers::Null
|
3
|
+
module Renderers
|
6
4
|
|
7
|
-
#
|
8
|
-
|
9
|
-
nil
|
10
|
-
end
|
5
|
+
# A renderer which returns nothing.
|
6
|
+
class Null
|
11
7
|
|
12
|
-
|
8
|
+
# @return [NilClass]
|
9
|
+
def self.render(*)
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
|
13
|
+
end # Null
|
14
|
+
|
15
|
+
end # Renderers
|
13
16
|
|
14
17
|
end # Vedeu
|
@@ -1,40 +1,45 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
3
|
+
module Renderers
|
4
|
+
|
5
|
+
# Converts a grid of {Vedeu::Char} objects into a stream of escape sequences
|
6
|
+
# and content suitable for a terminal.
|
7
|
+
class Terminal
|
8
|
+
|
9
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
10
|
+
# @return [String]
|
11
|
+
def self.render(*output)
|
12
|
+
new(*output).render
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns a new instance of Vedeu::Renderers::Terminal.
|
16
|
+
#
|
17
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
18
|
+
# @return [Vedeu::Renderers::Terminal]
|
19
|
+
def initialize(*output)
|
20
|
+
@output = output
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Array<String>]
|
24
|
+
def render
|
25
|
+
Vedeu::Terminal.output(parsed)
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
# @!attribute [r] output
|
31
|
+
# @return [Array<Array<Vedeu::Char>>]
|
32
|
+
attr_reader :output
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# @return [String]
|
37
|
+
def parsed
|
38
|
+
Vedeu::Compressor.new(output).render
|
39
|
+
end
|
40
|
+
|
41
|
+
end # Terminal
|
42
|
+
|
43
|
+
end # Renderers
|
39
44
|
|
40
45
|
end # Vedeu
|
@@ -1,40 +1,45 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
3
|
+
module Renderers
|
4
|
+
|
5
|
+
# Converts a grid of {Vedeu::Char} objects into a stream of escape sequences
|
6
|
+
# and content.
|
7
|
+
class Text
|
8
|
+
|
9
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
10
|
+
# @return [String]
|
11
|
+
def self.render(*output)
|
12
|
+
new(*output).render
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns a new instance of Vedeu::Renderers::Text.
|
16
|
+
#
|
17
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
18
|
+
# @return [Vedeu::Renderers::Text]
|
19
|
+
def initialize(*output)
|
20
|
+
@output = output
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [String]
|
24
|
+
def render
|
25
|
+
parsed
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
# @!attribute [r] output
|
31
|
+
# @return [Array<Array<Vedeu::Char>>]
|
32
|
+
attr_reader :output
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# @return [String]
|
37
|
+
def parsed
|
38
|
+
Vedeu::Compressor.new(output).render
|
39
|
+
end
|
40
|
+
|
41
|
+
end # Text
|
42
|
+
|
43
|
+
end # Renderers
|
39
44
|
|
40
45
|
end # Vedeu
|
data/lib/vedeu/output/style.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'vedeu/support/common'
|
2
|
-
|
3
1
|
module Vedeu
|
4
2
|
|
5
3
|
# Converts the style value or value collection into a terminal escape
|
@@ -11,7 +9,6 @@ module Vedeu
|
|
11
9
|
# Styles are applied as encountered.
|
12
10
|
#
|
13
11
|
# @see Vedeu::Esc
|
14
|
-
#
|
15
12
|
class Style
|
16
13
|
|
17
14
|
include Vedeu::Common
|
data/lib/vedeu/output/text.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
3
|
# Present a string (or object responding to `to_s`).
|
4
|
-
#
|
5
4
|
class Text
|
6
5
|
|
7
6
|
# @see Vedeu::DSL::Text#text
|
@@ -55,7 +54,7 @@ module Vedeu
|
|
55
54
|
model.add(content)
|
56
55
|
end
|
57
56
|
|
58
|
-
|
57
|
+
protected
|
59
58
|
|
60
59
|
# @!attribute [r] value
|
61
60
|
# @return [String]
|
@@ -65,6 +64,8 @@ module Vedeu
|
|
65
64
|
# @return [Hash]
|
66
65
|
attr_reader :options
|
67
66
|
|
67
|
+
private
|
68
|
+
|
68
69
|
# @return [Symbol] One of :align, :centre, :center, :left, :right, :text
|
69
70
|
def anchor
|
70
71
|
options[:anchor]
|