Module: Vedeu::Buffers::Terminal
Overview
All output will be written to this singleton, and #render will be called at the end of each run of MainLoop; effectively rendering this buffer to each registered renderer. This buffer is not cleared after this action though, as subsequent actions will modify the contents. This means that individual parts of Vedeu can write content here at various points and only at the end of each run of MainLoop will it be actually output ‘somewhere’.
Instance Method Summary collapse
-
#buffer ⇒ Vedeu::Buffers::View
(also: #cells)
private
Return a grid of Cells::Empty objects defined by the height and width of this virtual terminal.
-
#clear ⇒ String|void
-
#output ⇒ Vedeu::Models::Page
Returns the buffer content.
-
#refresh ⇒ String|void
-
#reset! ⇒ Vedeu::Buffers::View
Removes all content from the virtual terminal; effectively clearing it.
-
#update(value_or_values) ⇒ Array<Array<Vedeu::Cells::Char>>
Write a collection of cells to the virtual terminal, but do not send to a renderer.
-
#write(value_or_values) ⇒ Array<Array<Vedeu::Cells::Char>>
Write a collection of cells to the virtual terminal, will then send written content to be rendered by a renderer.
Instance Method Details
#buffer ⇒ Vedeu::Buffers::View (private) Also known as: cells
Return a grid of Cells::Empty objects defined by the height and width of this virtual terminal.
84 85 86 |
# File 'lib/vedeu/buffers/terminal.rb', line 84 def buffer @buffer ||= Vedeu::Buffers::View.new(name: name) end |
#clear ⇒ String|void
22 23 24 25 26 |
# File 'lib/vedeu/buffers/terminal.rb', line 22 def clear reset! Vedeu.renderers.clear end |
#output ⇒ Vedeu::Models::Page
Returns the buffer content.
34 35 36 |
# File 'lib/vedeu/buffers/terminal.rb', line 34 def output Vedeu::Models::Page.coerce(buffer) end |
#refresh ⇒ String|void
40 41 42 |
# File 'lib/vedeu/buffers/terminal.rb', line 40 def refresh Vedeu.renderers.render(output) end |
#reset! ⇒ Vedeu::Buffers::View
Removes all content from the virtual terminal; effectively clearing it.
48 49 50 |
# File 'lib/vedeu/buffers/terminal.rb', line 48 def reset! @buffer = buffer.reset! end |
#update(value_or_values) ⇒ Array<Array<Vedeu::Cells::Char>>
Write a collection of cells to the virtual terminal, but do not send to a renderer.
57 58 59 |
# File 'lib/vedeu/buffers/terminal.rb', line 57 def update(value_or_values) buffer.update(value_or_values) end |
#write(value_or_values) ⇒ Array<Array<Vedeu::Cells::Char>>
Write a collection of cells to the virtual terminal, will then send written content to be rendered by a renderer. This method is used internally by Vedeu, but can be triggered in DRb mode pushing the given data in to the virtual buffer of the running client application as per the example.
72 73 74 75 76 |
# File 'lib/vedeu/buffers/terminal.rb', line 72 def write(value_or_values) update(value_or_values) refresh end |