vedeu 0.6.9 → 0.6.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/lib/vedeu/all.rb +3 -3
  4. data/lib/vedeu/api/external.rb +194 -0
  5. data/lib/vedeu/api/internal.rb +173 -0
  6. data/lib/vedeu/application/controller.rb +3 -2
  7. data/lib/vedeu/bindings/application.rb +1 -1
  8. data/lib/vedeu/bindings/drb.rb +2 -3
  9. data/lib/vedeu/bindings/movement.rb +1 -1
  10. data/lib/vedeu/buffers/all.rb +0 -2
  11. data/lib/vedeu/colours/translator.rb +2 -1
  12. data/lib/vedeu/common.rb +4 -2
  13. data/lib/vedeu/configuration/api.rb +1 -1
  14. data/lib/vedeu/configuration/cli.rb +1 -1
  15. data/lib/vedeu/cursors/repository.rb +1 -1
  16. data/lib/vedeu/editor/insert.rb +12 -13
  17. data/lib/vedeu/geometry/position.rb +1 -1
  18. data/lib/vedeu/models/cell.rb +35 -21
  19. data/lib/vedeu/models/escape.rb +18 -1
  20. data/lib/vedeu/models/page.rb +20 -10
  21. data/lib/vedeu/models/row.rb +18 -8
  22. data/lib/vedeu/models/views/char.rb +9 -7
  23. data/lib/vedeu/models/views/view.rb +1 -1
  24. data/lib/vedeu/output/compressor.rb +22 -14
  25. data/lib/vedeu/output/output.rb +1 -10
  26. data/lib/vedeu/output/renderers/escape_sequence.rb +8 -4
  27. data/lib/vedeu/output/renderers/file.rb +7 -23
  28. data/lib/vedeu/output/renderers/html.rb +47 -26
  29. data/lib/vedeu/output/renderers/json.rb +11 -16
  30. data/lib/vedeu/output/renderers/null.rb +1 -1
  31. data/lib/vedeu/output/renderers/renderer_options.rb +2 -1
  32. data/lib/vedeu/output/renderers/terminal.rb +7 -15
  33. data/lib/vedeu/output/renderers/text.rb +1 -1
  34. data/lib/vedeu/output/viewport.rb +154 -143
  35. data/lib/vedeu/repositories/collection.rb +2 -2
  36. data/lib/vedeu/repositories/model.rb +25 -26
  37. data/lib/vedeu/repositories/registerable.rb +9 -8
  38. data/lib/vedeu/repositories/repository.rb +21 -16
  39. data/lib/vedeu/repositories/store.rb +6 -4
  40. data/lib/vedeu/runtime/bootstrap.rb +7 -5
  41. data/lib/vedeu/runtime/main_loop.rb +2 -0
  42. data/lib/vedeu/runtime/router.rb +155 -149
  43. data/lib/vedeu/templating/decoder.rb +8 -5
  44. data/lib/vedeu/templating/encoder.rb +6 -4
  45. data/lib/vedeu/templating/template.rb +2 -2
  46. data/lib/vedeu/templating/view_template.rb +8 -7
  47. data/lib/vedeu/terminal/buffer.rb +132 -0
  48. data/lib/vedeu/terminal/terminal.rb +0 -5
  49. data/lib/vedeu/version.rb +1 -1
  50. data/lib/vedeu.rb +2 -2
  51. data/out_ +50 -0
  52. data/test/lib/vedeu/api/external_test.rb +62 -0
  53. data/test/lib/vedeu/{internal_api_test.rb → api/internal_test.rb} +6 -2
  54. data/test/lib/vedeu/application/controller_test.rb +3 -3
  55. data/test/lib/vedeu/bindings/application_test.rb +2 -2
  56. data/test/lib/vedeu/models/cell_test.rb +48 -17
  57. data/test/lib/vedeu/models/escape_test.rb +29 -7
  58. data/test/lib/vedeu/models/page_test.rb +70 -50
  59. data/test/lib/vedeu/models/row_test.rb +40 -20
  60. data/test/lib/vedeu/output/compressor_test.rb +12 -12
  61. data/test/lib/vedeu/output/output_test.rb +17 -23
  62. data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +15 -11
  63. data/test/lib/vedeu/output/renderers/html_test.rb +66 -68
  64. data/test/lib/vedeu/output/renderers/json_test.rb +36 -83
  65. data/test/lib/vedeu/output/renderers/terminal_test.rb +22 -2
  66. data/test/lib/vedeu/output/viewport_test.rb +201 -197
  67. data/test/lib/vedeu/runtime/router_test.rb +144 -140
  68. data/test/lib/vedeu/terminal/buffer_test.rb +307 -0
  69. data/test/support/examples/material_colours_app.rb +2 -2
  70. data/test/support/templates/html_renderer.vedeu +24 -0
  71. metadata +14 -17
  72. data/lib/vedeu/api.rb +0 -190
  73. data/lib/vedeu/buffers/virtual_buffer.rb +0 -136
  74. data/lib/vedeu/buffers/virtual_buffers.rb +0 -77
  75. data/lib/vedeu/internal_api.rb +0 -173
  76. data/lib/vedeu/terminal/content.rb +0 -88
  77. data/test/lib/vedeu/api_test.rb +0 -58
  78. data/test/lib/vedeu/buffers/virtual_buffer_test.rb +0 -148
  79. data/test/lib/vedeu/buffers/virtual_buffers_test.rb +0 -73
  80. data/test/lib/vedeu/terminal/content_test.rb +0 -108
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-16 00:00:00.000000000 Z
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -252,7 +252,8 @@ files:
252
252
  - docs/object_graph.md
