Class: Vedeu::Cursors::Refresh Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Vedeu::Common
Defined in:
lib/vedeu/cursors/refresh.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.

Handle the refreshing (redrawing) of a cursor, without redrawing the whole interface; unless the cursor’s offset has caused the view to change.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Vedeu::Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Constructor Details

#initialize(name) ⇒ Vedeu::Cursors::Refresh

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 a new instance of Vedeu::Cursors::Refresh.

Parameters:

  • name (NilClass|Symbol|String)

    The name of the model or target model to act upon. May default to ‘Vedeu.focus`.



44
45
46
# File 'lib/vedeu/cursors/refresh.rb', line 44

def initialize(name)
  @name = name
end

Class Method Details

.by_name(name = Vedeu.focus) ⇒ Array

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.

Examples:

Vedeu.trigger(:_refresh_cursor_, name)

Parameters:

  • name (NilClass|Symbol|String) (defaults to: Vedeu.focus)

    The name of the model or target model to act upon. May default to ‘Vedeu.focus`.

Returns:

  • (Array)


36
37
38
# File 'lib/vedeu/cursors/refresh.rb', line 36

def self.by_name(name = Vedeu.focus)
  new(name).by_name
end

Instance Method Details

#by_nameArray

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 cursor in the terminal. If the cursor’s x or y offsets are greater or equal to the interface’s width or height respectively, then the view is also refreshed, causing the content to be offset also.

Returns:

  • (Array)


54
55
56
57
58
59
60
61
62
# File 'lib/vedeu/cursors/refresh.rb', line 54

def by_name
  Vedeu.trigger(:_refresh_view_content_, name) if refresh_view?

  Vedeu.log(type:    :cursor,
            message: "Refreshing cursor: '#{name}' (x:#{x}, y:#{y}, " \
                     "ox:#{ox}, oy:#{oy}, visible:#{visible})")

  render
end

#cursorVedeu::Cursors::Cursor (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:

See Also:

  • Vedeu::Cursors::Repository#by_name


83
84
85
# File 'lib/vedeu/cursors/refresh.rb', line 83

def cursor
  @cursor ||= Vedeu.cursors.by_name(name)
end

#geometryObject (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.

Fetch the geometry by name.



90
91
92
# File 'lib/vedeu/cursors/refresh.rb', line 90

def geometry
  @geometry ||= Vedeu.geometries.by_name(name)
end

#nameString|Symbol (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:

  • (String|Symbol)


67
68
69
# File 'lib/vedeu/cursors/refresh.rb', line 67

def name
  present?(@name) ? @name : Vedeu.focus
end

#refresh_view?Boolean (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 true when the view should be refreshed. This is determined by checking that the offsets for x and y are outside the (bordered) width and (bordered) height of the named interface.

Returns:



77
78
79
# File 'lib/vedeu/cursors/refresh.rb', line 77

def refresh_view?
  visible? && (ox >= bordered_width || oy >= bordered_height)
end