vedeu 0.6.10 → 0.6.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/all.rb +17 -103
- data/lib/vedeu/api/all.rb +15 -0
- data/lib/vedeu/api/internal.rb +4 -0
- data/lib/vedeu/application/all.rb +6 -0
- data/lib/vedeu/bindings/all.rb +32 -0
- data/lib/vedeu/bindings/bindings.rb +0 -14
- data/lib/vedeu/bindings/refresh.rb +8 -2
- data/lib/vedeu/bindings/system.rb +1 -0
- data/lib/vedeu/borders/border.rb +1 -1
- data/lib/vedeu/borders/repository.rb +1 -1
- data/lib/vedeu/buffers/buffer.rb +2 -4
- data/lib/vedeu/buffers/repository.rb +1 -1
- data/lib/vedeu/colours/background.rb +1 -1
- data/lib/vedeu/colours/backgrounds.rb +1 -1
- data/lib/vedeu/colours/foreground.rb +1 -1
- data/lib/vedeu/colours/foregrounds.rb +1 -1
- data/lib/vedeu/colours/translator.rb +4 -3
- data/lib/vedeu/configuration/api.rb +2 -1
- data/lib/vedeu/configuration/cli.rb +1 -1
- data/lib/vedeu/cursors/cursor.rb +26 -26
- data/lib/vedeu/cursors/repository.rb +1 -1
- data/lib/vedeu/distributed/all.rb +16 -0
- data/lib/vedeu/distributed/test_application.rb +3 -3
- data/lib/vedeu/dsl/all.rb +22 -0
- data/lib/vedeu/dsl/composition.rb +43 -40
- data/lib/vedeu/dsl/dsl.rb +6 -3
- data/lib/vedeu/dsl/group.rb +23 -16
- data/lib/vedeu/dsl/interface.rb +48 -38
- data/lib/vedeu/dsl/keymap.rb +6 -7
- data/lib/vedeu/dsl/line.rb +6 -3
- data/lib/vedeu/dsl/stream.rb +2 -1
- data/lib/vedeu/editor/cursor.rb +1 -3
- data/lib/vedeu/editor/document.rb +4 -5
- data/lib/vedeu/editor/documents.rb +1 -1
- data/lib/vedeu/editor/line.rb +2 -3
- data/lib/vedeu/editor/lines.rb +2 -3
- data/lib/vedeu/esc/all.rb +14 -0
- data/lib/vedeu/esc/colours.rb +8 -4
- data/lib/vedeu/esc/esc.rb +89 -84
- data/lib/vedeu/events/aliases.rb +1 -2
- data/lib/vedeu/events/collection.rb +1 -1
- data/lib/vedeu/events/event.rb +1 -1
- data/lib/vedeu/events/repository.rb +1 -1
- data/lib/vedeu/events/trigger.rb +11 -9
- data/lib/vedeu/geometry/dimension.rb +1 -3
- data/lib/vedeu/geometry/generic_coordinate.rb +1 -3
- data/lib/vedeu/geometry/geometry.rb +1 -1
- data/lib/vedeu/geometry/repository.rb +3 -3
- data/lib/vedeu/input/all.rb +3 -0
- data/lib/vedeu/input/keymap.rb +10 -11
- data/lib/vedeu/input/keymaps.rb +1 -1
- data/lib/vedeu/input/keys.rb +1 -1
- data/lib/vedeu/input/mapper.rb +14 -12
- data/lib/vedeu/logging/all.rb +3 -0
- data/lib/vedeu/logging/log.rb +4 -2
- data/lib/vedeu/menus/menu.rb +2 -4
- data/lib/vedeu/menus/repository.rb +1 -1
- data/lib/vedeu/models/all.rb +15 -0
- data/lib/vedeu/models/cell.rb +1 -1
- data/lib/vedeu/models/escape.rb +1 -1
- data/lib/vedeu/models/group.rb +4 -3
- data/lib/vedeu/models/groups.rb +1 -1
- data/lib/vedeu/models/interface.rb +1 -1
- data/lib/vedeu/models/interfaces.rb +1 -1
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/collections/chars.rb +1 -1
- data/lib/vedeu/models/views/collections/lines.rb +1 -1
- data/lib/vedeu/models/views/collections/streams.rb +1 -1
- data/lib/vedeu/models/views/collections/view_collection.rb +1 -1
- data/lib/vedeu/models/views/composition.rb +1 -1
- data/lib/vedeu/models/views/line.rb +8 -6
- data/lib/vedeu/models/views/stream.rb +1 -1
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/null/all.rb +12 -0
- data/lib/vedeu/output/clear/named_group.rb +2 -1
- data/lib/vedeu/output/clear/named_interface.rb +5 -4
- data/lib/vedeu/output/compressor.rb +1 -0
- data/lib/vedeu/output/output.rb +3 -0
- data/lib/vedeu/output/presentation/colour.rb +10 -10
- data/lib/vedeu/output/presentation/presentation.rb +9 -9
- data/lib/vedeu/output/presentation/style.rb +2 -2
- data/lib/vedeu/output/refresh/refresh.rb +35 -0
- data/lib/vedeu/output/refresh/refresh_group.rb +66 -0
- data/lib/vedeu/output/renderers/all.rb +17 -0
- data/lib/vedeu/output/renderers/escape_sequence.rb +4 -2
- data/lib/vedeu/output/renderers/file.rb +7 -6
- data/lib/vedeu/output/renderers/html.rb +9 -7
- data/lib/vedeu/output/renderers/null.rb +1 -1
- data/lib/vedeu/output/renderers/renderer_options.rb +24 -20
- data/lib/vedeu/output/renderers/terminal.rb +1 -1
- data/lib/vedeu/output/renderers/text.rb +1 -1
- data/lib/vedeu/output/wordwrap.rb +7 -4
- data/lib/vedeu/plugins/all.rb +2 -0
- data/lib/vedeu/repositories/all.rb +16 -0
- data/lib/vedeu/repositories/collection.rb +93 -89
- data/lib/vedeu/repositories/model.rb +113 -102
- data/lib/vedeu/repositories/registerable.rb +60 -56
- data/lib/vedeu/repositories/repository.rb +161 -156
- data/lib/vedeu/repositories/store.rb +70 -66
- data/lib/vedeu/runtime/all.rb +15 -0
- data/lib/vedeu/runtime/launcher.rb +19 -16
- data/lib/vedeu/templating/all.rb +6 -0
- data/lib/vedeu/terminal/all.rb +14 -0
- data/lib/vedeu/terminal/buffer.rb +8 -7
- data/lib/vedeu/terminal/mode.rb +11 -10
- data/lib/vedeu/terminal/terminal.rb +50 -45
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/cursors/cursor_test.rb +4 -2
- data/test/lib/vedeu/editor/cursor_test.rb +0 -3
- data/test/lib/vedeu/esc/esc_test.rb +58 -54
- data/test/lib/vedeu/events/collection_test.rb +1 -1
- data/test/lib/vedeu/input/keys_test.rb +1 -1
- data/test/lib/vedeu/input/mapper_test.rb +1 -1
- data/test/lib/vedeu/models/views/collections/chars_test.rb +1 -1
- data/test/lib/vedeu/models/views/collections/lines_test.rb +1 -1
- data/test/lib/vedeu/models/views/collections/streams_test.rb +1 -1
- data/test/lib/vedeu/models/views/collections/view_collection_test.rb +1 -1
- data/test/lib/vedeu/output/refresh/refresh_group_test.rb +43 -0
- data/test/lib/vedeu/output/refresh/refresh_test.rb +50 -0
- data/test/lib/vedeu/output/renderers/renderer_options_test.rb +8 -4
- data/test/lib/vedeu/output/renderers_test.rb +2 -1
- data/test/lib/vedeu/repositories/collection_test.rb +105 -101
- data/test/lib/vedeu/repositories/model_test.rb +56 -52
- data/test/lib/vedeu/repositories/registerable_test.rb +36 -32
- data/test/lib/vedeu/repositories/repository_test.rb +178 -174
- data/test/lib/vedeu/repositories/store_test.rb +109 -105
- data/test/support/examples/material_colours_app.rb +0 -1
- data/test/support/helpers/model_test_class.rb +50 -46
- data/test/test_helper.rb +2 -2
- metadata +21 -9
- data/lib/vedeu/refresh/refresh.rb +0 -31
- data/lib/vedeu/refresh/refresh_group.rb +0 -59
- data/out_ +0 -50
- data/test/lib/vedeu/refresh/refresh_group_test.rb +0 -39
- data/test/lib/vedeu/refresh/refresh_test.rb +0 -46
@@ -4,36 +4,38 @@ module Vedeu
|
|
4
4
|
|
5
5
|
# DSL for creating collections of interfaces.
|
6
6
|
#
|
7
|
-
# Views with Vedeu are made up of simple building blocks. These
|
8
|
-
# be arranged in a multitude of ways which I hope is
|
9
|
-
# for your design needs.
|
7
|
+
# Views with Vedeu are made up of simple building blocks. These
|
8
|
+
# blocks can be arranged in a multitude of ways which I hope is
|
9
|
+
# more than sufficient for your design needs.
|
10
10
|
|
11
11
|
# - A view (`Composition`) is made up of one or more interfaces.
|
12
|
-
# - An interface is an area on the screen where you can take input
|
13
|
-
# output. You will define it's colour and style, its
|
14
|
-
# position and give it a name. You can
|
15
|
-
# command, or event, to this
|
16
|
-
# is placed there.
|
17
|
-
# - Interfaces (`Interface`) are made up of lines (`Line`), their
|
18
|
-
# being the width of the interface and their number being
|
19
|
-
# the interface.
|
20
|
-
# - An interface with `width: 12, height: 5` will have five lines,
|
21
|
-
# of 12 characters- providing 60 cells. Colours and
|
22
|
-
# terminal escape sequences and therefore
|
23
|
-
#
|
12
|
+
# - An interface is an area on the screen where you can take input
|
13
|
+
# or direct output. You will define it's colour and style, its
|
14
|
+
# dimensions, including position and give it a name. You can
|
15
|
+
# then direct the output of a command, or event, to this
|
16
|
+
# interface and Vedeu will ensure the content is placed there.
|
17
|
+
# - Interfaces (`Interface`) are made up of lines (`Line`), their
|
18
|
+
# length being the width of the interface and their number being
|
19
|
+
# the height of the interface.
|
20
|
+
# - An interface with `width: 12, height: 5` will have five lines,
|
21
|
+
# each made of 12 characters- providing 60 cells. Colours and
|
22
|
+
# styles are handled by terminal escape sequences and therefore
|
23
|
+
# do not consume a cell.
|
24
|
+
# - Lines are made up of zero, one or multiple streams which are
|
24
25
|
# basically subsets of the line.
|
25
|
-
# - An interface, line or stream can have a colour
|
26
|
-
# - An interface, line or stream can have a style
|
27
|
-
# - Interfaces have a position (`y`, `x`) on the screen, and a
|
28
|
-
# (`width`, `height`)
|
26
|
+
# - An interface, line or stream can have a colour attribute.
|
27
|
+
# - An interface, line or stream can have a style attribute.
|
28
|
+
# - Interfaces have a position (`y`, `x`) on the screen, and a
|
29
|
+
# size. (`width`, `height`)
|
29
30
|
# - Interfaces can be placed relative to each other based on their
|
30
31
|
# attributes.
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# - Colours are defined in CSS-style values, i.e. `#ff0000` would
|
32
|
+
# - An interface has a `top`, `right`, `bottom`, `left`.
|
33
|
+
# - An interface also has a `north` and `west` (`top` and `left`
|
34
|
+
# minus 1 respectively).
|
35
|
+
# - An interface also has a `south` and `east` (`bottom` and
|
36
|
+
# `right` plus 1 respectively).
|
37
|
+
# - Colours are defined in CSS-style values, i.e. `#ff0000` would
|
38
|
+
# be red.
|
37
39
|
# - Styles are named. See the table below for supported styles.
|
38
40
|
#
|
39
41
|
class Composition
|
@@ -54,14 +56,15 @@ module Vedeu
|
|
54
56
|
#
|
55
57
|
# A view is just an Interface object.
|
56
58
|
#
|
57
|
-
# When a view already exists, we take its attributes and use
|
58
|
-
# basis for the newly defined view. This way we
|
59
|
-
# everything again.
|
59
|
+
# When a view already exists, we take its attributes and use
|
60
|
+
# them as the basis for the newly defined view. This way we
|
61
|
+
# don't need to specify everything again.
|
60
62
|
#
|
61
63
|
# @todo More documentation required.
|
62
|
-
# @param name [String] The name of the interface you are
|
63
|
-
# this view.
|
64
|
-
# @param block [Proc] The directives you wish to send to this
|
64
|
+
# @param name [String] The name of the interface you are
|
65
|
+
# targetting for this view.
|
66
|
+
# @param block [Proc] The directives you wish to send to this
|
67
|
+
# interface.
|
65
68
|
#
|
66
69
|
# @example
|
67
70
|
# view 'my_interface' do
|
@@ -90,13 +93,13 @@ module Vedeu
|
|
90
93
|
#
|
91
94
|
# @todo More documentation required.
|
92
95
|
#
|
93
|
-
# @param name [String] The name of interface for which this
|
94
|
-
# content belongs to.
|
95
|
-
# @param filename [String] The filename (including path) to the
|
96
|
-
# to be used. Yoy can use `File.dirname(__FILE__)` to
|
97
|
-
# paths.
|
98
|
-
# @param object [Object] The object for which the values of
|
99
|
-
# variables can be obtained.
|
96
|
+
# @param name [String] The name of interface for which this
|
97
|
+
# template's content belongs to.
|
98
|
+
# @param filename [String] The filename (including path) to the
|
99
|
+
# template to be used. Yoy can use `File.dirname(__FILE__)` to
|
100
|
+
# use relative paths.
|
101
|
+
# @param object [Object] The object for which the values of
|
102
|
+
# template's variables can be obtained.
|
100
103
|
# @param options [Hash] See {Vedeu::Output::Wordwrap}
|
101
104
|
# @raise [Vedeu::Error::MissingRequired]
|
102
105
|
# @return [Vedeu::Views::Views<Vedeu::Views::View>]
|
@@ -128,8 +131,8 @@ module Vedeu
|
|
128
131
|
new_attributes(name).merge!(value: lines)
|
129
132
|
end
|
130
133
|
|
131
|
-
# Return the current attributes combined with the existing
|
132
|
-
# attributes defined by the interface.
|
134
|
+
# Return the current attributes combined with the existing
|
135
|
+
# interface attributes defined by the interface.
|
133
136
|
#
|
134
137
|
# @param name [String] The name of the interface.
|
135
138
|
# @return [Hash]
|
data/lib/vedeu/dsl/dsl.rb
CHANGED
@@ -7,11 +7,13 @@ module Vedeu
|
|
7
7
|
protected
|
8
8
|
|
9
9
|
# @!attribute [r] client
|
10
|
-
# @return [Object] The object instance where the DSL is being
|
10
|
+
# @return [Object] The object instance where the DSL is being
|
11
|
+
# used.
|
11
12
|
attr_reader :client
|
12
13
|
|
13
14
|
# @!attribute [r] model
|
14
|
-
# @return [void] The new model object which the DSL is
|
15
|
+
# @return [void] The new model object which the DSL is
|
16
|
+
# constructing.
|
15
17
|
attr_reader :model
|
16
18
|
|
17
19
|
private
|
@@ -33,7 +35,8 @@ module Vedeu
|
|
33
35
|
# Attempts to find the missing method on the client object.
|
34
36
|
#
|
35
37
|
# @param method [Symbol] The name of the method sought.
|
36
|
-
# @param args [Array] The arguments which the method was to be
|
38
|
+
# @param args [Array] The arguments which the method was to be
|
39
|
+
# invoked with.
|
37
40
|
# @param block [Proc] The optional block provided to the method.
|
38
41
|
# @return [void]
|
39
42
|
def method_missing(method, *args, &block)
|
data/lib/vedeu/dsl/group.rb
CHANGED
@@ -2,25 +2,27 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module DSL
|
4
4
|
|
5
|
-
# Interfaces can be configured to be part of a named group. Once
|
6
|
-
# interface is a member of group, the group can be affected by
|
7
|
-
# controls. For example, assuming the client application is
|
8
|
-
# client, it may have a group called 'commit'. The
|
9
|
-
# contain the interfaces 'diff' (to show the
|
10
|
-
# which files are staged) and
|
11
|
-
#
|
12
|
-
#
|
13
|
-
# of
|
5
|
+
# Interfaces can be configured to be part of a named group. Once
|
6
|
+
# an interface is a member of group, the group can be affected by
|
7
|
+
# other controls. For example, assuming the client application is
|
8
|
+
# a simple Git client, it may have a group called 'commit'. The
|
9
|
+
# 'commit' group will contain the interfaces 'diff' (to show the
|
10
|
+
# changes), 'staged' (to show which files are staged) and
|
11
|
+
# 'unstaged'. A refresh of the 'commit' group would cause all
|
12
|
+
# interfaces belonging to the group to refresh. Similarly,
|
13
|
+
# showing or hiding the group would of course, show or hide the
|
14
|
+
# interfaces of that group.
|
14
15
|
#
|
15
16
|
class Group
|
16
17
|
|
17
18
|
include Vedeu::DSL
|
18
19
|
|
19
|
-
# Specify a new group of interfaces with a simple DSL. Creating
|
20
|
-
# with the same name as an existing group overwrites the
|
20
|
+
# Specify a new group of interfaces with a simple DSL. Creating
|
21
|
+
# a group with the same name as an existing group overwrites the
|
22
|
+
# existing group.
|
21
23
|
#
|
22
|
-
# The example below resembles 'vim' (the popular terminal-based
|
23
|
-
# editor):
|
24
|
+
# The example below resembles 'vim' (the popular terminal-based
|
25
|
+
# text editor):
|
24
26
|
#
|
25
27
|
# Vedeu.group 'title_screen' do
|
26
28
|
# add 'welcome_interface'
|
@@ -37,7 +39,9 @@ module Vedeu
|
|
37
39
|
# or more succinctly:
|
38
40
|
#
|
39
41
|
# Vedeu.group 'main_screen' do
|
40
|
-
# members 'editor_interface',
|
42
|
+
# members 'editor_interface',
|
43
|
+
# 'status_interface',
|
44
|
+
# 'command_interface'
|
41
45
|
# # ... some code
|
42
46
|
# end
|
43
47
|
#
|
@@ -50,7 +54,8 @@ module Vedeu
|
|
50
54
|
#
|
51
55
|
# @param name [String] The name of this group.
|
52
56
|
# @param block [Proc]
|
53
|
-
# @raise [Vedeu::Error::InvalidSyntax] The required block was
|
57
|
+
# @raise [Vedeu::Error::InvalidSyntax] The required block was
|
58
|
+
# not given.
|
54
59
|
# @return [Vedeu::Models::Group]
|
55
60
|
def self.group(name, &block)
|
56
61
|
fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?
|
@@ -83,7 +88,9 @@ module Vedeu
|
|
83
88
|
# Add the named interfaces to this group in bulk.
|
84
89
|
#
|
85
90
|
# Vedeu.group 'main_screen' do
|
86
|
-
# members ['editor_interface',
|
91
|
+
# members ['editor_interface',
|
92
|
+
# 'some_interface',
|
93
|
+
# 'other_interface']
|
87
94
|
# end
|
88
95
|
#
|
89
96
|
# @param interface_names [Array<String>]
|
data/lib/vedeu/dsl/interface.rb
CHANGED
@@ -17,19 +17,22 @@ module Vedeu
|
|
17
17
|
|
18
18
|
include Vedeu::Common
|
19
19
|
|
20
|
-
# Register an interface by name which will display output from
|
21
|
-
# or command. This provides the means for you to
|
22
|
-
# of your application without their
|
20
|
+
# Register an interface by name which will display output from
|
21
|
+
# an event or a command. This provides the means for you to
|
22
|
+
# define your the views of your application without their
|
23
|
+
# content.
|
23
24
|
#
|
24
25
|
# Vedeu.interface 'my_interface' do
|
25
26
|
# # ... some code
|
26
27
|
# end
|
27
28
|
#
|
28
|
-
# @param name [String] The name of the interface. Used to
|
29
|
-
# interface throughout your application's
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
29
|
+
# @param name [String] The name of the interface. Used to
|
30
|
+
# reference the interface throughout your application's
|
31
|
+
# execution lifetime.
|
32
|
+
# @param block [Proc] A set of attributes which define the
|
33
|
+
# features of the interface.
|
34
|
+
# @raise [Vedeu::Error::InvalidSyntax] The required block was
|
35
|
+
# not given.
|
33
36
|
# @return [Vedeu::Models::Interface]
|
34
37
|
# @todo More documentation required.
|
35
38
|
def interface(name, &block)
|
@@ -50,8 +53,8 @@ module Vedeu
|
|
50
53
|
private
|
51
54
|
|
52
55
|
# Registers a set of buffers for the interface unless already
|
53
|
-
# registered, and also adds interface's name to list of
|
54
|
-
# interfaces.
|
56
|
+
# registered, and also adds interface's name to list of
|
57
|
+
# focussable interfaces.
|
55
58
|
#
|
56
59
|
# @see Vedeu::Buffers::Buffer
|
57
60
|
# @return [Vedeu::Buffers::Buffer]
|
@@ -59,14 +62,16 @@ module Vedeu
|
|
59
62
|
Vedeu::Buffers::Buffer.new(name: name).store
|
60
63
|
end
|
61
64
|
|
62
|
-
# Registers a new cursor for the interface unless already
|
65
|
+
# Registers a new cursor for the interface unless already
|
66
|
+
# registered.
|
63
67
|
#
|
64
68
|
# @return [Vedeu::Cursors::Cursor]
|
65
69
|
def add_cursor!(name)
|
66
70
|
Vedeu::Cursors::Cursor.new(name: name).store
|
67
71
|
end
|
68
72
|
|
69
|
-
# Registers interface name in focus list unless already
|
73
|
+
# Registers interface name in focus list unless already
|
74
|
+
# registered.
|
70
75
|
#
|
71
76
|
# @return [void]
|
72
77
|
def add_focusable!(name)
|
@@ -95,14 +100,16 @@ module Vedeu
|
|
95
100
|
|
96
101
|
# Set the cursor visibility on an interface.
|
97
102
|
#
|
98
|
-
# @param value [Boolean] Any value other than nil or false will
|
103
|
+
# @param value [Boolean] Any value other than nil or false will
|
104
|
+
# evaluate
|
99
105
|
# to true.
|
100
106
|
#
|
101
107
|
# @example
|
102
108
|
# Vedeu.interface 'my_interface' do
|
103
109
|
# cursor true # => show the cursor for this interface
|
104
110
|
# # or...
|
105
|
-
# cursor :show # => both of these are equivalent to line
|
111
|
+
# cursor :show # => both of these are equivalent to line
|
112
|
+
# # above
|
106
113
|
# # or...
|
107
114
|
# cursor! #
|
108
115
|
# # ...
|
@@ -116,8 +123,9 @@ module Vedeu
|
|
116
123
|
# end
|
117
124
|
#
|
118
125
|
# Vedeu.view 'my_interface' do
|
119
|
-
# cursor true # => Specify the visibility of the cursor when
|
120
|
-
#
|
126
|
+
# cursor true # => Specify the visibility of the cursor when
|
127
|
+
# # the view is rendered.
|
128
|
+
# # ...
|
121
129
|
# end
|
122
130
|
#
|
123
131
|
# @return [Vedeu::Cursors::Cursor]
|
@@ -134,15 +142,16 @@ module Vedeu
|
|
134
142
|
cursor(true)
|
135
143
|
end
|
136
144
|
|
137
|
-
# To maintain performance interfaces can be delayed from
|
138
|
-
# often, the reduces artefacts particularly when
|
139
|
-
# screen.
|
145
|
+
# To maintain performance interfaces can be delayed from
|
146
|
+
# refreshing too often, the reduces artefacts particularly when
|
147
|
+
# resizing the terminal screen.
|
140
148
|
#
|
141
149
|
# @param value [Fixnum|Float] Time in seconds. (0.5 = 500ms).
|
142
150
|
#
|
143
151
|
# @example
|
144
152
|
# Vedeu.interface 'my_interface' do
|
145
|
-
# delay 0.5 # interface will not update more often than
|
153
|
+
# delay 0.5 # interface will not update more often than
|
154
|
+
# # every 500ms.
|
146
155
|
# # ...
|
147
156
|
# end
|
148
157
|
#
|
@@ -151,11 +160,12 @@ module Vedeu
|
|
151
160
|
model.delay = value
|
152
161
|
end
|
153
162
|
|
154
|
-
# Specify this interface as being in focus when the application
|
163
|
+
# Specify this interface as being in focus when the application
|
164
|
+
# starts.
|
155
165
|
#
|
156
|
-
# @note If multiple interfaces are defined, and this is included
|
157
|
-
# then the last defined will be the interface in
|
158
|
-
# behaviour can be overridden:
|
166
|
+
# @note If multiple interfaces are defined, and this is included
|
167
|
+
# in each, then the last defined will be the interface in
|
168
|
+
# focus. However, this behaviour can be overridden:
|
159
169
|
#
|
160
170
|
# ```ruby
|
161
171
|
# Vedeu.focus_by_name 'some_interface'
|
@@ -169,9 +179,9 @@ module Vedeu
|
|
169
179
|
Vedeu::Models::Focus.add(model.name, true) if present?(model.name)
|
170
180
|
end
|
171
181
|
|
172
|
-
# Specify a group for an interface. Interfaces of the same group
|
173
|
-
# targetted together; for example you may want to refresh
|
174
|
-
# interfaces at once.
|
182
|
+
# Specify a group for an interface. Interfaces of the same group
|
183
|
+
# can be targetted together; for example you may want to refresh
|
184
|
+
# multiple interfaces at once.
|
175
185
|
#
|
176
186
|
# @example
|
177
187
|
# Vedeu.interface 'my_interface' do
|
@@ -179,8 +189,8 @@ module Vedeu
|
|
179
189
|
# # ...
|
180
190
|
# end
|
181
191
|
#
|
182
|
-
# @param name [String] The name of the group to which this
|
183
|
-
# should belong.
|
192
|
+
# @param name [String] The name of the group to which this
|
193
|
+
# interface should belong.
|
184
194
|
# @return [Vedeu::Models::Group]
|
185
195
|
def group(name)
|
186
196
|
return false unless present?(name)
|
@@ -196,8 +206,8 @@ module Vedeu
|
|
196
206
|
end
|
197
207
|
alias_method :keys, :keymap
|
198
208
|
|
199
|
-
# The name of the interface. Used to reference the interface
|
200
|
-
# your application's execution lifetime.
|
209
|
+
# The name of the interface. Used to reference the interface
|
210
|
+
# throughout your application's execution lifetime.
|
201
211
|
#
|
202
212
|
# @param value [String]
|
203
213
|
#
|
@@ -247,8 +257,8 @@ module Vedeu
|
|
247
257
|
|
248
258
|
# Use a value from another model.
|
249
259
|
#
|
250
|
-
# @param name [String] The name of the interface model you wish
|
251
|
-
# value from.
|
260
|
+
# @param name [String] The name of the interface model you wish
|
261
|
+
# to use a value from.
|
252
262
|
# @return [Vedeu::Models::Interface]
|
253
263
|
def use(name)
|
254
264
|
model.repository.by_name(name)
|
@@ -256,8 +266,8 @@ module Vedeu
|
|
256
266
|
|
257
267
|
# Set the visibility of the interface.
|
258
268
|
#
|
259
|
-
# @param value [Boolean] Any value other than nil or false will
|
260
|
-
# to true.
|
269
|
+
# @param value [Boolean] Any value other than nil or false will
|
270
|
+
# evaluate to true.
|
261
271
|
#
|
262
272
|
# @example
|
263
273
|
# Vedeu.interface 'my_interface' do
|
@@ -286,9 +296,9 @@ module Vedeu
|
|
286
296
|
model.visible = boolean
|
287
297
|
end
|
288
298
|
|
289
|
-
# Set the zindex of the interface. This controls the render
|
290
|
-
# interfaces. Interfaces with a lower zindex will
|
291
|
-
# with a higher zindex.
|
299
|
+
# Set the zindex of the interface. This controls the render
|
300
|
+
# order of interfaces. Interfaces with a lower zindex will
|
301
|
+
# render before those with a higher zindex.
|
292
302
|
#
|
293
303
|
# @example
|
294
304
|
# --4-- # rendered last
|
data/lib/vedeu/dsl/keymap.rb
CHANGED
@@ -69,25 +69,24 @@ module Vedeu
|
|
69
69
|
|
70
70
|
# Define keypress(es) to perform an action.
|
71
71
|
#
|
72
|
-
# @param
|
72
|
+
# @param values [Array<String>|Array<Symbol>|String|Symbol]
|
73
73
|
# The key(s) pressed. Special keys can be found in
|
74
74
|
# {Vedeu::Input::Input#specials}. When more than one key is
|
75
75
|
# defined, then the extras are treated as aliases.
|
76
76
|
# @param block [Proc] The action to perform when this key is pressed. Can
|
77
77
|
# be a method call or event triggered.
|
78
78
|
# @raise [Vedeu::Error::InvalidSyntax]
|
79
|
-
# When the required block is not given, the
|
79
|
+
# When the required block is not given, the values parameter is
|
80
80
|
# undefined, or when processing the collection, a member is undefined.
|
81
81
|
# @return [Array] A collection containing the keypress(es).
|
82
|
-
def key(*
|
82
|
+
def key(*values, &block)
|
83
83
|
fail Vedeu::Error::InvalidSyntax,
|
84
84
|
'No action defined for `key`.' unless block_given?
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
end
|
86
|
+
fail Vedeu::Error::InvalidSyntax,
|
87
|
+
'No keypress(es) defined for `key`.' unless present?(values)
|
89
88
|
|
90
|
-
|
89
|
+
values.each do |value|
|
91
90
|
unless present?(value)
|
92
91
|
fail Vedeu::Error::InvalidSyntax,
|
93
92
|
'An invalid value for `key` was encountered.'
|
data/lib/vedeu/dsl/line.rb
CHANGED
@@ -59,7 +59,8 @@ module Vedeu
|
|
59
59
|
# end
|
60
60
|
# end
|
61
61
|
#
|
62
|
-
# @raise [Vedeu::Error::InvalidSyntax] When no block or value is
|
62
|
+
# @raise [Vedeu::Error::InvalidSyntax] When no block or value is
|
63
|
+
# provided.
|
63
64
|
# @return [Vedeu::Views::Lines]
|
64
65
|
def line(value = '', &block)
|
65
66
|
if block_given?
|
@@ -81,7 +82,8 @@ module Vedeu
|
|
81
82
|
alias_method :line=, :line
|
82
83
|
|
83
84
|
# Define multiple streams (a stream is a subset of a line).
|
84
|
-
# Uses {Vedeu::DSL::Stream} for all directives within the
|
85
|
+
# Uses {Vedeu::DSL::Stream} for all directives within the
|
86
|
+
# required block.
|
85
87
|
#
|
86
88
|
# Vedeu.renders do
|
87
89
|
# view 'my_interface' do
|
@@ -98,7 +100,8 @@ module Vedeu
|
|
98
100
|
# end
|
99
101
|
#
|
100
102
|
# @param block [Proc]
|
101
|
-
# @raise [Vedeu::Error::InvalidSyntax] The required block was
|
103
|
+
# @raise [Vedeu::Error::InvalidSyntax] The required block was
|
104
|
+
# not given.
|
102
105
|
# @return [Vedeu::Views::Streams<Vedeu::Views::Stream>]
|
103
106
|
# @see Vedeu::DSL::Stream for subdirectives.
|
104
107
|
def streams(&block)
|
data/lib/vedeu/dsl/stream.rb
CHANGED
@@ -21,7 +21,8 @@ module Vedeu
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# @param block [Proc]
|
24
|
-
# @raise [Vedeu::Error::InvalidSyntax] The required block was
|
24
|
+
# @raise [Vedeu::Error::InvalidSyntax] The required block was
|
25
|
+
# not given.
|
25
26
|
# @return [void]
|
26
27
|
def stream(&block)
|
27
28
|
fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?
|
data/lib/vedeu/editor/cursor.rb
CHANGED
@@ -53,9 +53,7 @@ module Vedeu
|
|
53
53
|
# @option attributes ox [Fixnum]
|
54
54
|
# @return [Vedeu::Editor::Cursor]
|
55
55
|
def initialize(attributes = {})
|
56
|
-
|
57
|
-
|
58
|
-
@attributes.each do |key, value|
|
56
|
+
defaults.merge!(attributes).each do |key, value|
|
59
57
|
instance_variable_set("@#{key}", value)
|
60
58
|
end
|
61
59
|
end
|
@@ -6,7 +6,7 @@ module Vedeu
|
|
6
6
|
#
|
7
7
|
class Document
|
8
8
|
|
9
|
-
include Vedeu::Model
|
9
|
+
include Vedeu::Repositories::Model
|
10
10
|
extend Forwardable
|
11
11
|
|
12
12
|
def_delegators :border,
|
@@ -41,12 +41,11 @@ module Vedeu
|
|
41
41
|
# @param attributes [Hash]
|
42
42
|
# @option attributes data [String]
|
43
43
|
# @option attributes name [String]
|
44
|
-
# @option attributes repository
|
44
|
+
# @option attributes repository
|
45
|
+
# [Vedeu::Repositories::Repository]
|
45
46
|
# @return [Vedeu::Editor::Document]
|
46
47
|
def initialize(attributes = {})
|
47
|
-
|
48
|
-
|
49
|
-
@attributes.each do |key, value|
|
48
|
+
defaults.merge!(attributes).each do |key, value|
|
50
49
|
instance_variable_set("@#{key}", value || defaults.fetch(key))
|
51
50
|
end
|
52
51
|
end
|
data/lib/vedeu/editor/line.rb
CHANGED
@@ -110,9 +110,8 @@ module Vedeu
|
|
110
110
|
def insert_character(character, index = nil)
|
111
111
|
return self unless character
|
112
112
|
|
113
|
-
|
114
|
-
|
115
|
-
Vedeu::Editor::Line.coerce(insert)
|
113
|
+
Vedeu::Editor::Line.coerce(Vedeu::Editor::Insert
|
114
|
+
.into(line, character, index, size))
|
116
115
|
end
|
117
116
|
|
118
117
|
# Return the size of the line in characters.
|
data/lib/vedeu/editor/lines.rb
CHANGED
@@ -137,9 +137,8 @@ module Vedeu
|
|
137
137
|
def insert_line(line, index = nil)
|
138
138
|
return self unless line
|
139
139
|
|
140
|
-
|
141
|
-
|
142
|
-
Vedeu::Editor::Lines.coerce(insert)
|
140
|
+
Vedeu::Editor::Lines.coerce(Vedeu::Editor::Insert
|
141
|
+
.into(lines, line, index, size))
|
143
142
|
end
|
144
143
|
|
145
144
|
# Returns the line at the given index.
|
data/lib/vedeu/esc/colours.rb
CHANGED
@@ -28,13 +28,17 @@ module Vedeu
|
|
28
28
|
# to produce the desired colours:
|
29
29
|
#
|
30
30
|
# @example
|
31
|
-
#
|
31
|
+
# # "\e[31m"
|
32
|
+
# Vedeu::EscapeSequences::Esc.red
|
32
33
|
#
|
33
|
-
#
|
34
|
+
# # "\e[31msome text\e[39m"
|
35
|
+
# Vedeu::EscapeSequences::Esc.red { 'some text' }
|
34
36
|
#
|
35
|
-
#
|
37
|
+
# # "\e[44m"
|
38
|
+
# Vedeu::EscapeSequences::Esc.on_blue
|
36
39
|
#
|
37
|
-
#
|
40
|
+
# # "\e[44msome text\e[49m"
|
41
|
+
# Vedeu::EscapeSequences::Esc.on_blue { 'some text' }
|
38
42
|
#
|
39
43
|
# # Valid names:
|
40
44
|
# :black, :red, :green, :yellow, :blue, :magenta, :cyan,
|