253
253
  - lib/vedeu.rb
254
254
  - lib/vedeu/all.rb
255
- - lib/vedeu/api.rb
255
+ - lib/vedeu/api/external.rb
256
+ - lib/vedeu/api/internal.rb
256
257
  - lib/vedeu/application/application_controller.rb
257
258
  - lib/vedeu/application/application_helper.rb
258
259
  - lib/vedeu/application/application_view.rb
@@ -280,8 +281,6 @@ files:
280
281
  - lib/vedeu/buffers/null.rb
281
282
  - lib/vedeu/buffers/refresh.rb
282
283
  - lib/vedeu/buffers/repository.rb
283
- - lib/vedeu/buffers/virtual_buffer.rb
284
- - lib/vedeu/buffers/virtual_buffers.rb
285
284
  - lib/vedeu/colours/all.rb
286
285
  - lib/vedeu/colours/background.rb
287
286
  - lib/vedeu/colours/backgrounds.rb
@@ -364,7 +363,6 @@ files:
364
363
  - lib/vedeu/input/keys.rb
365
364
  - lib/vedeu/input/mapper.rb
366
365
  - lib/vedeu/input/translator.rb
367
- - lib/vedeu/internal_api.rb
368
366
  - lib/vedeu/logging/all.rb
369
367
  - lib/vedeu/logging/debug.rb
370
368
  - lib/vedeu/logging/lockless_log_device.rb
@@ -447,11 +445,13 @@ files:
447
445
  - lib/vedeu/templating/helpers.rb
448
446
  - lib/vedeu/templating/template.rb
449
447
  - lib/vedeu/templating/view_template.rb
450
- - lib/vedeu/terminal/content.rb
448
+ - lib/vedeu/terminal/buffer.rb
451
449
  - lib/vedeu/terminal/mode.rb
452
450
  - lib/vedeu/terminal/terminal.rb
453
451
  - lib/vedeu/version.rb
454
- - test/lib/vedeu/api_test.rb
452
+ - out_
453
+ - test/lib/vedeu/api/external_test.rb
454
+ - test/lib/vedeu/api/internal_test.rb
455
455
  - test/lib/vedeu/application/application_controller_test.rb
456
456
  - test/lib/vedeu/application/application_helper_test.rb
457
457
  - test/lib/vedeu/application/application_view_test.rb
@@ -477,8 +477,6 @@ files:
477
477
  - test/lib/vedeu/buffers/null_test.rb
478
478
  - test/lib/vedeu/buffers/refresh_test.rb
479
479
  - test/lib/vedeu/buffers/repository_test.rb
