vedeu 0.6.36 → 0.6.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +3 -3
  3. data/.yardopts +2 -0
  4. data/bin/vedeu_drb_server +0 -1
  5. data/docs/api.md +6 -2
  6. data/docs/cell.md +9 -0
  7. data/docs/chars.md +7 -0
  8. data/docs/colours_styles.md +8 -0
  9. data/docs/dsl.md +6 -2
  10. data/docs/input.md +98 -0
  11. data/docs/lines.md +8 -0
  12. data/docs/output.md +2 -0
  13. data/docs/streams.md +6 -0
  14. data/docs/template.md +3 -0
  15. data/docs/view.md +3 -6
  16. data/examples/dsl_demo_groups.rb +12 -4
  17. data/examples/dsl_hello_worlds.rb +2 -6
  18. data/lib/vedeu/distributed/templates/default_geometries.vedeu +0 -1
  19. data/lib/vedeu/dsl/view.rb +0 -1
  20. data/lib/vedeu/geometry/alignment.rb +65 -1
  21. data/lib/vedeu/geometry/area.rb +10 -15
  22. data/lib/vedeu/geometry/dimension.rb +19 -81
  23. data/lib/vedeu/geometry/dsl.rb +2 -25
  24. data/lib/vedeu/geometry/geometry.rb +6 -25
  25. data/lib/vedeu/geometry/x_dimension.rb +4 -9
  26. data/lib/vedeu/geometry/y_dimension.rb +4 -9
  27. data/lib/vedeu/null/generic.rb +0 -1
  28. data/lib/vedeu/output/renderers/file.rb +4 -0
  29. data/lib/vedeu/version.rb +1 -1
  30. data/test/lib/vedeu/geometry/alignment_test.rb +118 -0
  31. data/test/lib/vedeu/geometry/area_test.rb +0 -2
  32. data/test/lib/vedeu/geometry/dimension_test.rb +13 -19
  33. data/test/lib/vedeu/geometry/dsl_test.rb +4 -39
  34. data/test/lib/vedeu/geometry/geometry_test.rb +0 -68
  35. data/test/lib/vedeu/geometry/horizontal_alignment_test.rb +6 -0
  36. data/test/lib/vedeu/geometry/vertical_alignment_test.rb +6 -0
  37. data/test/lib/vedeu/geometry/x_dimension_test.rb +0 -2
  38. data/test/lib/vedeu/geometry/y_dimension_test.rb +0 -2
  39. data/test/lib/vedeu/null/generic_test.rb +0 -1
  40. data/test/support/examples/drb_app.rb +0 -1
  41. data/test/support/examples/hello_world.rb +1 -3
  42. data/test/support/examples/view_templates_app/view_templates_app.rb +1 -3
  43. metadata +10 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3edf1e2bc88b118913301844f044fcd633e8833a
4
- data.tar.gz: 4710cf6599d6e1a520f6298431ad7287475dfcf9
3
+ metadata.gz: 7fba735c3e10acba05e8b802dd3db76f2ebb06e0
4
+ data.tar.gz: 47bdfcbf57f2e69102f8a3fa489a4b88799a300f
5
5
  SHA512:
6
- metadata.gz: 0747b79841c05ad9589bfb339e4999665fdf4ad82994a9be7ec566b99303053685665ded9548d9480366226f82206736348a81931916279e7b63037773977c1c
7
- data.tar.gz: 5bece749f11c38671a4033d066dbe8efdc610be430232df65017256f978907225636d57a24c778331f1508cedc97e179e98c3f665adc34a85ee9ceadd61e2ada
6
+ metadata.gz: 828bab91908c976e8e19936576afee8b24ea4fed9ca4748d384bb547ed19edfafaf9f6e4dedd07eb1101f652875eb8ea164ac84621bae1307c7b5b42eaafe3e3
7
+ data.tar.gz: 4ed3df4d46e4983c3fa205bfbc586530b26096ce2ef561cc6509fa3d8b9dc82ec83f59e5c0195b95e48bb1a37c61e9a7c9c0172043f179833c69ea53edd1fb98
data/.codeclimate.yml CHANGED
@@ -2,6 +2,6 @@ ratings:
2
2
  paths:
3
3
  - lib/**
4
4
  exclude_paths:
5
- - "examples/**/*"
6
- - "test/**/*"
7
- - "vendor/**/*"
5
+ - "examples/*"
6
+ - "test/*"
7
+ - "vendor/*"
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
@@ -64,7 +64,6 @@ class VedeuTestApplication
64
64
  end
65
65
 
66
66
  Vedeu.geometry :test_interface do
67
- # centred!
68
67
  height 6
69
68
  width 26
70
69
  x 4
data/docs/api.md CHANGED
@@ -67,12 +67,16 @@ See {file:docs/events.md}
67
67
  - focus!
68
68
  - foreground
69
69
  - geometry
70
- - alignment
70
+ - align
71
71
  - align_left
72
72
  - align_center
73
73
  - align_centre
74
74
  - align_right
75
- - centred (or centred!)
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}.
@@ -0,0 +1,8 @@
1
+ # @title Vedeu Colours & Styles
2
+ # Vedeu Colours & Styles
3
+
4
+ - A colour is made up of a Background and a Foreground.
5
+
6
+ ## Vedeu Background Colours
7
+
8
+ ## Vedeu Foreground Colours
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#alignment}
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#centred}
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
@@ -0,0 +1,2 @@
1
+ # @title Vedeu Output
2
+ # Vedeu Output
data/docs/streams.md ADDED
@@ -0,0 +1,6 @@
1
+ # @title Vedeu Streams
2
+ # Vedeu Streams
3
+
4
+ - Streams can have their own background, foreground and styles. See
5
+ {file:docs/colours_styles.md Colours & Styles} for more details.
6
+ - A stream is made up of {file:docs/chars.md Characters}.
data/docs/template.md ADDED
@@ -0,0 +1,3 @@
1
+ # @title Vedeu View Templates
2
+ # Vedeu View Templates
3
+
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, made up of characters.
10
- - Lines can have their own background, foreground and styles.
11
- - A line can also be made up of streams, a stream itself having its
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}.
@@ -83,16 +83,24 @@ class DemoGroupsApp
83
83
 
84
84
  Vedeu.views do
85
85
  view(:apple) do
86
- line 'apple'
86
+ lines do
87
+ line 'apple'
88
+ end
87
89
  end
88
90
  view(:banana) do
89
- line 'banana'
91
+ lines do
92
+ line 'banana'
93
+ end
90
94
  end
91
95
  view(:carrot) do
92
- line 'carrot'
96
+ lines do
97
+ line 'carrot'
98
+ end
93
99
  end
94
100
  view(:dill) do
95
- line 'dill'
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
- centred!
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
- centred!
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
@@ -1,5 +1,4 @@
1
1
  Vedeu.geometry :test_interface do
2
- # centred!
3
2
  height 6
4
3
  width 26
5
4
  x 4
@@ -17,7 +17,6 @@ module Vedeu
17
17
  #
18
18
  # Vedeu.interface :main do
19
19
  # geometry do
20
- # centred!
21
20
  # height 4
22
21
  # width 50
23
22
  # end
@@ -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]
@@ -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: attributes[:y],
50
- dn: attributes[:yn],
51
- d_dn: attributes[:y_yn],
52
- default: Vedeu.height,
53
- maximised: attributes[:maximised],
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: attributes[:x],
59
- dn: attributes[:xn],
60
- d_dn: attributes[:x_xn],
61
- default: Vedeu.width,
62
- maximised: attributes[:maximised],
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)