vedeu 0.6.8 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/README.md +1 -1
- data/docs/api.md +60 -67
- data/docs/configuration.md +8 -5
- data/docs/events.md +31 -15
- data/docs/events/application.md +12 -0
- data/docs/events/document.md +57 -0
- data/docs/events/drb.md +43 -0
- data/docs/events/focus.md +24 -0
- data/docs/events/menu.md +57 -0
- data/docs/events/movement.md +57 -0
- data/docs/events/refresh.md +25 -0
- data/docs/events/system.md +90 -0
- data/docs/events/visibility.md +68 -0
- data/lib/vedeu.rb +2 -2
- data/lib/vedeu/all.rb +3 -2
- data/lib/vedeu/api.rb +18 -18
- data/lib/vedeu/application/controller.rb +1 -1
- data/lib/vedeu/application/helper.rb +1 -1
- data/lib/vedeu/application/view.rb +1 -1
- data/lib/vedeu/bindings/application.rb +1 -12
- data/lib/vedeu/bindings/bindings.rb +3 -1
- data/lib/vedeu/bindings/document.rb +9 -62
- data/lib/vedeu/bindings/drb.rb +12 -56
- data/lib/vedeu/bindings/focus.rb +3 -28
- data/lib/vedeu/bindings/menus.rb +10 -66
- data/lib/vedeu/bindings/movement.rb +4 -69
- data/lib/vedeu/bindings/refresh.rb +3 -33
- data/lib/vedeu/bindings/system.rb +14 -100
- data/lib/vedeu/bindings/visibility.rb +20 -71
- data/lib/vedeu/borders/all.rb +4 -3
- data/lib/vedeu/borders/border.rb +39 -33
- data/lib/vedeu/borders/dsl.rb +40 -33
- data/lib/vedeu/borders/null.rb +2 -2
- data/lib/vedeu/borders/render.rb +29 -24
- data/lib/vedeu/borders/repository.rb +2 -2
- data/lib/vedeu/buffers/all.rb +8 -7
- data/lib/vedeu/buffers/buffer.rb +47 -39
- data/lib/vedeu/buffers/null.rb +2 -2
- data/lib/vedeu/buffers/refresh.rb +4 -3
- data/lib/vedeu/buffers/virtual_buffer.rb +122 -118
- data/lib/vedeu/buffers/virtual_buffers.rb +62 -56
- data/lib/vedeu/colours/background.rb +2 -1
- data/lib/vedeu/colours/colour.rb +21 -19
- data/lib/vedeu/colours/foreground.rb +2 -1
- data/lib/vedeu/colours/repository.rb +6 -5
- data/lib/vedeu/colours/translator.rb +39 -35
- data/lib/vedeu/configuration/api.rb +59 -51
- data/lib/vedeu/configuration/cli.rb +9 -7
- data/lib/vedeu/configuration/configuration.rb +41 -32
- data/lib/vedeu/cursors/cursor.rb +1 -1
- data/lib/vedeu/cursors/refresh.rb +20 -16
- data/lib/vedeu/distributed/server.rb +8 -6
- data/lib/vedeu/distributed/subprocess.rb +90 -86
- data/lib/vedeu/distributed/uri.rb +4 -3
- data/lib/vedeu/dsl/composition.rb +2 -2
- data/lib/vedeu/dsl/group.rb +4 -4
- data/lib/vedeu/dsl/interface.rb +5 -5
- data/lib/vedeu/dsl/presentation.rb +2 -2
- data/lib/vedeu/dsl/text.rb +1 -1
- data/lib/vedeu/editor/cropper.rb +4 -4
- data/lib/vedeu/editor/cursor.rb +6 -4
- data/lib/vedeu/editor/document.rb +20 -18
- data/lib/vedeu/editor/editor.rb +2 -2
- data/lib/vedeu/editor/line.rb +10 -5
- data/lib/vedeu/editor/lines.rb +2 -2
- data/lib/vedeu/internal_api.rb +4 -4
- data/lib/vedeu/models/focus.rb +197 -191
- data/lib/vedeu/models/group.rb +171 -159
- data/lib/vedeu/models/groups.rb +14 -10
- data/lib/vedeu/models/interface.rb +116 -110
- data/lib/vedeu/models/interfaces.rb +24 -20
- data/lib/vedeu/models/toggleable.rb +4 -4
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/composition.rb +1 -1
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/models/views/stream.rb +1 -1
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/null/interface.rb +1 -1
- data/lib/vedeu/null/view.rb +1 -1
- data/lib/vedeu/output/clear/named_interface.rb +1 -1
- data/lib/vedeu/output/compressor.rb +78 -73
- data/lib/vedeu/output/direct.rb +61 -57
- data/lib/vedeu/output/output.rb +34 -29
- data/lib/vedeu/output/{presentation.rb → presentation/presentation.rb} +2 -1
- data/lib/vedeu/output/presentation/style.rb +64 -18
- data/lib/vedeu/output/presentation/styles.rb +39 -0
- data/lib/vedeu/output/renderers/html.rb +2 -2
- data/lib/vedeu/output/renderers/json.rb +2 -1
- data/lib/vedeu/output/renderers/terminal.rb +3 -3
- data/lib/vedeu/output/renderers/text.rb +3 -3
- data/lib/vedeu/output/text.rb +186 -180
- data/lib/vedeu/output/wordwrap.rb +142 -138
- data/lib/vedeu/refresh/refresh.rb +2 -2
- data/lib/vedeu/templating/helpers.rb +11 -6
- data/lib/vedeu/templating/view_template.rb +1 -1
- data/lib/vedeu/terminal/terminal.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/render_test.rb +1 -1
- data/test/lib/vedeu/buffers/buffer_test.rb +16 -14
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +105 -101
- data/test/lib/vedeu/buffers/virtual_buffers_test.rb +43 -39
- data/test/lib/vedeu/colours/colour_test.rb +4 -4
- data/test/lib/vedeu/cursors/cursor_test.rb +2 -2
- data/test/lib/vedeu/cursors/repository_test.rb +3 -3
- data/test/lib/vedeu/distributed/subprocess_test.rb +33 -29
- data/test/lib/vedeu/dsl/group_test.rb +3 -3
- data/test/lib/vedeu/dsl/interface_test.rb +6 -5
- data/test/lib/vedeu/dsl/line_test.rb +4 -2
- data/test/lib/vedeu/dsl/presentation_test.rb +2 -2
- data/test/lib/vedeu/dsl/text_test.rb +8 -8
- data/test/lib/vedeu/editor/document_test.rb +10 -6
- data/test/lib/vedeu/input/keymap_test.rb +1 -10
- data/test/lib/vedeu/models/focus_test.rb +177 -170
- data/test/lib/vedeu/models/group_test.rb +99 -95
- data/test/lib/vedeu/models/groups_test.rb +13 -9
- data/test/lib/vedeu/models/interface_test.rb +93 -87
- data/test/lib/vedeu/models/interfaces_test.rb +24 -20
- data/test/lib/vedeu/models/views/char_test.rb +2 -2
- data/test/lib/vedeu/models/views/line_test.rb +11 -7
- data/test/lib/vedeu/models/views/stream_test.rb +1 -1
- data/test/lib/vedeu/models/views/view_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_group_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_interface_test.rb +3 -1
- data/test/lib/vedeu/output/compressor_test.rb +126 -122
- data/test/lib/vedeu/output/direct_test.rb +49 -43
- data/test/lib/vedeu/output/output_test.rb +35 -31
- data/test/lib/vedeu/output/{presentation_test.rb → presentation/presentation_test.rb} +11 -7
- data/test/lib/vedeu/output/presentation/style_test.rb +88 -48
- data/test/lib/vedeu/output/presentation/styles_test.rb +84 -0
- data/test/lib/vedeu/output/text_test.rb +109 -105
- data/test/lib/vedeu/output/viewport_test.rb +3 -1
- data/test/lib/vedeu/output/wordwrap_test.rb +209 -205
- data/test/lib/vedeu/refresh/refresh_test.rb +3 -1
- data/test/lib/vedeu/templating/helpers_test.rb +6 -6
- data/test/lib/vedeu/templating/view_template_test.rb +1 -1
- metadata +17 -8
- data/lib/vedeu/output/style.rb +0 -76
- data/test/lib/vedeu/output/style_test.rb +0 -120
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'vedeu/output/presentation/colour'
|
2
|
+
require 'vedeu/output/presentation/styles'
|
2
3
|
require 'vedeu/output/presentation/style'
|
3
4
|
|
4
5
|
module Vedeu
|
@@ -9,7 +10,7 @@ module Vedeu
|
|
9
10
|
module Presentation
|
10
11
|
|
11
12
|
include Vedeu::Presentation::Colour
|
12
|
-
include Vedeu::Presentation::
|
13
|
+
include Vedeu::Presentation::Styles
|
13
14
|
|
14
15
|
# Converts the colours and styles to escape sequences, and when the parent
|
15
16
|
# model has previously set the colour and style, reverts back to that for
|
@@ -2,34 +2,80 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Presentation
|
4
4
|
|
5
|
-
#
|
5
|
+
# Converts the style value or value collection into a terminal
|
6
|
+
# escape sequence. Unrecognised values are discarded- an empty
|
7
|
+
# string is returned.
|
6
8
|
#
|
7
|
-
|
9
|
+
# Vedeu has a range of symbol styles which are compatible with
|
10
|
+
# most terminals which are ANSI compatible. Like colours, they can
|
11
|
+
# be defined in either interfaces, for specific lines or within
|
12
|
+
# streams. Styles are applied as encountered.
|
13
|
+
#
|
14
|
+
# @see Vedeu::Esc
|
15
|
+
#
|
16
|
+
class Style
|
17
|
+
|
18
|
+
include Vedeu::Common
|
19
|
+
|
20
|
+
# @!attribute [rw] value
|
21
|
+
# @return [String|Symbol]
|
22
|
+
attr_accessor :value
|
8
23
|
|
9
|
-
#
|
10
|
-
#
|
24
|
+
# Produces new objects of the correct class from the value,
|
25
|
+
# ignores objects that have already been coerced.
|
11
26
|
#
|
12
|
-
# @
|
13
|
-
|
14
|
-
|
15
|
-
|
27
|
+
# @param value [Object|NilClass]
|
28
|
+
# @return [Object]
|
29
|
+
def self.coerce(value)
|
30
|
+
if value.is_a?(self)
|
31
|
+
value
|
16
32
|
|
17
|
-
|
18
|
-
|
33
|
+
else
|
34
|
+
new(value)
|
19
35
|
|
20
|
-
|
21
|
-
|
36
|
+
end
|
37
|
+
end
|
22
38
|
|
23
|
-
|
39
|
+
# Return a new instance of Vedeu::Presentation::Style.
|
40
|
+
#
|
41
|
+
# @param value [Array<String|Symbol>|String|Symbol]
|
42
|
+
# The style value or a collection of values.
|
43
|
+
# @return [Vedeu::Presentation::Style]
|
44
|
+
def initialize(value = nil)
|
45
|
+
@value = value
|
24
46
|
end
|
25
47
|
|
26
|
-
#
|
27
|
-
# Vedeu::Style.
|
48
|
+
# Return an attributes hash for this class.
|
28
49
|
#
|
29
|
-
# @return [
|
30
|
-
def
|
31
|
-
|
50
|
+
# @return [Hash<Symbol => Array<String|Symbol>|String|Symbol>]
|
51
|
+
def attributes
|
52
|
+
{
|
53
|
+
style: value,
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
# An object is equal when its values are the same.
|
58
|
+
#
|
59
|
+
# @param other [Vedeu::Views::Char]
|
60
|
+
# @return [Boolean]
|
61
|
+
def eql?(other)
|
62
|
+
self.class == other.class && value == other.value
|
63
|
+
end
|
64
|
+
alias_method :==, :eql?
|
65
|
+
|
66
|
+
# Return the terminal escape sequences after converting the
|
67
|
+
# style or styles.
|
68
|
+
#
|
69
|
+
# @return [String]
|
70
|
+
def to_s
|
71
|
+
return '' unless present?(value)
|
72
|
+
|
73
|
+
@sequences ||= Array(value).flatten.map do |v|
|
74
|
+
Vedeu::Esc.string(v)
|
75
|
+
end.join
|
32
76
|
end
|
77
|
+
alias_method :escape_sequences, :to_s
|
78
|
+
alias_method :to_str, :to_s
|
33
79
|
|
34
80
|
end # Style
|
35
81
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
module Presentation
|
4
|
+
|
5
|
+
# Provides style related presentation behaviour.
|
6
|
+
#
|
7
|
+
module Styles
|
8
|
+
|
9
|
+
# When the style for the model exists, return it, otherwise
|
10
|
+
# returns the parent style, or an empty
|
11
|
+
# {Vedeu::Presentation::Style}.
|
12
|
+
#
|
13
|
+
# @return [Vedeu::Presentation::Style]
|
14
|
+
def style
|
15
|
+
@style ||= if attributes[:style]
|
16
|
+
Vedeu::Presentation::Style.coerce(attributes[:style])
|
17
|
+
|
18
|
+
elsif parent
|
19
|
+
Vedeu::Presentation::Style.coerce(parent.style)
|
20
|
+
|
21
|
+
else
|
22
|
+
Vedeu::Presentation::Style.new
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Allows the setting of the style by coercing the given value
|
28
|
+
# into a {Vedeu::Presentation::Style}.
|
29
|
+
#
|
30
|
+
# @return [Vedeu::Presentation::Style]
|
31
|
+
def style=(value)
|
32
|
+
@style = Vedeu::Presentation::Style.coerce(value)
|
33
|
+
end
|
34
|
+
|
35
|
+
end # Style
|
36
|
+
|
37
|
+
end # Presentation
|
38
|
+
|
39
|
+
end # Vedeu
|
@@ -2,8 +2,8 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Renderers
|
4
4
|
|
5
|
-
# Renders a {Vedeu::VirtualBuffer} or
|
6
|
-
# snippet; a table by default.
|
5
|
+
# Renders a {Vedeu::Buffers::VirtualBuffer} or
|
6
|
+
# {Vedeu::Output::Output} as a HTML snippet; a table by default.
|
7
7
|
#
|
8
8
|
class HTML < Vedeu::Renderers::File
|
9
9
|
|
@@ -2,8 +2,8 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Renderers
|
4
4
|
|
5
|
-
# Converts a grid of {Vedeu::Views::Char} objects into a stream of
|
6
|
-
# sequences and content suitable for a terminal.
|
5
|
+
# Converts a grid of {Vedeu::Views::Char} objects into a stream of
|
6
|
+
# escape sequences and content suitable for a terminal.
|
7
7
|
#
|
8
8
|
class Terminal
|
9
9
|
|
@@ -31,7 +31,7 @@ module Vedeu
|
|
31
31
|
store!(output)
|
32
32
|
|
33
33
|
Vedeu.timer('Compression') do
|
34
|
-
Vedeu::Compressor.render(output)
|
34
|
+
Vedeu::Output::Compressor.render(output)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -2,8 +2,8 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Renderers
|
4
4
|
|
5
|
-
# Converts a grid of {Vedeu::Views::Char} objects into a stream of
|
6
|
-
# sequences and content.
|
5
|
+
# Converts a grid of {Vedeu::Views::Char} objects into a stream of
|
6
|
+
# escape sequences and content.
|
7
7
|
#
|
8
8
|
class Text
|
9
9
|
|
@@ -20,7 +20,7 @@ module Vedeu
|
|
20
20
|
# @param output [Array<Array<Vedeu::Views::Char>>]
|
21
21
|
# @return [String]
|
22
22
|
def render(output)
|
23
|
-
Vedeu::Compressor.render(output)
|
23
|
+
Vedeu::Output::Compressor.render(output)
|
24
24
|
end
|
25
25
|
|
26
26
|
end # Text
|
data/lib/vedeu/output/text.rb
CHANGED
@@ -1,216 +1,222 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
class Text
|
3
|
+
module Output
|
6
4
|
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
end
|
5
|
+
# Present a string (or object responding to `to_s`).
|
6
|
+
#
|
7
|
+
class Text
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
# @see Vedeu::DSL::Text#text
|
10
|
+
def self.add(value = '', options = {})
|
11
|
+
new(value, options).add
|
12
|
+
end
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
# @option options anchor [Symbol] See {Text#anchor}
|
22
|
-
# @option options background [String]
|
23
|
-
# @option options colour [Hash|NilClass]
|
24
|
-
# @option options foreground [String]
|
25
|
-
# @option options model
|
26
|
-
# [Vedeu::Views::View|Vedeu::Views::Line|Vedeu::Views::Stream]
|
27
|
-
# @option options pad [String]
|
28
|
-
# @option options width [Integer]
|
29
|
-
# @return [Vedeu::Text]
|
30
|
-
def initialize(value = '', options = {})
|
31
|
-
@value = value
|
32
|
-
@options = defaults.merge!(options)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Aligns the value.
|
36
|
-
#
|
37
|
-
# @return [String]
|
38
|
-
def aligned
|
39
|
-
return string unless width
|
14
|
+
# @see Vedeu::DSL::Text#text
|
15
|
+
def self.with(value = '', options = {})
|
16
|
+
new(value, options).aligned
|
17
|
+
end
|
40
18
|
|
41
|
-
|
19
|
+
# Returns a new instance of Vedeu::Output::Text.
|
20
|
+
#
|
21
|
+
# @param value [String]
|
22
|
+
# @param options [Hash]
|
23
|
+
# @option options anchor [Symbol] See {Text#anchor}
|
24
|
+
# @option options background [String]
|
25
|
+
# @option options colour [Hash|NilClass]
|
26
|
+
# @option options foreground [String]
|
27
|
+
# @option options model
|
28
|
+
# [Vedeu::Views::View|Vedeu::Views::Line|Vedeu::Views::Stream]
|
29
|
+
# @option options pad [String]
|
30
|
+
# @option options width [Integer]
|
31
|
+
# @return [Vedeu::Output::Text]
|
32
|
+
def initialize(value = '', options = {})
|
33
|
+
@value = value
|
34
|
+
@options = defaults.merge!(options)
|
35
|
+
end
|
42
36
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
37
|
+
# Aligns the value.
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
def aligned
|
41
|
+
return string unless width
|
42
|
+
|
43
|
+
return truncated if truncate?
|
44
|
+
|
45
|
+
case anchor
|
46
|
+
when :align, :left, :text then left
|
47
|
+
when :centre, :center then centre
|
48
|
+
when :right then right
|
49
|
+
else
|
50
|
+
left
|
51
|
+
end
|
49
52
|
end
|
50
|
-
end
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
# Adds the content to the model.
|
55
|
+
#
|
56
|
+
# @return [void]
|
57
|
+
def add
|
58
|
+
model.add(content)
|
59
|
+
end
|
58
60
|
|
59
|
-
|
61
|
+
protected
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
# @!attribute [r] value
|
64
|
+
# @return [String]
|
65
|
+
attr_reader :value
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
|
67
|
+
# @!attribute [r] options
|
68
|
+
# @return [Hash]
|
69
|
+
attr_reader :options
|
68
70
|
|
69
|
-
|
71
|
+
private
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
# @return [Symbol] One of :align, :centre, :center, :left,
|
74
|
+
# :right, :text
|
75
|
+
def anchor
|
76
|
+
options[:anchor]
|
77
|
+
end
|
75
78
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
# The string padded to width, centralized.
|
80
|
+
#
|
81
|
+
# @return [String]
|
82
|
+
def centre
|
83
|
+
string.center(width, pad)
|
84
|
+
end
|
82
85
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
# If a colour, background or foreground option is set, use them
|
87
|
+
# as the colour settings for the new Vedeu::Views::Stream.
|
88
|
+
#
|
89
|
+
# @return [void]
|
90
|
+
def colour
|
91
|
+
if options[:colour] || options[:background] || options[:foreground]
|
92
|
+
Vedeu::Colours::Colour.coerce(options)
|
90
93
|
|
91
|
-
|
92
|
-
|
94
|
+
else
|
95
|
+
model.colour
|
93
96
|
|
97
|
+
end
|
94
98
|
end
|
95
|
-
end
|
96
99
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
100
|
+
# Returns either a Vedeu::Views::Line or Vedeu::Views::Stream
|
101
|
+
# containing the text value.
|
102
|
+
#
|
103
|
+
# @return [Vedeu::Views::Line|Vedeu::Views::Stream]
|
104
|
+
def content
|
105
|
+
if model.is_a?(Vedeu::Views::View)
|
106
|
+
stream.parent = line
|
107
|
+
line.add(stream)
|
108
|
+
line
|
106
109
|
|
107
|
-
|
108
|
-
|
110
|
+
else
|
111
|
+
stream
|
109
112
|
|
113
|
+
end
|
110
114
|
end
|
111
|
-
end
|
112
115
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
# The string padded to width, left justified.
|
127
|
-
#
|
128
|
-
# @return [String]
|
129
|
-
def left
|
130
|
-
string.ljust(width, pad)
|
131
|
-
end
|
116
|
+
# The default values for a new instance of this class.
|
117
|
+
#
|
118
|
+
# @return [Hash<Symbol => NilClass, String, Symbol>]
|
119
|
+
def defaults
|
120
|
+
{
|
121
|
+
anchor: :left,
|
122
|
+
colour: nil,
|
123
|
+
model: nil,
|
124
|
+
pad: ' ',
|
125
|
+
width: nil,
|
126
|
+
}
|
127
|
+
end
|
132
128
|
|
133
|
-
|
134
|
-
|
135
|
-
@
|
136
|
-
|
129
|
+
# The string padded to width, left justified.
|
130
|
+
#
|
131
|
+
# @return [String]
|
132
|
+
def left
|
133
|
+
string.ljust(width, pad)
|
134
|
+
end
|
137
135
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
# Vedeu::Null::Generic|
|
143
|
-
# Vedeu::Views::Stream]
|
144
|
-
def model
|
145
|
-
@model ||= options[:model] || Vedeu::Null::Generic.new
|
146
|
-
end
|
147
|
-
|
148
|
-
# The character to use for padding the string.
|
149
|
-
#
|
150
|
-
# @return [String]
|
151
|
-
def pad
|
152
|
-
options[:pad]
|
153
|
-
end
|
136
|
+
# @return [Vedeu::Views::Line]
|
137
|
+
def line
|
138
|
+
@line ||= Vedeu::Views::Line.build(parent: parent)
|
139
|
+
end
|
154
140
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
141
|
+
# Returns the model option when set.
|
142
|
+
#
|
143
|
+
# @return [Vedeu::Views::View|
|
144
|
+
# Vedeu::Views::Line|
|
145
|
+
# Vedeu::Null::Generic|
|
146
|
+
# Vedeu::Views::Stream]
|
147
|
+
def model
|
148
|
+
@model ||= options[:model] || Vedeu::Null::Generic.new
|
149
|
+
end
|
161
150
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
151
|
+
# The character to use for padding the string.
|
152
|
+
#
|
153
|
+
# @return [String]
|
154
|
+
def pad
|
155
|
+
options[:pad]
|
156
|
+
end
|
168
157
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
style: style,
|
176
|
-
value: aligned)
|
177
|
-
end
|
178
|
-
|
179
|
-
# The string, coerced.
|
180
|
-
#
|
181
|
-
# @return [String]
|
182
|
-
def string
|
183
|
-
value.to_s
|
184
|
-
end
|
158
|
+
# Returns the parent for the new Vedeu::Views::Stream.
|
159
|
+
#
|
160
|
+
# @return [void]
|
161
|
+
def parent
|
162
|
+
model.is_a?(Vedeu::Views::Stream) ? model.parent : model
|
163
|
+
end
|
185
164
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
165
|
+
# The string padded to width, right justified.
|
166
|
+
#
|
167
|
+
# @return [String]
|
168
|
+
def right
|
169
|
+
string.rjust(width, pad)
|
170
|
+
end
|
192
171
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
172
|
+
# Builds and returns a new Vedeu::Views::Stream.
|
173
|
+
#
|
174
|
+
# @return [void]
|
175
|
+
def stream
|
176
|
+
@stream ||= Vedeu::Views::Stream.build(colour: colour,
|
177
|
+
parent: parent,
|
178
|
+
style: style,
|
179
|
+
value: aligned)
|
180
|
+
end
|
199
181
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
182
|
+
# The string, coerced.
|
183
|
+
#
|
184
|
+
# @return [String]
|
185
|
+
def string
|
186
|
+
value.to_s
|
187
|
+
end
|
206
188
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
189
|
+
# Returns the model's styles.
|
190
|
+
#
|
191
|
+
# @return [void]
|
192
|
+
def style
|
193
|
+
model.style
|
194
|
+
end
|
195
|
+
|
196
|
+
# Return a boolean indicating that the string is greater than
|
197
|
+
# the width.
|
198
|
+
#
|
199
|
+
# @return [Boolean]
|
200
|
+
def truncate?
|
201
|
+
string.size > width
|
202
|
+
end
|
203
|
+
|
204
|
+
# Return the string truncated to the width.
|
205
|
+
#
|
206
|
+
# @return [String]
|
207
|
+
def truncated
|
208
|
+
string.slice(0, width)
|
209
|
+
end
|
210
|
+
|
211
|
+
# Return the width.
|
212
|
+
#
|
213
|
+
# @return [Fixnum]
|
214
|
+
def width
|
215
|
+
options[:width]
|
216
|
+
end
|
217
|
+
|
218
|
+
end # Text
|
213
219
|
|
214
|
-
end #
|
220
|
+
end # Output
|
215
221
|
|
216
222
|
end # Vedeu
|