480
- - test/lib/vedeu/buffers/virtual_buffer_test.rb
481
- - test/lib/vedeu/buffers/virtual_buffers_test.rb
482
480
  - test/lib/vedeu/colours/background_test.rb
483
481
  - test/lib/vedeu/colours/backgrounds_test.rb
484
482
  - test/lib/vedeu/colours/colour_test.rb
@@ -546,7 +544,6 @@ files:
546
544
  - test/lib/vedeu/input/keys_test.rb
547
545
  - test/lib/vedeu/input/mapper_test.rb
548
546
  - test/lib/vedeu/input/translator_test.rb
549
- - test/lib/vedeu/internal_api_test.rb
550
547
  - test/lib/vedeu/logging/debug_test.rb
551
548
  - test/lib/vedeu/logging/lockless_log_device_test.rb
552
549
  - test/lib/vedeu/logging/log_test.rb
@@ -624,7 +621,7 @@ files:
624
621
  - test/lib/vedeu/templating/helpers_test.rb
625
622
  - test/lib/vedeu/templating/template_test.rb
626
623
  - test/lib/vedeu/templating/view_template_test.rb
627
- - test/lib/vedeu/terminal/content_test.rb
624
+ - test/lib/vedeu/terminal/buffer_test.rb
628
625
  - test/lib/vedeu/terminal/mode_test.rb
629
626
  - test/lib/vedeu/terminal/terminal_test.rb
630
627
  - test/lib/vedeu_test.rb
@@ -650,6 +647,7 @@ files:
650
647
  - test/support/examples/view_templates_app/wrap.erb
651
648
  - test/support/helpers/model_test_class.rb
652
649
  - test/support/stats.sh
650
+ - test/support/templates/html_renderer.vedeu
653
651
  - test/test_helper.rb
654
652
  - vedeu.gemspec
655
653
  homepage: https://github.com/gavinlaking/vedeu
@@ -677,7 +675,8 @@ signing_key:
677
675
  specification_version: 4
678
676
  summary: A terminal case of wonderland.
679
677
  test_files:
680
- - test/lib/vedeu/api_test.rb
678
+ - test/lib/vedeu/api/external_test.rb
679
+ - test/lib/vedeu/api/internal_test.rb
681
680
  - test/lib/vedeu/application/application_controller_test.rb
682
681
  - test/lib/vedeu/application/application_helper_test.rb
683
682
  - test/lib/vedeu/application/application_view_test.rb
@@ -703,8 +702,6 @@ test_files:
703
702
  - test/lib/vedeu/buffers/null_test.rb
704
703
  - test/lib/vedeu/buffers/refresh_test.rb
705
704
  - test/lib/vedeu/buffers/repository_test.rb
706
- - test/lib/vedeu/buffers/virtual_buffer_test.rb
707
- - test/lib/vedeu/buffers/virtual_buffers_test.rb
708
705
  - test/lib/vedeu/colours/background_test.rb
709
706
  - test/lib/vedeu/colours/backgrounds_test.rb
710
707
  - test/lib/vedeu/colours/colour_test.rb
@@ -772,7 +769,6 @@ test_files:
772
769
  - test/lib/vedeu/input/keys_test.rb
773
770
  - test/lib/vedeu/input/mapper_test.rb
774
771
  - test/lib/vedeu/input/translator_test.rb
775
- - test/lib/vedeu/internal_api_test.rb
776
772
  - test/lib/vedeu/logging/debug_test.rb
777
773
  - test/lib/vedeu/logging/lockless_log_device_test.rb
778
774
  - test/lib/vedeu/logging/log_test.rb
@@ -850,7 +846,7 @@ test_files:
850
846
  - test/lib/vedeu/templating/helpers_test.rb
851
847
  - test/lib/vedeu/templating/template_test.rb
852
848
  - test/lib/vedeu/templating/view_template_test.rb
853
- - test/lib/vedeu/terminal/content_test.rb
849
+ - test/lib/vedeu/terminal/buffer_test.rb
854
850
  - test/lib/vedeu/terminal/mode_test.rb
855
851
  - test/lib/vedeu/terminal/terminal_test.rb
856
852
  - test/lib/vedeu_test.rb
