lib/vedeu/cursors/refresh.rb in vedeu-0.6.42 vs lib/vedeu/cursors/refresh.rb in vedeu-0.6.43

- old
+ new

@@ -19,50 +19,52 @@ # Vedeu.trigger(:_refresh_cursor_, name) # # @param (see #initialize) # @return (see #by_name) def self.by_name(name = Vedeu.focus) - name || Vedeu.focus - new(name).by_name end # Returns a new instance of Vedeu::Cursors::Refresh. # # @param name [String|Symbol] The name of the interface/view # cursor to be refreshed. Defaults to `Vedeu.focus`. # @return [Vedeu::Cursors::Refresh] def initialize(name) - @name = present?(name) ? name : Vedeu.focus + @name = name end # 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. # # @return [Array] def by_name - Vedeu.trigger(:_refresh_view_content_, name) if refresh_view? + refresh_view if refresh_view? cursor.render end - protected + private - # @!attribute [r] name # @return [String|Symbol] - attr_reader :name + def name + present?(@name) ? @name : Vedeu.focus + end - private + # @return [void] + def refresh_view + Vedeu.trigger(:_refresh_view_content_, name) + end # 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. # # @return [Boolean] def refresh_view? - cursor.ox >= width || cursor.oy >= height + cursor.visible? && cursor.ox >= width || cursor.oy >= height end # @return [Vedeu::Cursors::Cursor] # @see Vedeu::Cursors::Repository#by_name def cursor