Module: Vedeu::Buffers::Terminal

Extended by:
Terminal
Included in:
Terminal
Defined in:
lib/vedeu/buffers/terminal.rb

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

Instance Method Details

#bufferVedeu::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

#clearString|void

Returns:

  • (String|void)

    Most likely to be a String.



22
23
24
25
26
# File 'lib/vedeu/buffers/terminal.rb', line 22

def clear
  reset!

  Vedeu.renderers.clear
end

#outputVedeu::Models::Page

Returns the buffer content.

Examples:

Vedeu.trigger(:_drb_retrieve_output_)

Returns:



34
35
36
# File 'lib/vedeu/buffers/terminal.rb', line 34

def output
  Vedeu::Models::Page.coerce(buffer)
end

#refreshString|void

Returns:

  • (String|void)

    Most likely to be a String.



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.

Parameters:

Returns:



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.

Examples:

Vedeu.trigger(:_drb_store_output_, value_or_values)

Parameters:

Returns:



72
73
74
75
76
# File 'lib/vedeu/buffers/terminal.rb', line 72

def write(value_or_values)
  update(value_or_values)

  refresh
end