vedeu 0.6.36 → 0.6.37
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/.codeclimate.yml +3 -3
- data/.yardopts +2 -0
- data/bin/vedeu_drb_server +0 -1
- data/docs/api.md +6 -2
- data/docs/cell.md +9 -0
- data/docs/chars.md +7 -0
- data/docs/colours_styles.md +8 -0
- data/docs/dsl.md +6 -2
- data/docs/input.md +98 -0
- data/docs/lines.md +8 -0
- data/docs/output.md +2 -0
- data/docs/streams.md +6 -0
- data/docs/template.md +3 -0
- data/docs/view.md +3 -6
- data/examples/dsl_demo_groups.rb +12 -4
- data/examples/dsl_hello_worlds.rb +2 -6
- data/lib/vedeu/distributed/templates/default_geometries.vedeu +0 -1
- data/lib/vedeu/dsl/view.rb +0 -1
- data/lib/vedeu/geometry/alignment.rb +65 -1
- data/lib/vedeu/geometry/area.rb +10 -15
- data/lib/vedeu/geometry/dimension.rb +19 -81
- data/lib/vedeu/geometry/dsl.rb +2 -25
- data/lib/vedeu/geometry/geometry.rb +6 -25
- data/lib/vedeu/geometry/x_dimension.rb +4 -9
- data/lib/vedeu/geometry/y_dimension.rb +4 -9
- data/lib/vedeu/null/generic.rb +0 -1
- data/lib/vedeu/output/renderers/file.rb +4 -0
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/geometry/alignment_test.rb +118 -0
- data/test/lib/vedeu/geometry/area_test.rb +0 -2
- data/test/lib/vedeu/geometry/dimension_test.rb +13 -19
- data/test/lib/vedeu/geometry/dsl_test.rb +4 -39
- data/test/lib/vedeu/geometry/geometry_test.rb +0 -68
- data/test/lib/vedeu/geometry/horizontal_alignment_test.rb +6 -0
- data/test/lib/vedeu/geometry/vertical_alignment_test.rb +6 -0
- data/test/lib/vedeu/geometry/x_dimension_test.rb +0 -2
- data/test/lib/vedeu/geometry/y_dimension_test.rb +0 -2
- data/test/lib/vedeu/null/generic_test.rb +0 -1
- data/test/support/examples/drb_app.rb +0 -1
- data/test/support/examples/hello_world.rb +1 -3
- data/test/support/examples/view_templates_app/view_templates_app.rb +1 -3
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fba735c3e10acba05e8b802dd3db76f2ebb06e0
|
4
|
+
data.tar.gz: 47bdfcbf57f2e69102f8a3fa489a4b88799a300f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 828bab91908c976e8e19936576afee8b24ea4fed9ca4748d384bb547ed19edfafaf9f6e4dedd07eb1101f652875eb8ea164ac84621bae1307c7b5b42eaafe3e3
|
7
|
+
data.tar.gz: 4ed3df4d46e4983c3fa205bfbc586530b26096ce2ef561cc6509fa3d8b9dc82ec83f59e5c0195b95e48bb1a37c61e9a7c9c0172043f179833c69ea53edd1fb98
|
data/.codeclimate.yml
CHANGED
data/.yardopts
CHANGED
@@ -12,9 +12,11 @@ docs/events.md
|
|
12
12
|
docs/geometry.md
|
13
13
|
docs/getting_started.md
|
14
14
|
docs/group.md
|
15
|
+
docs/input.md
|
15
16
|
docs/interfaces.md
|
16
17
|
docs/keymaps.md
|
17
18
|
docs/object_graph.md
|
19
|
+
docs/output.md
|
18
20
|
docs/view.md
|
19
21
|
docs/events/application.md
|
20
22
|
docs/events/document.md
|
data/bin/vedeu_drb_server
CHANGED
data/docs/api.md
CHANGED
@@ -67,12 +67,16 @@ See {file:docs/events.md}
|
|
67
67
|
- focus!
|
68
68
|
- foreground
|
69
69
|
- geometry
|
70
|
-
-
|
70
|
+
- align
|
71
71
|
- align_left
|
72
72
|
- align_center
|
73
73
|
- align_centre
|
74
74
|
- align_right
|
75
|
-
-
|
75
|
+
- align_top
|
76
|
+
- align_middle
|
77
|
+
- align_bottom
|
78
|
+
- horizontal_alignment
|
79
|
+
- vertical_alignment
|
76
80
|
- height
|
77
81
|
- width
|
78
82
|
- x
|
data/docs/cell.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# @title Vedeu Cells
|
2
|
+
# Vedeu Cells
|
3
|
+
|
4
|
+
- A cell represents a single character in the visible terminal space.
|
5
|
+
We could use {file:docs/chars.md Characters} for this, but sometimes
|
6
|
+
a character is empty, and only has a colour and/or style.
|
7
|
+
- Cells also represent individual terminal escape sequences. Although
|
8
|
+
most are not visible, in order to correctly render a TTY, they are
|
9
|
+
used.
|
data/docs/chars.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# @title Vedeu Characters
|
2
|
+
# Vedeu Characters
|
3
|
+
|
4
|
+
- Characters can have their own background, foreground and styles. See
|
5
|
+
{file:docs/colours_styles.md Colours & Styles} for more details.
|
6
|
+
- The character is a fundamental building block of a terminal
|
7
|
+
{file:docs/cell.md Cell}.
|
data/docs/dsl.md
CHANGED
@@ -109,11 +109,15 @@ end
|
|
109
109
|
|
110
110
|
### Setting the interface dimensions
|
111
111
|
|
112
|
-
{include:Vedeu::Geometry::DSL#
|
112
|
+
{include:Vedeu::Geometry::DSL#align}
|
113
113
|
{include:Vedeu::Geometry::DSL#align_left}
|
114
114
|
{include:Vedeu::Geometry::DSL#align_centre}
|
115
115
|
{include:Vedeu::Geometry::DSL#align_right}
|
116
|
-
{include:Vedeu::Geometry::DSL#
|
116
|
+
{include:Vedeu::Geometry::DSL#align_top}
|
117
|
+
{include:Vedeu::Geometry::DSL#align_middle}
|
118
|
+
{include:Vedeu::Geometry::DSL#align_bottom}
|
119
|
+
{include:Vedeu::Geometry::DSL#horizontal_alignment}
|
120
|
+
{include:Vedeu::Geometry::DSL#vertical_alignment}
|
117
121
|
{include:Vedeu::Geometry::DSL#height}
|
118
122
|
{include:Vedeu::Geometry::DSL#width}
|
119
123
|
{include:Vedeu::Geometry::DSL#columns}
|
data/docs/input.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# @title Vedeu Input
|
2
|
+
# Vedeu Input
|
3
|
+
|
4
|
+
A configured and running client application using Vedeu will spend the
|
5
|
+
majority of its time waiting for input from the terminal by the user.
|
6
|
+
|
7
|
+
Input in to Vedeu is essentially characters derived from a keypress or
|
8
|
+
keypresses, and throughout this document, 'characters' and
|
9
|
+
'keypresses' may be used interchangably to mean 'input'.
|
10
|
+
|
11
|
+
* It should be noted that data can be also be 'piped' into a Vedeu
|
12
|
+
application as input, though at this time, this is not the mode du
|
13
|
+
jour.
|
14
|
+
|
15
|
+
The input received by Vedeu is handled in one of three ways, depending
|
16
|
+
on which mode Vedeu has been configured to use;
|
17
|
+
'{file:docs/input.md#label-Raw+Mode raw}' (default),
|
18
|
+
'{file:docs/input.md#label-Cooked+Mode cooked}' or
|
19
|
+
'{file:docs/input.md#label-Fake+Mode fake}'. See below for details of
|
20
|
+
each.
|
21
|
+
|
22
|
+
* Vedeu uses Ruby's 'IO/Console' from the standard library to
|
23
|
+
facilitate this. For more information relating to this area, consult
|
24
|
+
the Ruby documentation, or the 'stty(1)' or 'termios(3)' manpages.
|
25
|
+
|
26
|
+
## Raw Mode
|
27
|
+
|
28
|
+
This is the default mode for Vedeu. Keypresses or characters are not
|
29
|
+
processed by the underlying terminal, but instead sent directly to
|
30
|
+
Vedeu to be handled.
|
31
|
+
|
32
|
+
Vedeu.configure do
|
33
|
+
terminal_mode :raw
|
34
|
+
|
35
|
+
# or...
|
36
|
+
|
37
|
+
raw!
|
38
|
+
|
39
|
+
# ...more configuration here
|
40
|
+
end
|
41
|
+
|
42
|
+
This mode is generally used to perform an operation dependent on the
|
43
|
+
key which was pressed. The configuration of mapping keypresses to
|
44
|
+
actions is handled on a per-interface basis; each interface having its
|
45
|
+
own keymap which can perform specific actions.
|
46
|
+
|
47
|
+
There is also global keymap available to handle certain keypresses
|
48
|
+
application-wide, ie. irrespective of the interface or view which is
|
49
|
+
currently in focus. The global keymap would specify the keypress
|
50
|
+
needed to exit the application, for example.
|
51
|
+
|
52
|
+
See {file:docs/keymaps.md Keymaps} for more information.
|
53
|
+
|
54
|
+
## Cooked Mode
|
55
|
+
|
56
|
+
Here, the input from the user is stored in an internal buffer by the
|
57
|
+
terminal itself until a line-feed or carriage-return character is
|
58
|
+
encountered. The terminal then sends this stream of characters to
|
59
|
+
Vedeu to be processed.
|
60
|
+
|
61
|
+
Vedeu.configure do
|
62
|
+
terminal_mode :cooked
|
63
|
+
|
64
|
+
# or...
|
65
|
+
|
66
|
+
cooked!
|
67
|
+
|
68
|
+
# ...more configuration here
|
69
|
+
end
|
70
|
+
|
71
|
+
## Fake Mode
|
72
|
+
|
73
|
+
Whilst technically the terminal will be in raw mode, with the 'fake'
|
74
|
+
mode, Vedeu attempts to simulate cooked mode but with some additional
|
75
|
+
functionality. To do this, Vedeu creates an internal buffer for
|
76
|
+
characters resulting from keypresses to be either stored or processed
|
77
|
+
immediately.
|
78
|
+
|
79
|
+
Vedeu.configure do
|
80
|
+
terminal_mode :fake
|
81
|
+
|
82
|
+
# or...
|
83
|
+
|
84
|
+
fake!
|
85
|
+
|
86
|
+
# ...more configuration here
|
87
|
+
end
|
88
|
+
|
89
|
+
## Mode Switching
|
90
|
+
|
91
|
+
During the lifecycle of a Vedeu client application it may be necessary
|
92
|
+
to switch between the different modes offered. This is handled by
|
93
|
+
triggering the `:\_mode_switch\_` event. By default, this cycles
|
94
|
+
through the available modes. When an optional but valid target mode is
|
95
|
+
given, that mode will be activated instead.
|
96
|
+
|
97
|
+
Vedeu.trigger(:_mode_switch_, mode) # Valid values for mode are
|
98
|
+
# :raw, :cooked or :fake
|
data/docs/lines.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# @title Vedeu Lines
|
2
|
+
# Vedeu Lines
|
3
|
+
|
4
|
+
- Lines can have their own background, foreground and styles. See
|
5
|
+
{file:docs/colours_styles.md Colours & Styles} for more details.
|
6
|
+
- A line can also be made up of {file:docs/streams.md Streams}.
|
7
|
+
- Lines or streams are made up of {file:docs/chars.md Characters}
|
8
|
+
|
data/docs/output.md
ADDED
data/docs/streams.md
ADDED
data/docs/template.md
ADDED
data/docs/view.md
CHANGED
@@ -6,12 +6,9 @@ course) view. This view will contain that which is visible within the
|
|
6
6
|
interface and is determined by the position of the cursor associated
|
7
7
|
with the interface.
|
8
8
|
|
9
|
-
- A view is made up of lines
|
10
|
-
-
|
11
|
-
|
12
|
-
own background, foreground and styles.
|
13
|
-
- Lines and streams are made up of characters- again, each with their
|
14
|
-
own background, foreground and styles.
|
9
|
+
- A view is made up of {file:docs/lines.md Lines}.
|
10
|
+
- A view can also be derived from a
|
11
|
+
{file:docs/templates.md View Template}.
|
15
12
|
|
16
13
|
Views can be requested to be drawn immediately on construction, or
|
17
14
|
added to a {file:docs/buffer.md Buffer}.
|
data/examples/dsl_demo_groups.rb
CHANGED
@@ -83,16 +83,24 @@ class DemoGroupsApp
|
|
83
83
|
|
84
84
|
Vedeu.views do
|
85
85
|
view(:apple) do
|
86
|
-
|
86
|
+
lines do
|
87
|
+
line 'apple'
|
88
|
+
end
|
87
89
|
end
|
88
90
|
view(:banana) do
|
89
|
-
|
91
|
+
lines do
|
92
|
+
line 'banana'
|
93
|
+
end
|
90
94
|
end
|
91
95
|
view(:carrot) do
|
92
|
-
|
96
|
+
lines do
|
97
|
+
line 'carrot'
|
98
|
+
end
|
93
99
|
end
|
94
100
|
view(:dill) do
|
95
|
-
|
101
|
+
lines do
|
102
|
+
line 'dill'
|
103
|
+
end
|
96
104
|
end
|
97
105
|
end
|
98
106
|
|
@@ -27,9 +27,7 @@ class HelloWorldsApp
|
|
27
27
|
background '#000000'
|
28
28
|
foreground '#00ff00'
|
29
29
|
geometry do
|
30
|
-
|
31
|
-
height 5
|
32
|
-
width 24
|
30
|
+
align(:middle, :centre, 24, 5)
|
33
31
|
end
|
34
32
|
# (You usually specify the views outside the interface block).
|
35
33
|
Vedeu.views do
|
@@ -59,9 +57,7 @@ class HelloWorldsApp
|
|
59
57
|
Vedeu.render do
|
60
58
|
view :hello do
|
61
59
|
geometry do
|
62
|
-
|
63
|
-
height 5 + 2
|
64
|
-
width 24 + 2
|
60
|
+
align(:middle, :centre, (24 + 2), (5 + 2))
|
65
61
|
end
|
66
62
|
border do
|
67
63
|
colour foreground: ["#00ff00", "#000033", "#cddc39", "#03a9f4"].sample
|
data/lib/vedeu/dsl/view.rb
CHANGED
@@ -18,6 +18,21 @@ module Vedeu
|
|
18
18
|
new(value).align
|
19
19
|
end
|
20
20
|
|
21
|
+
# @param value [NilClass|Symbol|Vedeu::Geometry::Alignment]
|
22
|
+
# @return [Vedeu::Geometry::Alignment]
|
23
|
+
def self.coerce(value = nil)
|
24
|
+
if value.is_a?(self)
|
25
|
+
value
|
26
|
+
|
27
|
+
elsif value.is_a?(Symbol)
|
28
|
+
new(value)
|
29
|
+
|
30
|
+
else
|
31
|
+
new(:none)
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
21
36
|
# @param value [NilClass|Symbol]
|
22
37
|
# @return [Vedeu::Geometry::Alignment]
|
23
38
|
def initialize(value = nil)
|
@@ -30,11 +45,60 @@ module Vedeu
|
|
30
45
|
fail Vedeu::Error::NotImplemented, 'Subclasses implement this.'.freeze
|
31
46
|
end
|
32
47
|
|
48
|
+
# Return a boolean indicating alignment was set to :bottom.
|
49
|
+
#
|
50
|
+
# @return [Boolean]
|
51
|
+
def bottom_aligned?
|
52
|
+
value == :bottom
|
53
|
+
end
|
54
|
+
|
55
|
+
# Return a boolean indicating alignment was set to :centre.
|
56
|
+
#
|
57
|
+
# @return [Boolean]
|
58
|
+
def centre_aligned?
|
59
|
+
value == :centre
|
60
|
+
end
|
61
|
+
|
62
|
+
# Return a boolean indicating alignment was set to :left.
|
63
|
+
#
|
64
|
+
# @return [Boolean]
|
65
|
+
def left_aligned?
|
66
|
+
value == :left
|
67
|
+
end
|
68
|
+
|
69
|
+
# Return a boolean indicating alignment was set to :middle.
|
70
|
+
#
|
71
|
+
# @return [Boolean]
|
72
|
+
def middle_aligned?
|
73
|
+
value == :middle
|
74
|
+
end
|
75
|
+
|
76
|
+
# Return a boolean indicating alignment was set to :right.
|
77
|
+
#
|
78
|
+
# @return [Boolean]
|
79
|
+
def right_aligned?
|
80
|
+
value == :right
|
81
|
+
end
|
82
|
+
|
83
|
+
# Return a boolean indicating alignment was set to :top.
|
84
|
+
#
|
85
|
+
# @return [Boolean]
|
86
|
+
def top_aligned?
|
87
|
+
value == :top
|
88
|
+
end
|
89
|
+
|
90
|
+
# Return a boolean indicating alignment was set to, or is :none.
|
91
|
+
#
|
92
|
+
# @return [Boolean]
|
93
|
+
def unaligned?
|
94
|
+
value == :none
|
95
|
+
end
|
96
|
+
|
33
97
|
private
|
34
98
|
|
35
99
|
# @return [Boolean]
|
36
100
|
def none?
|
37
|
-
@value.nil? || !(@value.is_a?(Symbol))
|
101
|
+
@value == :none || @value.nil? || !(@value.is_a?(Symbol))
|
38
102
|
end
|
39
103
|
|
40
104
|
# @return [Boolean]
|
data/lib/vedeu/geometry/area.rb
CHANGED
@@ -40,28 +40,23 @@ module Vedeu
|
|
40
40
|
# @option attributes x_xn [Fixnum]
|
41
41
|
# @option attributes x_default [Fixnum]
|
42
42
|
# @option attributes maximised [Boolean]
|
43
|
-
# @option attributes centred [Boolean]
|
44
43
|
# @option attributes horizontal_alignment [Symbol]
|
45
44
|
# @option attributes vertical_alignment [Symbol]
|
46
45
|
# @return [Vedeu::Geometry::Area]
|
47
46
|
def self.from_attributes(attributes = {})
|
48
47
|
y_attributes = {
|
49
|
-
d:
|
50
|
-
dn:
|
51
|
-
d_dn:
|
52
|
-
|
53
|
-
|
54
|
-
centred: attributes[:centred],
|
55
|
-
vertical_alignment: attributes[:vertical_alignment],
|
48
|
+
d: attributes[:y],
|
49
|
+
dn: attributes[:yn],
|
50
|
+
d_dn: attributes[:y_yn],
|
51
|
+
maximised: attributes[:maximised],
|
52
|
+
alignment: attributes[:vertical_alignment],
|
56
53
|
}
|
57
54
|
x_attributes = {
|
58
|
-
d:
|
59
|
-
dn:
|
60
|
-
d_dn:
|
61
|
-
|
62
|
-
|
63
|
-
centred: attributes[:centred],
|
64
|
-
horizontal_alignment: attributes[:horizontal_alignment],
|
55
|
+
d: attributes[:x],
|
56
|
+
dn: attributes[:xn],
|
57
|
+
d_dn: attributes[:x_xn],
|
58
|
+
maximised: attributes[:maximised],
|
59
|
+
alignment: attributes[:horizontal_alignment],
|
65
60
|
}
|
66
61
|
y_yn = Vedeu::Geometry::YDimension.pair(y_attributes)
|
67
62
|
x_xn = Vedeu::Geometry::XDimension.pair(x_attributes)
|