@@ -876,5 +872,6 @@ test_files:
876
872
  - test/support/examples/view_templates_app/wrap.erb
877
873
  - test/support/helpers/model_test_class.rb
878
874
  - test/support/stats.sh
875
+ - test/support/templates/html_renderer.vedeu
879
876
  - test/test_helper.rb
880
877
  has_rdoc:
data/lib/vedeu/api.rb DELETED
@@ -1,190 +0,0 @@
1
- module Vedeu
2
-
3
- # Provides the API to Vedeu. Methods therein, and classes belonging
4
- # to this module expose Vedeu's core functionality.
5
- #
6
- # These methods are used in a variety of ways, sometimes in
7
- # combination:
8
- #
9
- # # with parameters
10
- # Vedeu.method_name(*params)
11
- #
12
- # # with a block
13
- # Vedeu.method_name(*params) do
14
- # # ...
15
- # end
16
- #
17
- # # with other methods
18
- # Vedeu.method_name.other_method
19
- #
20
- module API
21
-
22
- extend Forwardable
23
-
24
- module_function
25
-
26
- # @!method configure
27
- # @see Vedeu::Configuration.configure
28
- # @!method configuration
29
- # @see Vedeu::Configuration.configuration
30
- def_delegators Vedeu::Configuration, :configure, :configuration
31
-
32
- # @!method cursor
33
- # @return [Vedeu::Cursors::Cursor]
34
- def_delegators Vedeu::Cursors::Repository, :cursor
35
-
36
- # @!method drb_restart
37
- # @see Vedeu::Distributed::Server#restart
38
- # @!method drb_start
39
- # @see Vedeu::Distributed::Server#start
40
- # @!method drb_status
41
- # @see Vedeu::Distributed::Server#status
42
- # @!method drb_stop
43
- # @see Vedeu::Distributed::Server#stop
44
- def_delegators Vedeu::Distributed::Server, :drb_restart, :drb_start,
45
- :drb_status, :drb_stop
46
-
47
- # @!method border
48
- # @see Vedeu::Borders::DSL.border
49
- def_delegators Vedeu::Borders::DSL, :border
50
-
51
- # @!method geometry
52
- # @see Vedeu::Geometry::DSL.geometry
53
- def_delegators Vedeu::Geometry::DSL, :geometry
54
-
55
- # @!method group
56
- # @see Vedeu::DSL::Group.group
57
- def_delegators Vedeu::DSL::Group, :group
58
-
59
- # @!method keymap
60
- # @see Vedeu::DSL::Keymap.keymap
61
- def_delegators Vedeu::DSL::Keymap, :keymap
62
-
63
- # @!method interface
64
- # @see Vedeu::DSL::Interface.interface
65
- def_delegators Vedeu::DSL::Interface, :interface
66
-
67
- # @!method render
68
- # @see Vedeu::DSL::View.render
69
- # @!method renders
70
- # @see Vedeu::DSL::View.renders
71
- # @!method views
72
- # @see Vedeu::DSL::View.views
73
- def_delegators Vedeu::DSL::View, :renders, :render, :views
74
-
75
- # @!method bind
76
- # @see Vedeu::Events::Event.bind
77
- # @!method bound?
78
- # @see Vedeu::Events::Event.bound?
79
- # @!method unbind
80
- # @see Vedeu::Events::Event.unbind
81
- def_delegators Vedeu::Events::Event, :bind, :bound?, :unbind
82
-
83
- # @!method bind_alias
84
- # @see Vedeu::Events::Aliases#bind_alias
85
- # @!method unbind_alias
86
- # @see Vedeu::Events::Aliases#unbind_alias
87
- def_delegators Vedeu::Events::Aliases, :bind_alias, :unbind_alias
88
-
89
- # @!method focus
90
- # @see Vedeu::Models::Focus#focus
91
- # @!method focus_by_name
92
- # @see Vedeu::Models::Focus#focus_by_name
93
- # @!method focussed?
94
- # @see Vedeu::Models::Focus#focussed?
95
- # @!method focus_next
96
- # @see Vedeu::Models::Focus#focus_next
97
- # @!method focus_previous
98
- # @see Vedeu::Models::Focus#focus_previous
99
- def_delegators Vedeu::Models::Focus, :focus, :focus_by_name, :focussed?,
100
- :focus_next, :focus_previous
101
-
102
- # @!method log
103
- # @see Vedeu::Logging::Log.log
104
- # @!method log_stdout
105
- # @see Vedeu::Logging::Log.log_stdout
106
- # @!method log_stderr
107
- # @see Vedeu::Logging::Log.log_stderr
108
- def_delegators Vedeu::Logging::Log, :log, :log_stdout, :log_stderr
109
-
110
- # @!method keypress
111
- # @see Vedeu::Input::Mapper.keypress
112
- def_delegators Vedeu::Input::Mapper, :keypress
113
-
114
- # @!method menu
115
- # @see Vedeu::Menus::Menu.menu
116
- def_delegators Vedeu::Menus::Menu, :menu
117
-
118
- # @!method goto
119
- # @see Vedeu::Router#goto
120
- def_delegators Vedeu::Router, :goto
121
-
122
- # @!method height
123
- # @see Vedeu::Terminal#height
124
- def_delegators Vedeu::Terminal, :height
125
-
126
- # @!method width
127
- # @see Vedeu::Terminal#width
128
- def_delegators Vedeu::Terminal, :width
129
-
130
- # @!method trigger
131
- # @see Vedeu::Events::Trigger.trigger
132
- def_delegators Vedeu::Events::Trigger, :trigger
133
-
134
- # @!method exit
135
- # @see Vedeu::Runtime::Application.stop
136
- def_delegators Vedeu::Runtime::Application, :exit
137
-
138
- # @!method clear
139
- # @see Vedeu::Terminal#clear
140
- def_delegators Vedeu::Terminal, :clear
141
-
142
- # @!method clear_by_name
143
- # @see Vedeu::Clear::NamedInterface.render
144
- def_delegators Vedeu::Clear::NamedInterface, :clear_by_name
145
-
146
- # @!method clear_by_group
147
- # @see Vedeu::Clear::NamedGroup.render
148
- def_delegators Vedeu::Clear::NamedGroup, :clear_by_group
149
-
150
- # @!method hide_cursor
151
- # @see Vedeu::Cursors::Cursor#hide
152
- def_delegators Vedeu::Cursors::Cursor, :hide_cursor
153
-
154
- # @!method show_cursor
155
- # @see Vedeu::Cursors::Cursor#show
156
- def_delegators Vedeu::Cursors::Cursor, :show_cursor
157
-
158
- # @!method toggle_cursor
159
- # @see Vedeu::Cursors::Cursor#toggle
160
- def_delegators Vedeu::Cursors::Cursor, :toggle_cursor
161
-
162
- # @!method hide_group
163
- # @see Vedeu::Models::Group#hide
164
- def_delegators Vedeu::Models::Group, :hide_group
165
-
166
- # @!method show_group
167
- # @see Vedeu::Models::Group#show
168
- def_delegators Vedeu::Models::Group, :show_group
169
-
170
- # @!method toggle_group
171
- # @see Vedeu::Models::Group#toggle
172
- def_delegators Vedeu::Models::Group, :toggle_group
173
-
174
- # @!method hide_interface
175
- # @see Vedeu::Models::Interface#hide
176
- def_delegators Vedeu::Models::Interface, :hide_interface
177
-
178
- # @!method show_interface
179
- # @see Vedeu::Models::Interface#show
180
- def_delegators Vedeu::Models::Interface, :show_interface
181
-
182
- # @!method toggle_interface
183
- # @see Vedeu::Models::Interface#toggle
184
- def_delegators Vedeu::Models::Interface, :toggle_interface
185
-
186
- end # API
187
-
188
- extend API
189
-
190
- end # Vedeu
@@ -1,136 +0,0 @@
1
- module Vedeu
2
-
3
- module Buffers
4
-
5
- # Represents a {Vedeu::Terminal} view as a grid of
6
- # {Vedeu::Models::Cell} objects.
7
- #
8
- class VirtualBuffer
9
-
10
- # @!attribute [rw] renderer
11
- # @return [void]
12
- attr_accessor :renderer
13
-
14
- # @!attribute [r] height
15
- # @return [Fixnum]
16
- attr_reader :height
17
-
18
- # @!attribute [r] width
19
- # @return [Fixnum]
20
- attr_reader :width
21
-
22
- # @param data [Array<Array<Vedeu::Views::Char>>]
23
- # @return [Array<Array<Vedeu::Views::Char>>]
24
- # @see Vedeu::Buffers::VirtualBuffer#output
25
- def self.output(data)
26
- new(Vedeu.height, Vedeu.width, Vedeu::Renderers::HTML.new).output(data)
27
- end
28
-
29
- # Returns a new instance of Vedeu::Buffers::VirtualBuffer.
30
- #
31
- # @param height [Fixnum]
32
- # @param width [Fixnum]
33
- # @param renderer [Object|Vedeu::Renderers::HTML] An object
34
- # responding to .render.
35
- # @return [Vedeu::Buffers::VirtualBuffer]
36
- def initialize(height, width, renderer = Vedeu::Renderers::HTML.new)
37
- @height = height
38
- @width = width
39
- @renderer = renderer
40
- end
41
-
42
- # Return a grid of {Vedeu::Views::Char} objects defined by the
43
- # height and width of this virtual terminal.
44
- #
45
- # @return [Array<Array<Vedeu::Views::Char>>]
46
- def cells
47
- @cells ||= new_virtual_buffer
48
- end
49
-
50
- # Read a single cell from the virtual terminal.
51
- #
52
- # @note
53
- # Given two actual coordinates (y, x) e.g. (1, 1)
54
- # Convert to coordinate indices (cy, cx) e.g. (0, 0)
55
- # Fetch the row at cy and return the cell from cx
56
- #
57
- # @param y [Fixnum] The row/line coordinate.
58
- # @param x [Fixnum] The column/character coordinate.
59
- # @return [Vedeu::Views::Char]
60
- def read(y, x)
61
- cy, cx = Vedeu::Geometry::Position[y, x].as_indices
62
-
63
- row = fetch(cells, cy)
64
- cell = fetch(row, cx)
65
-
66
- cell
67
- end
68
-
69
- # Write a collection of cells to the virtual terminal.
70
- #
71
- # @param data [Array<Array<Vedeu::Views::Char>>]
72
- # @return [Array<Array<Vedeu::Views::Char>>]
73
- def output(data)
74
- Array(data).flatten.each do |char|
75
- write(char.y, char.x, char) if char.is_a?(Vedeu::Views::Char)
76
- end
77
-
78
- cells
79
- end
80
-
81
- # Send the cells to the renderer and return the rendered result.
82
- #
83
- # @return [String|void] Most likely to be a String.
84
- def render
85
- renderer.render(cells)
86
- end
87
-
88
- # Removes all content from the virtual terminal; effectively
89
- # clearing it.
90
- #
91
- # @return [Array<Array<Vedeu::Views::Char>>]
92
- def reset
93
- @cells = new_virtual_buffer
94
- end
95
- alias_method :clear, :reset
96
-
97
- # Write a single cell to the virtual terminal.
98
- #
99
- # @note
100
- # If the position (y, x) is nil; we're out of bounds.
101
- # Otherwise, write the data to (cy, cx).
102
- #
103
- # @param y [Fixnum] The row/line coordinate.
104
- # @param x [Fixnum] The column/character coordinate.
105
- # @param data [Vedeu::Views::Char]
106
- # @return [Vedeu::Views::Char]
107
- def write(y, x, data)
108
- return false unless read(y, x).is_a?(Vedeu::Models::Cell)
109
-
110
- cy, cx = Vedeu::Geometry::Position[y, x].as_indices
111
- cells[cy][cx] = data
112
-
113
- true
114
- end
115
-
116
- private
117
-
118
- # @param from [Array] An Array of rows, or an Array of cells.
119
- # @param which [Fixnum] A Fixnum representing the index; the row
120
- # number or the cell number for a row.
121
- # @return [Array<Vedeu::Views::Char>|Array]
122
- def fetch(from, which)
123
- from[which] || []
124
- end
125
-
126
- # @return [Array<Array<Vedeu::Models::Cell>>]
127
- # @see Vedeu::Buffers::VirtualBuffer#cells
128
- def new_virtual_buffer
129
- Array.new(height) { Array.new(width) { Vedeu::Models::Cell.new } }
130
- end
131
-
132
- end # VirtualBuffer
133
-
134
- end # Buffers
135
-
136
- end # Vedeu
@@ -1,77 +0,0 @@
1
- module Vedeu
2
-
3
- module Buffers
4
-
5
- # Store and retrieve {Vedeu::Buffers::VirtualBuffer} objects.
6
- #
7
- # Each {Vedeu::Buffers::VirtualBuffer} object is a copy of the
8
- # current terminal including content but not as String objects but
9
- # {Vedeu::Views::Char} objects. Using {Vedeu::Views::Char} objects
10
- # means that we can store the data used to make up the displayed
11
- # character, complete with its colour, position and style.
12
- #
13
- # Once a {Vedeu::Views::Char} has been converted to a String, it
14
- # is tricky to separate the escape sequences and string data. By
15
- # deferring this conversion we can display the
16
- # {Vedeu::Views::Char} in multiple ways (e.g. HTML) or in multiple
17
- # formats (e.g. JSON), and render/use that in an appropriate way.
18
- #
19
- module VirtualBuffers
20
-
21
- extend self
22
-
23
- # Fetch the oldest stored virtual buffer first.
24
- #
25
- # @return [Array<Array<Vedeu::Views::Char>>|NilClass]
26
- def retrieve
27
- Vedeu.log(type: :drb, message: 'Retrieving output')
28
-
29
- storage.pop
30
- end
31
-
32
- # Store a new virtual buffer.
33
- #
34
- # @return [Array<Array<Vedeu::Views::Char>>]
35
- def store(data)
36
- Vedeu.log(type: :drb, message: 'Storing output')
37
-
38
- storage.unshift(data)
39
- end
40
-
41
- # Return the number of virtual buffers currently stored.
42
- #
43
- # @return [Fixnum]
44
- def size
45
- storage.size
46
- end
47
-
48
- # Destroy all virtual buffers currently stored.
49
- #
50
- # @return [Array]
51
- def clear
52
- @storage = in_memory
53
- end
54
- alias_method :reset, :clear
55
-
56
- private
57
-
58
- # Access to the storage for this repository.
59
- #
60
- # @return [Array]
61
- def storage
62
- @storage ||= in_memory
63
- end
64
-
65
- # Returns an empty collection ready for the storing of virtual
66
- # buffers.
67
- #
68
- # @return [Array]
69
- def in_memory
70
- []
71
- end
72
-
73
- end # VirtualBuffers
74
-
75
- end # Buffers
76
-
77
- end # Vedeu
@@ -1,173 +0,0 @@
1
- module Vedeu
2
-
3
- # Vedeu's internal API methods provide convenient ways to access
4
- # Vedeu's internals. They are not supposed to be used by client
5
- # applications as they have limited value there.
6
- #
7
- module InternalAPI
8
-
9
- extend Forwardable
10
-
11
- module_function
12
-
13
- # Manipulate the repository of background colours.
14
- #
15
- # @example
16
- # Vedeu.background_colours
17
- #
18
- # @!method background_colours
19
- # @return [Vedeu::Colours::Backgrounds]
20
- def_delegators Vedeu::Colours::Backgrounds, :background_colours
21
-
22
- # Manipulate the repository of borders.
23
- #
24
- # @example
25
- # Vedeu.borders
26
- #
27
- # @!method borders
28
- # @return [Vedeu::Borders::Repository]
29
- def_delegators Vedeu::Borders::Repository, :borders
30
-
31
- # Manipulate the repository of buffers.
32
- #
33
- # @example
34
- # Vedeu.buffers
35
- #
36
- # @!method buffers
37
- # @return [Vedeu::Buffers::Repository]
38
- def_delegators Vedeu::Buffers::Repository, :buffers
39
-
40
- # Manipulate the repository of cursors.
41
- #
42
- # @example
43
- # Vedeu.cursors
44
- #
45
- # @!method cursors
46
- # @return [Vedeu::Cursors::Repository]
47
- def_delegators Vedeu::Cursors::Repository, :cursors
48
-
49
- # Allow debugging via the creation of stack traces courtesy of
50
- # ruby-prof.
51
- #
52
- # @example
53
- # Vedeu.debug
54
- #
55
- # @!method debug
56
- # @return [Vedeu::Logging::Debug]
57
- def_delegators Vedeu::Logging::Debug, :debug
58
-
59
- # Manipulate the repository of documents.
60
- #
61
- # @example
62
- # Vedeu.documents
63
- #
64
- # @!method documents
65
- # @return [Vedeu::Editor::Documents]
66
- def_delegators Vedeu::Editor::Documents, :documents
67
-
68
- # Manipulate the repository of events.
69
- #
70
- # @example
71
- # Vedeu.events
72
- #
73
- # @!method events
74
- # @return [Vedeu::Events::Repository]
75
- def_delegators Vedeu::Events::Repository, :events
76
-
77
- # Manipulate the repository of foreground colours.
78
- #
79
- # @example
80
- # Vedeu.foreground_colours
81
- #
82
- # @!method foreground_colours
83
- # @return [Vedeu::Colours::Foregrounds]
84
- def_delegators Vedeu::Colours::Foregrounds, :foreground_colours
85
-
86
- # Manipulate the repository of geometries.
87
- #
88
- # @example
89
- # Vedeu.geometries
90
- #
91
- # @!method geometries
92
- # @return [Vedeu::Geometry::Repository]
93
- def_delegators Vedeu::Geometry::Repository, :geometries
94
-
95
- # Manipulate the repository of groups.
96
- #
97
- # @example
98
- # Vedeu.groups
99
- #
100
- # @!method groups
101
- # @return [Vedeu::Models::Groups]
102
- def_delegators Vedeu::Models::Groups, :groups
103
-
104
- # Manipulate the repository of interfaces.
105
- #
106
- # @example
107
- # Vedeu.interfaces
108
- #
109
- # @!method interfaces
110
- # @return [Vedeu::Models::Interfaces]
111
- def_delegators Vedeu::Models::Interfaces, :interfaces
112
-
113
- # Manipulate the repository of keymaps.
114
- #
115
- # @example
116
- # Vedeu.keymaps
117
- #
118
- # @!method keymaps
119
- # @return [Vedeu::Input::Keymaps]
120
- def_delegators Vedeu::Input::Keymaps, :keymaps
121
-
122
- # Manipulate the repository of menus.
123
- #
124
- # @example
125
- # Vedeu.menus
126
- #
127
- # @!method menus
128
- # @return [Vedeu::Menus::Repository]
129
- def_delegators Vedeu::Menus::Repository, :menus
130
-
131
- # Manipulate the internal flags.
132
- #
133
- # @!method ready?
134
- # @!method ready!
135
- # @return [Boolean]
136
- def_delegators Vedeu::Runtime::Flags, :ready?, :ready!
137
-
138
- # @example
139
- # Vedeu.renderer
140
- # Vedeu.renderers
141
- #
142
- # @!method renderer
143
- # @see Vedeu::Renderers#renderer
144
- # @!method renderers
145
- # @see Vedeu::Renderers#renderers
146
- def_delegators Vedeu::Renderers, :renderer, :renderers
147
-
148
- # Instruct the terminal to resize. This will happen automatically
149
- # as the terminal recieves SIGWINCH signals.
150
- #
151
- # @example
152
- # Vedeu.resize
153
- #
154
- # @!method resize
155
- # @see Vedeu::Terminal#resize
156
- def_delegators Vedeu::Terminal, :resize
157
-
158
- # Measure the execution time of the code in the given block.
159
- #
160
- # @example
161
- # Vedeu.timer do
162
- # # ... some code here ...
163
- # end
164
- #
165
- # @!method timer
166
- # @see Vedeu::Logging::Timer.timer
167
- def_delegators Vedeu::Logging::Timer, :timer
168
-
169
- end # InternalAPI
170
-
171
- extend InternalAPI
172
-
173
- end # Vedeu