Class: Vedeu::Cursors::Refresh
- Inherits:
-
Object
- Object
- Vedeu::Cursors::Refresh
- Extended by:
- Forwardable
- Defined in:
- lib/vedeu/cursors/refresh.rb
Overview
Handle the refreshing (redrawing) of a cursor, without redrawing the whole interface; unless the cursor’s offset has caused the view to change.
Instance Attribute Summary collapse
- #name ⇒ String readonly protected
Class Method Summary collapse
Instance Method Summary collapse
-
#border ⇒ Object
private
Fetch the border by name.
-
#by_name ⇒ Array
Renders the cursor in the terminal.
- #cursor ⇒ Vedeu::Cursors::Cursor private
-
#initialize(name = nil) ⇒ Vedeu::Cursors::Refresh
constructor
Returns a new instance of Vedeu::Cursors::Refresh.
-
#refresh_view? ⇒ Boolean
private
Returns true when the view should be refreshed.
Constructor Details
#initialize(name = nil) ⇒ Vedeu::Cursors::Refresh
Returns a new instance of Vedeu::Cursors::Refresh.
26 27 28 |
# File 'lib/vedeu/cursors/refresh.rb', line 26 def initialize(name = nil) @name = name || Vedeu.focus end |
Instance Attribute Details
#name ⇒ String (readonly, protected)
48 49 50 |
# File 'lib/vedeu/cursors/refresh.rb', line 48 def name @name end |
Class Method Details
.by_name(name = nil) ⇒ Object
18 19 20 |
# File 'lib/vedeu/cursors/refresh.rb', line 18 def self.by_name(name = nil) new(name).by_name end |
Instance Method Details
#border ⇒ Object (private)
Borders::Border is used in this way because when there is not a border defined, it will fallback to a Borders::Null which uses Geometry::Geometry to determine it’s dimensions based on the name also. When a Geometry::Geometry cannot be found, this falls back to a Geometry::Null which uses the dimensions of the current terminal.
Fetch the border by name.
80 81 82 |
# File 'lib/vedeu/cursors/refresh.rb', line 80 def border @border ||= Vedeu.borders.by_name(name) end |
#by_name ⇒ Array
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.
36 37 38 39 40 41 42 |
# File 'lib/vedeu/cursors/refresh.rb', line 36 def by_name Vedeu.log(type: :info, message: "Refreshing cursor: '#{name}'") Vedeu.trigger(:_refresh_, name) if refresh_view? Vedeu::Terminal.output(cursor.to_s) end |
#cursor ⇒ Vedeu::Cursors::Cursor (private)
63 64 65 |
# File 'lib/vedeu/cursors/refresh.rb', line 63 def cursor @cursor ||= Vedeu.cursors.by_name(name) end |
#refresh_view? ⇒ Boolean (private)
Returns true when the view should be refreshed. This is determined by checking that the offsets for x and y are outside the width and height of the named interface.
57 58 59 |
# File 'lib/vedeu/cursors/refresh.rb', line 57 def refresh_view? cursor.ox >= width || cursor.oy >= height end |