vedeu 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/api.rb +8 -0
- data/lib/vedeu/application.rb +2 -0
- data/lib/vedeu/bindings.rb +3 -0
- data/lib/vedeu/configuration/configuration.rb +1 -1
- data/lib/vedeu/cursor/cursor.rb +1 -1
- data/lib/vedeu/cursor/move.rb +1 -1
- data/lib/vedeu/cursor/refresh_cursor.rb +2 -0
- data/lib/vedeu/cursor/toggle.rb +1 -1
- data/lib/vedeu/debug.rb +36 -1
- data/lib/vedeu/distributed/client.rb +2 -0
- data/lib/vedeu/distributed/subprocess.rb +2 -0
- data/lib/vedeu/distributed/test_application.rb +2 -0
- data/lib/vedeu/distributed/uri.rb +2 -0
- data/lib/vedeu/events/event.rb +1 -1
- data/lib/vedeu/events/trigger.rb +2 -0
- data/lib/vedeu/geometry/all.rb +0 -1
- data/lib/vedeu/geometry/area.rb +22 -0
- data/lib/vedeu/geometry/centre.rb +2 -0
- data/lib/vedeu/geometry/content.rb +2 -0
- data/lib/vedeu/geometry/coordinate.rb +2 -0
- data/lib/vedeu/geometry/dimension.rb +2 -0
- data/lib/vedeu/geometry/geometry.rb +8 -3
- data/lib/vedeu/geometry/grid.rb +2 -0
- data/lib/vedeu/geometry/index_position.rb +21 -0
- data/lib/vedeu/geometry/limit.rb +2 -0
- data/lib/vedeu/geometry/position.rb +1 -1
- data/lib/vedeu/geometry/position_index.rb +2 -0
- data/lib/vedeu/geometry/position_validator.rb +2 -0
- data/lib/vedeu/input/input.rb +1 -1
- data/lib/vedeu/input/key.rb +1 -1
- data/lib/vedeu/input/keymap.rb +2 -0
- data/lib/vedeu/input/mapper.rb +8 -0
- data/lib/vedeu/launcher.rb +2 -0
- data/lib/vedeu/main_loop.rb +1 -3
- data/lib/vedeu/models/cell.rb +2 -0
- data/lib/vedeu/models/composition.rb +1 -1
- data/lib/vedeu/models/group.rb +1 -1
- data/lib/vedeu/models/interface.rb +35 -3
- data/lib/vedeu/models/line.rb +6 -1
- data/lib/vedeu/models/menu.rb +1 -1
- data/lib/vedeu/models/stream.rb +6 -17
- data/lib/vedeu/output/all.rb +3 -2
- data/lib/vedeu/output/background.rb +26 -0
- data/lib/vedeu/output/border.rb +105 -25
- data/lib/vedeu/output/clear.rb +17 -10
- data/lib/vedeu/output/colour.rb +1 -1
- data/lib/vedeu/output/compositor.rb +4 -1
- data/lib/vedeu/output/foreground.rb +26 -0
- data/lib/vedeu/output/html_char.rb +2 -0
- data/lib/vedeu/output/null_border.rb +49 -0
- data/lib/vedeu/output/output.rb +8 -44
- data/lib/vedeu/output/renderers/all.rb +3 -0
- data/lib/vedeu/output/{renderer.rb → renderers/file_renderer.rb} +14 -6
- data/lib/vedeu/output/{html_renderer.rb → renderers/html_renderer.rb} +3 -1
- data/lib/vedeu/output/renderers/terminal_renderer.rb +50 -0
- data/lib/vedeu/output/text.rb +1 -1
- data/lib/vedeu/output/translator.rb +21 -2
- data/lib/vedeu/output/viewport.rb +17 -50
- data/lib/vedeu/output/virtual_terminal.rb +2 -0
- data/lib/vedeu/output/wordwrap.rb +2 -0
- data/lib/vedeu/repositories/all.rb +82 -0
- data/lib/vedeu/repositories/collection.rb +16 -0
- data/lib/vedeu/repositories/repository.rb +2 -0
- data/lib/vedeu/support/log.rb +3 -0
- data/lib/vedeu/support/sentence.rb +2 -0
- data/lib/vedeu/support/template.rb +2 -0
- data/lib/vedeu/support/terminal.rb +6 -1
- data/lib/vedeu/support/trace.rb +2 -0
- data/lib/vedeu/support/visible.rb +6 -0
- data/test/lib/vedeu/dsl/components/border_test.rb +0 -270
- data/test/lib/vedeu/dsl/shared/text_test.rb +19 -0
- data/test/lib/vedeu/geometry/area_test.rb +32 -0
- data/test/lib/vedeu/geometry/index_position_test.rb +36 -0
- data/test/lib/vedeu/models/interface_test.rb +42 -1
- data/test/lib/vedeu/models/line_test.rb +15 -1
- data/test/lib/vedeu/models/stream_test.rb +15 -1
- data/test/lib/vedeu/output/background_test.rb +4 -2
- data/test/lib/vedeu/output/border_test.rb +229 -127
- data/test/lib/vedeu/output/clear_test.rb +14 -0
- data/test/lib/vedeu/output/foreground_test.rb +4 -2
- data/test/lib/vedeu/output/null_border_test.rb +53 -0
- data/test/lib/vedeu/output/output_test.rb +2 -0
- data/test/lib/vedeu/output/{renderer_test.rb → renderers/file_renderer_test.rb} +5 -5
- data/test/lib/vedeu/output/renderers/html_renderer_test.rb +71 -0
- data/test/lib/vedeu/output/renderers/terminal_renderer_test.rb +24 -0
- data/test/lib/vedeu/output/viewport_test.rb +100 -74
- data/vedeu.gemspec +1 -1
- metadata +15 -11
- data/lib/vedeu/geometry/bounding_area.rb +0 -136
- data/test/lib/vedeu/geometry/bounding_area_test.rb +0 -123
- data/test/lib/vedeu/output/html_renderer_test.rb +0 -42
data/lib/vedeu/output/clear.rb
CHANGED
@@ -4,18 +4,23 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
class Clear
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
class << self
|
8
|
+
|
9
|
+
# Clears the area defined by the interface.
|
10
|
+
#
|
11
|
+
# @return [Array|String]
|
12
|
+
# @see #initialize
|
13
|
+
def clear(interface)
|
14
|
+
new(interface).write
|
15
|
+
end
|
16
|
+
alias_method :render, :clear
|
17
|
+
|
13
18
|
end
|
14
19
|
|
15
|
-
# Return a new instance of
|
20
|
+
# Return a new instance of Vedeu::Clear.
|
16
21
|
#
|
17
22
|
# @param interface [Interface]
|
18
|
-
# @return [
|
23
|
+
# @return [Vedeu::Clear]
|
19
24
|
def initialize(interface)
|
20
25
|
@interface = interface
|
21
26
|
end
|
@@ -26,7 +31,7 @@ module Vedeu
|
|
26
31
|
#
|
27
32
|
# @return [Array<Array<Vedeu::Char>>]
|
28
33
|
def clear
|
29
|
-
Array.new(interface.height) do |iy|
|
34
|
+
@clear ||= Array.new(interface.height) do |iy|
|
30
35
|
Array.new(interface.width) do |ix|
|
31
36
|
Vedeu::Char.new({ value: ' ',
|
32
37
|
colour: interface.colour,
|
@@ -48,7 +53,9 @@ module Vedeu
|
|
48
53
|
Vedeu::HTMLRenderer.to_file(Vedeu::VirtualBuffer.retrieve)
|
49
54
|
end
|
50
55
|
|
51
|
-
Vedeu::
|
56
|
+
# Vedeu::FileRenderer.render(clear)
|
57
|
+
|
58
|
+
Vedeu::TerminalRenderer.render(clear)
|
52
59
|
end
|
53
60
|
|
54
61
|
private
|
data/lib/vedeu/output/colour.rb
CHANGED
@@ -20,7 +20,7 @@ module Vedeu
|
|
20
20
|
new(name).compose
|
21
21
|
end
|
22
22
|
|
23
|
-
# Initialize a new Compositor.
|
23
|
+
# Initialize a new Vedeu::Compositor.
|
24
24
|
#
|
25
25
|
# @param name [String] The name of the buffer.
|
26
26
|
# @return [Compositor]
|
@@ -28,6 +28,9 @@ module Vedeu
|
|
28
28
|
@name = name
|
29
29
|
end
|
30
30
|
|
31
|
+
# Applies any overridden colours or styles in the buffered view to the
|
32
|
+
# stored interface.
|
33
|
+
#
|
31
34
|
# @return [Array<Interface>]
|
32
35
|
def compose
|
33
36
|
buffer.each do |view|
|
@@ -11,6 +11,32 @@ module Vedeu
|
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
+
# Registers a HTML/CSS colour code and escape sequence to reduce processing.
|
15
|
+
#
|
16
|
+
# @param colour [String] A HTML/CSS colour code.
|
17
|
+
# @param escape_sequence [String] The HTML/CSS colour code as an escape
|
18
|
+
# sequence.
|
19
|
+
# @return [String]
|
20
|
+
def register(colour, escape_sequence)
|
21
|
+
Vedeu.foreground_colours.register(colour, escape_sequence)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns a boolean indicating the HTML/CSS colour code has been registered.
|
25
|
+
#
|
26
|
+
# @param colour [String]
|
27
|
+
# @return [Boolean]
|
28
|
+
def registered?(colour)
|
29
|
+
Vedeu.foreground_colours.registered?(colour)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Retrieves the escape sequence for the HTML/CSS colour code.
|
33
|
+
#
|
34
|
+
# @param colour [String]
|
35
|
+
# @return [String]
|
36
|
+
def retrieve(colour)
|
37
|
+
Vedeu.foreground_colours.retrieve(colour)
|
38
|
+
end
|
39
|
+
|
14
40
|
# @return [String]
|
15
41
|
def named_codes
|
16
42
|
Vedeu::Esc.foreground_codes[colour]
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Provides a non-existent Vedeu::Border that acts like the real thing, but
|
4
|
+
# does nothing.
|
5
|
+
#
|
6
|
+
class NullBorder
|
7
|
+
|
8
|
+
# Returns a new instance of Vedeu::NullBorder.
|
9
|
+
#
|
10
|
+
# @param interface [Vedeu::Interface]
|
11
|
+
# @return [Vedeu::NullBorder]
|
12
|
+
def initialize(interface)
|
13
|
+
@interface = interface
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Fixnum]
|
17
|
+
def bx
|
18
|
+
interface.x
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Fixnum]
|
22
|
+
def bxn
|
23
|
+
interface.xn
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Fixnum]
|
27
|
+
def by
|
28
|
+
interface.y
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Fixnum]
|
32
|
+
def byn
|
33
|
+
interface.yn
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Array]
|
37
|
+
def render
|
38
|
+
[]
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
# @!attribute [r] interface
|
44
|
+
# @return [Vedeu::Interface]
|
45
|
+
attr_reader :interface
|
46
|
+
|
47
|
+
end # NullBorder
|
48
|
+
|
49
|
+
end # Vedeu
|
data/lib/vedeu/output/output.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
require 'vedeu/output/
|
2
|
-
require 'vedeu/output/html_renderer'
|
3
|
-
require 'vedeu/output/renderer'
|
4
|
-
require 'vedeu/output/viewport'
|
1
|
+
require 'vedeu/output/renderers/all'
|
5
2
|
require 'vedeu/output/virtual_buffer'
|
6
3
|
require 'vedeu/support/terminal'
|
7
4
|
|
@@ -20,7 +17,7 @@ module Vedeu
|
|
20
17
|
new(interface).render
|
21
18
|
end
|
22
19
|
|
23
|
-
# Return a new instance of Output.
|
20
|
+
# Return a new instance of Vedeu::Output.
|
24
21
|
#
|
25
22
|
# @param interface [Interface]
|
26
23
|
# @return [Output]
|
@@ -33,12 +30,14 @@ module Vedeu
|
|
33
30
|
# @return [Array]
|
34
31
|
def render
|
35
32
|
if Vedeu::Configuration.drb?
|
36
|
-
Vedeu.trigger(:_drb_store_output_,
|
33
|
+
Vedeu.trigger(:_drb_store_output_, rendered)
|
37
34
|
|
38
35
|
Vedeu::HTMLRenderer.to_file(Vedeu::VirtualBuffer.retrieve)
|
39
36
|
end
|
40
37
|
|
41
|
-
Vedeu::
|
38
|
+
# Vedeu::FileRenderer.render(rendered)
|
39
|
+
|
40
|
+
Vedeu::TerminalRenderer.render(rendered)
|
42
41
|
end
|
43
42
|
|
44
43
|
private
|
@@ -47,43 +46,8 @@ module Vedeu
|
|
47
46
|
# @return [Interface]
|
48
47
|
attr_reader :interface
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
#
|
53
|
-
# @note
|
54
|
-
# omg!
|
55
|
-
#
|
56
|
-
# @return [Array<Array<Vedeu::Char>>]
|
57
|
-
def virtual_view
|
58
|
-
out = [ clear_area_first! ]
|
59
|
-
|
60
|
-
Vedeu.log(type: :output, message: "Rendering: '#{interface.name}'")
|
61
|
-
|
62
|
-
viewport.each_with_index do |line, iy|
|
63
|
-
row = []
|
64
|
-
line.each_with_index do |char, ix|
|
65
|
-
row << if char.x != ix || char.y != iy
|
66
|
-
char.position = Vedeu::IndexPosition[iy, ix, interface.top, interface.left]
|
67
|
-
char
|
68
|
-
|
69
|
-
else
|
70
|
-
char
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
out << row
|
75
|
-
end
|
76
|
-
out
|
77
|
-
end
|
78
|
-
|
79
|
-
# @return [Array<Array<Vedeu::Char>>]
|
80
|
-
def clear_area_first!
|
81
|
-
Vedeu::Clear.new(interface).clear
|
82
|
-
end
|
83
|
-
|
84
|
-
# @return [void]
|
85
|
-
def viewport
|
86
|
-
@viewport ||= Vedeu::Viewport.new(interface).render
|
49
|
+
def rendered
|
50
|
+
@rendered ||= interface.render
|
87
51
|
end
|
88
52
|
|
89
53
|
end # Output
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
3
|
# Converts a grid of {Vedeu::Char} objects into a stream of escape sequences
|
4
|
-
# and content suitable for a terminal
|
4
|
+
# and content suitable for a terminal, and writes them to a file in the /tmp
|
5
|
+
# directory.
|
5
6
|
#
|
6
|
-
class
|
7
|
+
class FileRenderer
|
7
8
|
|
8
9
|
# @param output [Array<Array<Vedeu::Char>>]
|
9
10
|
# @return [String]
|
@@ -11,15 +12,17 @@ module Vedeu
|
|
11
12
|
new(*output).render
|
12
13
|
end
|
13
14
|
|
15
|
+
# Returns a new instance of Vedeu::FileRenderer.
|
16
|
+
#
|
14
17
|
# @param output [Array<Array<Vedeu::Char>>]
|
15
|
-
# @return [Vedeu::
|
18
|
+
# @return [Vedeu::FileRenderer]
|
16
19
|
def initialize(*output)
|
17
|
-
@output
|
20
|
+
@output = output
|
18
21
|
end
|
19
22
|
|
20
23
|
# @return [String]
|
21
24
|
def render
|
22
|
-
|
25
|
+
File.open("/tmp/out_#{Time.now.to_f}", 'w') { |f| f.write(parsed) }
|
23
26
|
end
|
24
27
|
|
25
28
|
private
|
@@ -28,6 +31,11 @@ module Vedeu
|
|
28
31
|
# @return [Array<Array<Vedeu::Char>>]
|
29
32
|
attr_reader :output
|
30
33
|
|
31
|
-
|
34
|
+
# @return [String]
|
35
|
+
def parsed
|
36
|
+
Array(output).flatten.map(&:to_s).join
|
37
|
+
end
|
38
|
+
|
39
|
+
end # FileRenderer
|
32
40
|
|
33
41
|
end # Vedeu
|
@@ -17,6 +17,8 @@ module Vedeu
|
|
17
17
|
new(output).to_file(path)
|
18
18
|
end
|
19
19
|
|
20
|
+
# Returns a new instance of Vedeu::HTMLRenderer.
|
21
|
+
#
|
20
22
|
# @param output [Array<Array<Vedeu::Char>>]
|
21
23
|
# @return [Vedeu::HTMLRenderer]
|
22
24
|
def initialize(output)
|
@@ -63,7 +65,7 @@ module Vedeu
|
|
63
65
|
|
64
66
|
# @return [String]
|
65
67
|
def template
|
66
|
-
File.dirname(__FILE__) + '
|
68
|
+
File.dirname(__FILE__) + '/../templates/html_renderer.vedeu'
|
67
69
|
end
|
68
70
|
|
69
71
|
# @return [String]
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Converts a grid of {Vedeu::Char} objects into a stream of escape sequences
|
4
|
+
# and content suitable for a terminal.
|
5
|
+
#
|
6
|
+
class TerminalRenderer
|
7
|
+
|
8
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
9
|
+
# @return [String]
|
10
|
+
def self.render(*output)
|
11
|
+
new(*output).render
|
12
|
+
end
|
13
|
+
|
14
|
+
# Returns a new instance of Vedeu::TerminalRenderer.
|
15
|
+
#
|
16
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
17
|
+
# @return [Vedeu::TerminalRenderer]
|
18
|
+
def initialize(*output)
|
19
|
+
@output = output
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Array<String>]
|
23
|
+
def render
|
24
|
+
Vedeu::Terminal.output(hide_cursor, parsed, show_cursor)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# @!attribute [r] output
|
30
|
+
# @return [Array<Array<Vedeu::Char>>]
|
31
|
+
attr_reader :output
|
32
|
+
|
33
|
+
# @return [String]
|
34
|
+
def show_cursor
|
35
|
+
Vedeu::Esc.string(:show_cursor)
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String]
|
39
|
+
def parsed
|
40
|
+
Array(output).flatten.map(&:to_s).join
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [String]
|
44
|
+
def hide_cursor
|
45
|
+
Vedeu::Esc.string(:hide_cursor)
|
46
|
+
end
|
47
|
+
|
48
|
+
end # TerminalRenderer
|
49
|
+
|
50
|
+
end # Vedeu
|
data/lib/vedeu/output/text.rb
CHANGED
@@ -38,7 +38,7 @@ module Vedeu
|
|
38
38
|
new(colour).escape_sequence
|
39
39
|
end
|
40
40
|
|
41
|
-
# Return a new instance of Translator.
|
41
|
+
# Return a new instance of Vedeu::Translator.
|
42
42
|
#
|
43
43
|
# @param colour [Fixnum|String|Symbol]
|
44
44
|
# @return [Translator]
|
@@ -52,6 +52,9 @@ module Vedeu
|
|
52
52
|
if no_colour?
|
53
53
|
''
|
54
54
|
|
55
|
+
elsif registered?(colour)
|
56
|
+
retrieve(colour)
|
57
|
+
|
55
58
|
elsif rgb?
|
56
59
|
rgb
|
57
60
|
|
@@ -81,6 +84,22 @@ module Vedeu
|
|
81
84
|
|
82
85
|
private
|
83
86
|
|
87
|
+
# Subclasses implement this method.
|
88
|
+
#
|
89
|
+
# @param colour [String]
|
90
|
+
# @return [String]
|
91
|
+
def retrieve(colour)
|
92
|
+
''
|
93
|
+
end
|
94
|
+
|
95
|
+
# Subclasses implement this method.
|
96
|
+
#
|
97
|
+
# @param colour [String]
|
98
|
+
# @return [FalseClass]
|
99
|
+
def registered?(colour)
|
100
|
+
false
|
101
|
+
end
|
102
|
+
|
84
103
|
# @return [Boolean]
|
85
104
|
def no_colour?
|
86
105
|
colour.nil? || colour.to_s.empty?
|
@@ -136,7 +155,7 @@ module Vedeu
|
|
136
155
|
# @return [String]
|
137
156
|
def rgb
|
138
157
|
if Vedeu::Configuration.colour_mode == 16777216
|
139
|
-
sprintf(rgb_prefix, *css_to_rgb)
|
158
|
+
register(colour, sprintf(rgb_prefix, *css_to_rgb))
|
140
159
|
|
141
160
|
else
|
142
161
|
numbered
|
@@ -24,7 +24,13 @@ module Vedeu
|
|
24
24
|
:height,
|
25
25
|
:width
|
26
26
|
|
27
|
-
#
|
27
|
+
# @param interface [Vedeu::Interface]
|
28
|
+
# @return [Array<Array<Vedeu::Char>>]
|
29
|
+
def self.render(interface)
|
30
|
+
new(interface).render
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns an instance of Vedeu::Viewport.
|
28
34
|
#
|
29
35
|
# @param interface [Interface] An instance of interface.
|
30
36
|
# @return [Viewport]
|
@@ -37,30 +43,25 @@ module Vedeu
|
|
37
43
|
#
|
38
44
|
# @return [Array<Array<String>>]
|
39
45
|
def render
|
40
|
-
|
41
|
-
out = []
|
46
|
+
Vedeu.log(type: :output, message: "Rendering: '#{interface.name}'")
|
42
47
|
|
43
|
-
|
48
|
+
out = []
|
44
49
|
|
45
|
-
|
46
|
-
|
50
|
+
show[0...bordered_height].each_with_index do |line, iy|
|
51
|
+
line[0...bordered_width].each_with_index do |column, ix|
|
52
|
+
column.position = IndexPosition[iy, ix, interface.border.by, interface.border.bx]
|
53
|
+
out << column
|
47
54
|
end
|
48
|
-
|
49
|
-
out << border.bottom if border.bottom?
|
50
|
-
|
51
|
-
out
|
52
|
-
|
53
|
-
else
|
54
|
-
show
|
55
|
-
|
56
55
|
end
|
56
|
+
|
57
|
+
out
|
57
58
|
end
|
58
59
|
|
59
60
|
# Returns a string representation of the viewport.
|
60
61
|
#
|
61
62
|
# @return [String]
|
62
63
|
def to_s
|
63
|
-
render.map(&:
|
64
|
+
render.map(&:to_s).join("\n")
|
64
65
|
end
|
65
66
|
|
66
67
|
private
|
@@ -80,41 +81,7 @@ module Vedeu
|
|
80
81
|
def show
|
81
82
|
return [] unless lines?
|
82
83
|
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
# Returns the lines, padded where necessary for the viewport.
|
87
|
-
#
|
88
|
-
# @return [Array<Array<String>>]
|
89
|
-
def padded_lines
|
90
|
-
visible = lines[rows] || []
|
91
|
-
|
92
|
-
pad(visible, :height)
|
93
|
-
end
|
94
|
-
|
95
|
-
# Returns the columns, padded where necessary for the given line.
|
96
|
-
#
|
97
|
-
# @param line [Array<String>]
|
98
|
-
# @return [Array<String>]
|
99
|
-
def padded_columns(line)
|
100
|
-
visible = line.chars[columns] || []
|
101
|
-
|
102
|
-
pad(visible, :width)
|
103
|
-
end
|
104
|
-
|
105
|
-
# Pads the number of rows or columns to always return an Array of the same
|
106
|
-
# length for each viewport or line respectively.
|
107
|
-
#
|
108
|
-
# @param visible [Array<Array<String>>|Array<String>]
|
109
|
-
# @param dimension [Symbol] The dimension to pad (:height or :width).
|
110
|
-
# @return [Array<Array<String>>|Array<String>]
|
111
|
-
def pad(visible, dimension)
|
112
|
-
dim = send(dimension)
|
113
|
-
size = visible.size
|
114
|
-
|
115
|
-
return visible unless size < dim
|
116
|
-
|
117
|
-
visible + [Vedeu::Char.new({ value: ' ' })] * (dim - size)
|
84
|
+
(lines[rows] || []).map { |line| (line.chars[columns] || []) }
|
118
85
|
end
|
119
86
|
|
120
87
|
# Using the current cursor's y position, return a range of visible lines.
|