Class: Vedeu::Compositor Private

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/vedeu/output/compositor.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Combines stored interface layout/geometry with an interface view/buffer to create a single view to be sent to the terminal for output.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common

#defined_value?

Constructor Details

#initialize(name) ⇒ Compositor

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a new Compositor.

Parameters:

  • name (String)

    The name of the interface/buffer.



21
22
23
# File 'lib/vedeu/output/compositor.rb', line 21

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly, private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
# File 'lib/vedeu/output/compositor.rb', line 34

def name
  @name
end

Class Method Details

.render(name) ⇒ Compositor

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • name (String)

    The name of the interface/buffer.

Returns:



13
14
15
# File 'lib/vedeu/output/compositor.rb', line 13

def self.render(name)
  new(name).render
end

Instance Method Details

#bufferHash (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the attributes of the latest buffer (view).

Returns:

  • (Hash)


76
77
78
# File 'lib/vedeu/output/compositor.rb', line 76

def buffer
  @_buffer ||= Vedeu::Buffers.latest(name)
end

#interfaceHash (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the attributes of the named interface (layout).

Returns:

  • (Hash)


68
69
70
# File 'lib/vedeu/output/compositor.rb', line 68

def interface
  @_interface ||= Vedeu::Interfaces.find(name)
end

#new_interfaceHash (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Combine the buffer attributes with the interface attributes. Buffer presentation attributes will override interface defaults.

Returns:

  • (Hash)


56
57
58
59
60
61
62
# File 'lib/vedeu/output/compositor.rb', line 56

def new_interface
  combined = interface
  combined[:lines]  = buffer[:lines]
  combined[:colour] = buffer[:colour] if defined_value?(buffer[:colour])
  combined[:style]  = buffer[:style]  if defined_value?(buffer[:style])
  combined
end

#renderArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Send the view to the terminal.

Returns:

  • (Array)


28
29
30
# File 'lib/vedeu/output/compositor.rb', line 28

def render
  Terminal.output(view)
end

#viewString (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Renders the buffer unless empty, otherwise clears the area which the interface occupies.

Returns:

  • (String)


41
42
43
44
45
46
47
48
49
# File 'lib/vedeu/output/compositor.rb', line 41

def view
  if buffer
    Render.call(Interface.new(new_interface))

  else
    Clear.call(Interface.new(interface))

  end
end