vedeu 0.6.61 → 0.6.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/benchmarks/array_vs_range.rb +1 -1
- data/docs/events/drb.md +2 -2
- data/docs/events/visibility.md +1 -1
- data/lib/vedeu/buffers/all.rb +1 -0
- data/lib/vedeu/buffers/empty.rb +2 -2
- data/lib/vedeu/{terminal/buffer.rb → buffers/terminal.rb} +12 -16
- data/lib/vedeu/cursors/cursor.rb +4 -8
- data/lib/vedeu/cursors/refresh.rb +5 -0
- data/lib/vedeu/editor/all.rb +1 -0
- data/lib/vedeu/editor/collection.rb +26 -0
- data/lib/vedeu/editor/document.rb +0 -8
- data/lib/vedeu/editor/line.rb +17 -47
- data/lib/vedeu/editor/lines.rb +22 -51
- data/lib/vedeu/geometries/geometry.rb +0 -6
- data/lib/vedeu/groups/group.rb +0 -6
- data/lib/vedeu/input/capture.rb +1 -1
- data/lib/vedeu/interfaces/clear.rb +1 -1
- data/lib/vedeu/logging/log.rb +5 -2
- data/lib/vedeu/models/focus.rb +4 -13
- data/lib/vedeu/output/compressor.rb +8 -4
- data/lib/vedeu/output/output.rb +3 -3
- data/lib/vedeu/output/renderers/all.rb +2 -2
- data/lib/vedeu/output/renderers/html.rb +1 -1
- data/lib/vedeu/output/renderers/json.rb +1 -1
- data/lib/vedeu/repositories/all.rb +1 -0
- data/lib/vedeu/repositories/assemblage.rb +57 -0
- data/lib/vedeu/repositories/collection.rb +1 -40
- data/lib/vedeu/repositories/model.rb +17 -0
- data/lib/vedeu/runtime/launcher.rb +5 -8
- data/lib/vedeu/terminal/all.rb +0 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/{terminal/buffer_test.rb → buffers/terminal_test.rb} +24 -50
- data/test/lib/vedeu/cursors/cursor_test.rb +0 -6
- data/test/lib/vedeu/editor/collection_test.rb +38 -0
- data/test/lib/vedeu/editor/document_test.rb +0 -16
- data/test/lib/vedeu/editor/line_test.rb +17 -75
- data/test/lib/vedeu/editor/lines_test.rb +21 -88
- data/test/lib/vedeu/geometries/geometry_test.rb +0 -6
- data/test/lib/vedeu/groups/group_test.rb +0 -6
- data/test/lib/vedeu/input/mouse_test.rb +1 -1
- data/test/lib/vedeu/logging/log_test.rb +3 -3
- data/test/lib/vedeu/models/focus_test.rb +62 -56
- data/test/lib/vedeu/output/output_test.rb +2 -2
- data/test/lib/vedeu/output/renderers/html_test.rb +2 -2
- data/test/lib/vedeu/output/renderers/json_test.rb +1 -1
- data/test/lib/vedeu/repositories/assemblage_test.rb +96 -0
- data/test/lib/vedeu/repositories/collection_test.rb +0 -54
- data/test/lib/vedeu/repositories/model_test.rb +15 -0
- data/vedeu.gemspec +1 -1
- metadata +13 -7
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 161b51ae0f6dddf89fe026875fa21b5bcbef0b63
         | 
| 4 | 
            +
              data.tar.gz: f724c3d3b35f703f2ba58800123628837fd7a8fa
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 66121dcb5d8c27bc23a7ec695a2eecf360dfe0946f7f0cb3cf85eb39682f6a0a683d14328987e3858807a8a3fbf75c3a440565ad0aa39c80d76eea9eea263396
         | 
| 7 | 
            +
              data.tar.gz: c21adb2837c843bbb19a8b60ced2f19fa76835417ed86a15f769153c9e212f5a8b98133a5cf47446a4ab1a212971bff37321f360c2697f7849f258abece2654b
         | 
| @@ -2,7 +2,7 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            # To test the suitability of using a range to determine a valid
         | 
| 4 4 | 
             
            # coordinate instead of the current array method as used in
         | 
| 5 | 
            -
            # Vedeu::Terminal | 
| 5 | 
            +
            # Vedeu::Buffers::Terminal#within_terminal_boundary?
         | 
| 6 6 | 
             
            #
         | 
| 7 7 | 
             
            # vedeu/benchmarks:spike/benchmarking$ ./array_vs_range.rb
         | 
| 8 8 | 
             
            # Calculating -------------------------------------
         | 
    
        data/docs/events/drb.md
    CHANGED
    
    | @@ -11,10 +11,10 @@ Note: See {Vedeu::Distributed::Server#input} for parameter details. | |
| 11 11 | 
             
                Vedeu.trigger(:_drb_input_, data, type)
         | 
| 12 12 |  | 
| 13 13 | 
             
            ### `:\_drb_retrieve_output\_`
         | 
| 14 | 
            -
            See {Vedeu::Terminal | 
| 14 | 
            +
            See {Vedeu::Buffers::Terminal#output}
         | 
| 15 15 |  | 
| 16 16 | 
             
            ### `:\_drb_store_output\_`
         | 
| 17 | 
            -
            See {Vedeu::Terminal | 
| 17 | 
            +
            See {Vedeu::Buffers::Terminal#write}
         | 
| 18 18 |  | 
| 19 19 | 
             
            ### `:\_drb_restart\_`
         | 
| 20 20 | 
             
            Use the DRb server to request the client application to restart.
         | 
    
        data/docs/events/visibility.md
    CHANGED
    
    
    
        data/lib/vedeu/buffers/all.rb
    CHANGED
    
    
    
        data/lib/vedeu/buffers/empty.rb
    CHANGED
    
    | @@ -17,9 +17,9 @@ module Vedeu | |
| 17 17 | 
             
                  # @return [Array<Array<Vedeu::Models::Cell>>]
         | 
| 18 18 | 
             
                  def buffer
         | 
| 19 19 | 
             
                    Array.new(height) do |y|
         | 
| 20 | 
            -
                       | 
| 20 | 
            +
                      if y > 0
         | 
| 21 21 | 
             
                        Array.new(width) do |x|
         | 
| 22 | 
            -
                          Vedeu::Models::Cell.new(name: name, position: [y, x])  | 
| 22 | 
            +
                          Vedeu::Models::Cell.new(name: name, position: [y, x]) if x > 0
         | 
| 23 23 | 
             
                        end.compact
         | 
| 24 24 | 
             
                      end
         | 
| 25 25 | 
             
                    end.compact
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            module Vedeu
         | 
| 2 2 |  | 
| 3 | 
            -
              module  | 
| 3 | 
            +
              module Buffers
         | 
| 4 4 |  | 
| 5 5 | 
             
                # All output will be written to this singleton, and #render will
         | 
| 6 6 | 
             
                # be called at the end of each run of {Vedeu::MainLoop};
         | 
| @@ -11,7 +11,7 @@ module Vedeu | |
| 11 11 | 
             
                # points and only at the end of each run of {Vedeu::MainLoop} will
         | 
| 12 12 | 
             
                # it be actually output 'somewhere'.
         | 
| 13 13 | 
             
                #
         | 
| 14 | 
            -
                module  | 
| 14 | 
            +
                module Terminal
         | 
| 15 15 |  | 
| 16 16 | 
             
                  extend self
         | 
| 17 17 |  | 
| @@ -66,8 +66,6 @@ module Vedeu | |
| 66 66 | 
             
                  # @return [Array<Array<Vedeu::Views::Char>>]
         | 
| 67 67 | 
             
                  def update(value_or_values)
         | 
| 68 68 | 
             
                    buffer.update(value_or_values)
         | 
| 69 | 
            -
             | 
| 70 | 
            -
                    self
         | 
| 71 69 | 
             
                  end
         | 
| 72 70 |  | 
| 73 71 | 
             
                  # Write a collection of cells to the virtual terminal, will
         | 
| @@ -79,14 +77,12 @@ module Vedeu | |
| 79 77 | 
             
                  # @example
         | 
| 80 78 | 
             
                  #   Vedeu.trigger(:_drb_store_output_, value_or_values)
         | 
| 81 79 | 
             
                  #
         | 
| 82 | 
            -
                  # @param  | 
| 80 | 
            +
                  # @param value_or_values [Array<Array<Vedeu::Views::Char>>]
         | 
| 83 81 | 
             
                  # @return [Array<Array<Vedeu::Views::Char>>]
         | 
| 84 82 | 
             
                  def write(value_or_values)
         | 
| 85 83 | 
             
                    buffer.update(value_or_values)
         | 
| 86 84 |  | 
| 87 85 | 
             
                    refresh
         | 
| 88 | 
            -
             | 
| 89 | 
            -
                    self
         | 
| 90 86 | 
             
                  end
         | 
| 91 87 |  | 
| 92 88 | 
             
                  private
         | 
| @@ -100,26 +96,26 @@ module Vedeu | |
| 100 96 | 
             
                  end
         | 
| 101 97 | 
             
                  alias_method :cells, :buffer
         | 
| 102 98 |  | 
| 103 | 
            -
                end #  | 
| 99 | 
            +
                end # Terminal
         | 
| 104 100 |  | 
| 105 | 
            -
              end #  | 
| 101 | 
            +
              end # Buffers
         | 
| 106 102 |  | 
| 107 103 | 
             
              # @!method clear
         | 
| 108 | 
            -
              #   @see Vedeu::Terminal | 
| 109 | 
            -
              def_delegators Vedeu::Terminal | 
| 104 | 
            +
              #   @see Vedeu::Buffers::Terminal#clear
         | 
| 105 | 
            +
              def_delegators Vedeu::Buffers::Terminal,
         | 
| 110 106 | 
             
                             :clear,
         | 
| 111 107 | 
             
                             :refresh
         | 
| 112 108 |  | 
| 113 109 | 
             
              # :nocov:
         | 
| 114 110 |  | 
| 115 | 
            -
              # @see Vedeu::Terminal | 
| 111 | 
            +
              # @see Vedeu::Buffers::Terminal#clear
         | 
| 116 112 | 
             
              Vedeu.bind(:_clear_) { Vedeu.clear }
         | 
| 117 113 |  | 
| 118 | 
            -
              # @see Vedeu::Terminal | 
| 119 | 
            -
              Vedeu.bind(:_drb_retrieve_output_) { Vedeu::Terminal | 
| 114 | 
            +
              # @see Vedeu::Buffers::Terminal#output
         | 
| 115 | 
            +
              Vedeu.bind(:_drb_retrieve_output_) { Vedeu::Buffers::Terminal.output }
         | 
| 120 116 |  | 
| 121 | 
            -
              # @see Vedeu::Terminal | 
| 122 | 
            -
              Vedeu.bind(:_drb_store_output_) { |data| Vedeu::Terminal | 
| 117 | 
            +
              # @see Vedeu::Buffers::Terminal#write
         | 
| 118 | 
            +
              Vedeu.bind(:_drb_store_output_) { |data| Vedeu::Buffers::Terminal.write(data) }
         | 
| 123 119 |  | 
| 124 120 | 
             
              # :nocov:
         | 
| 125 121 |  | 
    
        data/lib/vedeu/cursors/cursor.rb
    CHANGED
    
    | @@ -39,12 +39,6 @@ module Vedeu | |
| 39 39 | 
             
                  # @return [Fixnum]
         | 
| 40 40 | 
             
                  attr_writer :y
         | 
| 41 41 |  | 
| 42 | 
            -
                  # @param (see #initialize)
         | 
| 43 | 
            -
                  # @return [Vedeu::Cursors::Cursor]
         | 
| 44 | 
            -
                  def self.store(attributes = {})
         | 
| 45 | 
            -
                    new(attributes).store
         | 
| 46 | 
            -
                  end
         | 
| 47 | 
            -
             | 
| 48 42 | 
             
                  # Returns a new instance of Vedeu::Cursors::Cursor.
         | 
| 49 43 | 
             
                  #
         | 
| 50 44 | 
             
                  # @param attributes [Hash<Symbol => Boolean|Fixnum|String|
         | 
| @@ -162,8 +156,6 @@ module Vedeu | |
| 162 156 | 
             
                  #
         | 
| 163 157 | 
             
                  # @return [Array<Vedeu::Models::Escape>]
         | 
| 164 158 | 
             
                  def render
         | 
| 165 | 
            -
                    Vedeu.log(type: :output, message: "Refreshing cursor: '#{name}'".freeze)
         | 
| 166 | 
            -
             | 
| 167 159 | 
             
                    Vedeu.render_output(escape_sequence)
         | 
| 168 160 | 
             
                  end
         | 
| 169 161 |  | 
| @@ -199,6 +191,8 @@ module Vedeu | |
| 199 191 | 
             
                  def hide
         | 
| 200 192 | 
             
                    super
         | 
| 201 193 |  | 
| 194 | 
            +
                    Vedeu.log(type: :output, message: "Hiding cursor: '#{name}'".freeze)
         | 
| 195 | 
            +
             | 
| 202 196 | 
             
                    render
         | 
| 203 197 | 
             
                  end
         | 
| 204 198 |  | 
| @@ -234,6 +228,8 @@ module Vedeu | |
| 234 228 | 
             
                  def show
         | 
| 235 229 | 
             
                    super
         | 
| 236 230 |  | 
| 231 | 
            +
                    Vedeu.log(type: :output, message: "Showing cursor: '#{name}'".freeze)
         | 
| 232 | 
            +
             | 
| 237 233 | 
             
                    render
         | 
| 238 234 | 
             
                  end
         | 
| 239 235 |  | 
| @@ -44,6 +44,11 @@ module Vedeu | |
| 44 44 | 
             
                  def by_name
         | 
| 45 45 | 
             
                    refresh_view if refresh_view?
         | 
| 46 46 |  | 
| 47 | 
            +
                    Vedeu.log(type:    :output,
         | 
| 48 | 
            +
                              message: "Refreshing cursor: '#{name}' (x:#{cursor.x}, " \
         | 
| 49 | 
            +
                                       "y:#{cursor.y}, ox:#{cursor.ox}, oy:#{cursor.oy}, " \
         | 
| 50 | 
            +
                                       "visible:#{cursor.visible})".freeze)
         | 
| 51 | 
            +
             | 
| 47 52 | 
             
                    cursor.render
         | 
| 48 53 | 
             
                  end
         | 
| 49 54 |  | 
    
        data/lib/vedeu/editor/all.rb
    CHANGED
    
    
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            module Vedeu
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              module Editor
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                # Used by {Vedeu::Editor::Lines} and {Vedeu::Editor::Line} to
         | 
| 6 | 
            +
                # fetch an item from the respective collection.
         | 
| 7 | 
            +
                #
         | 
| 8 | 
            +
                # @api private
         | 
| 9 | 
            +
                #
         | 
| 10 | 
            +
                module Collection
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  include Vedeu::Repositories::Assemblage
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  # Fetches an item from a collection.
         | 
| 15 | 
            +
                  #
         | 
| 16 | 
            +
                  # @param index [Fixnum]
         | 
| 17 | 
            +
                  # @return [String]
         | 
| 18 | 
            +
                  def by_index(index)
         | 
| 19 | 
            +
                    Vedeu::Editor::Item.by_index(collection, index)
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                end # Collection
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              end # Editor
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            end # Vedeu
         | 
| @@ -31,14 +31,6 @@ module Vedeu | |
| 31 31 | 
             
                  # @return [String|Symbol]
         | 
| 32 32 | 
             
                  attr_accessor :name
         | 
| 33 33 |  | 
| 34 | 
            -
                  # Store an instance of this class with its repository.
         | 
| 35 | 
            -
                  #
         | 
| 36 | 
            -
                  # @param (see #initialize)
         | 
| 37 | 
            -
                  # @return (see #initialize)
         | 
| 38 | 
            -
                  def self.store(attributes = {})
         | 
| 39 | 
            -
                    new(attributes).store
         | 
| 40 | 
            -
                  end
         | 
| 41 | 
            -
             | 
| 42 34 | 
             
                  # Returns the document as a string with line breaks if there is
         | 
| 43 35 | 
             
                  # more than one line.
         | 
| 44 36 | 
             
                  #
         | 
    
        data/lib/vedeu/editor/line.rb
    CHANGED
    
    | @@ -8,37 +8,31 @@ module Vedeu | |
| 8 8 | 
             
                #
         | 
| 9 9 | 
             
                class Line
         | 
| 10 10 |  | 
| 11 | 
            -
                   | 
| 11 | 
            +
                  include Vedeu::Editor::Collection
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  # @!attribute [rw] collection
         | 
| 12 14 | 
             
                  # @return [String]
         | 
| 13 | 
            -
                  attr_accessor : | 
| 14 | 
            -
                  alias_method : | 
| 15 | 
            +
                  attr_accessor :collection
         | 
| 16 | 
            +
                  alias_method :line, :collection
         | 
| 17 | 
            +
                  alias_method :to_s, :collection
         | 
| 15 18 |  | 
| 16 19 | 
             
                  # Coerce a line into a new instance of Vedeu::Editor::Line.
         | 
| 17 20 | 
             
                  #
         | 
| 18 | 
            -
                  # @param  | 
| 21 | 
            +
                  # @param collection [String|Vedeu::Editor::Line]
         | 
| 19 22 | 
             
                  # @return (see #initialize)
         | 
| 20 | 
            -
                  def self.coerce( | 
| 21 | 
            -
                    return  | 
| 22 | 
            -
                    return new( | 
| 23 | 
            +
                  def self.coerce(collection)
         | 
| 24 | 
            +
                    return collection      if collection.is_a?(self)
         | 
| 25 | 
            +
                    return new(collection) if collection.is_a?(String)
         | 
| 23 26 |  | 
| 24 27 | 
             
                    new
         | 
| 25 28 | 
             
                  end
         | 
| 26 29 |  | 
| 27 30 | 
             
                  # Returns a new instance of Vedeu::Editor::Line.
         | 
| 28 31 | 
             
                  #
         | 
| 29 | 
            -
                  # @param  | 
| 32 | 
            +
                  # @param collection [String|NilClass]
         | 
| 30 33 | 
             
                  # @return [Vedeu::Editor::Line]
         | 
| 31 | 
            -
                  def initialize( | 
| 32 | 
            -
                    @ | 
| 33 | 
            -
                  end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                  # Return a character or collection of characters (if index is a
         | 
| 36 | 
            -
                  # Range).
         | 
| 37 | 
            -
                  #
         | 
| 38 | 
            -
                  # @param index [Fixnum|Range]
         | 
| 39 | 
            -
                  # @return [String]
         | 
| 40 | 
            -
                  def [](index)
         | 
| 41 | 
            -
                    line[index]
         | 
| 34 | 
            +
                  def initialize(collection = nil)
         | 
| 35 | 
            +
                    @collection = collection || ''
         | 
| 42 36 | 
             
                  end
         | 
| 43 37 |  | 
| 44 38 | 
             
                  # Return the character at the given index.
         | 
| @@ -46,10 +40,10 @@ module Vedeu | |
| 46 40 | 
             
                  # @param index [Fixnum|NilClass]
         | 
| 47 41 | 
             
                  # @return [String|NilClass]
         | 
| 48 42 | 
             
                  def character(index = nil)
         | 
| 49 | 
            -
                    return '' | 
| 50 | 
            -
                    return  | 
| 43 | 
            +
                    return ''             if collection && collection.empty?
         | 
| 44 | 
            +
                    return collection[-1] unless index
         | 
| 51 45 |  | 
| 52 | 
            -
                     | 
| 46 | 
            +
                    by_index(index)
         | 
| 53 47 | 
             
                  end
         | 
| 54 48 |  | 
| 55 49 | 
             
                  # Delete the character from the line positioned at the given
         | 
| @@ -62,23 +56,6 @@ module Vedeu | |
| 62 56 | 
             
                                               .from(line, index, size))
         | 
| 63 57 | 
             
                  end
         | 
| 64 58 |  | 
| 65 | 
            -
                  # Returns a boolean indicating whether there are characters on
         | 
| 66 | 
            -
                  # this line.
         | 
| 67 | 
            -
                  #
         | 
| 68 | 
            -
                  # @return [Boolean]
         | 
| 69 | 
            -
                  def empty?
         | 
| 70 | 
            -
                    line.empty?
         | 
| 71 | 
            -
                  end
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                  # An object is equal when its values are the same.
         | 
| 74 | 
            -
                  #
         | 
| 75 | 
            -
                  # @param other [Vedeu::Editor::Line]
         | 
| 76 | 
            -
                  # @return [Boolean]
         | 
| 77 | 
            -
                  def eql?(other)
         | 
| 78 | 
            -
                    self.class == other.class && line == other.line
         | 
| 79 | 
            -
                  end
         | 
| 80 | 
            -
                  alias_method :==, :eql?
         | 
| 81 | 
            -
             | 
| 82 59 | 
             
                  # Insert the character on the line positioned at the given
         | 
| 83 60 | 
             
                  # index.
         | 
| 84 61 | 
             
                  #
         | 
| @@ -89,14 +66,7 @@ module Vedeu | |
| 89 66 | 
             
                    return self unless character
         | 
| 90 67 |  | 
| 91 68 | 
             
                    Vedeu::Editor::Line.coerce(Vedeu::Editor::Insert
         | 
| 92 | 
            -
                                               .into( | 
| 93 | 
            -
                  end
         | 
| 94 | 
            -
             | 
| 95 | 
            -
                  # Return the size of the line in characters.
         | 
| 96 | 
            -
                  #
         | 
| 97 | 
            -
                  # @return [Fixnum]
         | 
| 98 | 
            -
                  def size
         | 
| 99 | 
            -
                    line.size
         | 
| 69 | 
            +
                                               .into(collection, character, index, size))
         | 
| 100 70 | 
             
                  end
         | 
| 101 71 |  | 
| 102 72 | 
             
                end # Line
         | 
    
        data/lib/vedeu/editor/lines.rb
    CHANGED
    
    | @@ -9,10 +9,12 @@ module Vedeu | |
| 9 9 | 
             
                class Lines
         | 
| 10 10 |  | 
| 11 11 | 
             
                  include Enumerable
         | 
| 12 | 
            +
                  include Vedeu::Editor::Collection
         | 
| 12 13 |  | 
| 13 | 
            -
                  # @!attribute [rw]  | 
| 14 | 
            +
                  # @!attribute [rw] collection
         | 
| 14 15 | 
             
                  # @return [String]
         | 
| 15 | 
            -
                  attr_accessor : | 
| 16 | 
            +
                  attr_accessor :collection
         | 
| 17 | 
            +
                  alias_method :lines, :collection
         | 
| 16 18 |  | 
| 17 19 | 
             
                  # Coerce a document into a new instance of Vedeu::Editor::Lines.
         | 
| 18 20 | 
             
                  #
         | 
| @@ -23,16 +25,16 @@ module Vedeu | |
| 23 25 | 
             
                      new(document.lines)
         | 
| 24 26 |  | 
| 25 27 | 
             
                    elsif document.is_a?(Array)
         | 
| 26 | 
            -
                       | 
| 28 | 
            +
                      collection = document.map { |line| Vedeu::Editor::Line.coerce(line) }
         | 
| 27 29 |  | 
| 28 | 
            -
                      new( | 
| 30 | 
            +
                      new(collection)
         | 
| 29 31 |  | 
| 30 32 | 
             
                    elsif document.is_a?(String)
         | 
| 31 | 
            -
                       | 
| 33 | 
            +
                      collection = document.lines.map(&:chomp).map do |line|
         | 
| 32 34 | 
             
                        Vedeu::Editor::Line.coerce(line)
         | 
| 33 35 | 
             
                      end
         | 
| 34 36 |  | 
| 35 | 
            -
                      new( | 
| 37 | 
            +
                      new(collection)
         | 
| 36 38 |  | 
| 37 39 | 
             
                    else
         | 
| 38 40 | 
             
                      new
         | 
| @@ -42,18 +44,10 @@ module Vedeu | |
| 42 44 |  | 
| 43 45 | 
             
                  # Returns a new instance of Vedeu::Editor::Lines.
         | 
| 44 46 | 
             
                  #
         | 
| 45 | 
            -
                  # @param  | 
| 47 | 
            +
                  # @param collection [Array<String>|NilClass]
         | 
| 46 48 | 
             
                  # @return [Vedeu::Editor::Lines]
         | 
| 47 | 
            -
                  def initialize( | 
| 48 | 
            -
                    @ | 
| 49 | 
            -
                  end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                  # Return a line or collection of lines (if index is a Range).
         | 
| 52 | 
            -
                  #
         | 
| 53 | 
            -
                  # @param index [Fixnum|Range]
         | 
| 54 | 
            -
                  # @return [Vedeu::Editor::Line]
         | 
| 55 | 
            -
                  def [](index)
         | 
| 56 | 
            -
                    lines[index]
         | 
| 49 | 
            +
                  def initialize(collection = nil)
         | 
| 50 | 
            +
                    @collection = collection || []
         | 
| 57 51 | 
             
                  end
         | 
| 58 52 |  | 
| 59 53 | 
             
                  # Deletes the character from the line where the cursor is
         | 
| @@ -63,9 +57,9 @@ module Vedeu | |
| 63 57 | 
             
                  # @param x [Fixnum]
         | 
| 64 58 | 
             
                  # @return [Vedeu::Editor::Lines]
         | 
| 65 59 | 
             
                  def delete_character(y, x)
         | 
| 66 | 
            -
                     | 
| 60 | 
            +
                    collection[y] = line(y).delete_character(x) unless line(y).empty?
         | 
| 67 61 |  | 
| 68 | 
            -
                    Vedeu::Editor::Lines.coerce( | 
| 62 | 
            +
                    Vedeu::Editor::Lines.coerce(collection)
         | 
| 69 63 | 
             
                  end
         | 
| 70 64 |  | 
| 71 65 | 
             
                  # Delete the line from the lines positioned at the given index.
         | 
| @@ -82,25 +76,9 @@ module Vedeu | |
| 82 76 | 
             
                  # @param block [Proc]
         | 
| 83 77 | 
             
                  # @return [Enumerator]
         | 
| 84 78 | 
             
                  def each(&block)
         | 
| 85 | 
            -
                     | 
| 86 | 
            -
                  end
         | 
| 87 | 
            -
             | 
| 88 | 
            -
                  # Returns a boolean indicating whether there are lines.
         | 
| 89 | 
            -
                  #
         | 
| 90 | 
            -
                  # @return [Boolean]
         | 
| 91 | 
            -
                  def empty?
         | 
| 92 | 
            -
                    lines.empty?
         | 
| 79 | 
            +
                    collection.each(&block)
         | 
| 93 80 | 
             
                  end
         | 
| 94 81 |  | 
| 95 | 
            -
                  # An object is equal when its values are the same.
         | 
| 96 | 
            -
                  #
         | 
| 97 | 
            -
                  # @param other [Vedeu::Editor::Lines]
         | 
| 98 | 
            -
                  # @return [Boolean]
         | 
| 99 | 
            -
                  def eql?(other)
         | 
| 100 | 
            -
                    self.class == other.class && lines == other.lines
         | 
| 101 | 
            -
                  end
         | 
| 102 | 
            -
                  alias_method :==, :eql?
         | 
| 103 | 
            -
             | 
| 104 82 | 
             
                  # Insert a character in to a line.
         | 
| 105 83 | 
             
                  #
         | 
| 106 84 | 
             
                  # @param character [String]
         | 
| @@ -108,9 +86,9 @@ module Vedeu | |
| 108 86 | 
             
                  # @param x [Fixnum]
         | 
| 109 87 | 
             
                  # @return [Vedeu::Editor::Lines]
         | 
| 110 88 | 
             
                  def insert_character(character, y, x)
         | 
| 111 | 
            -
                     | 
| 89 | 
            +
                    collection[y] = line(y).insert_character(character, x)
         | 
| 112 90 |  | 
| 113 | 
            -
                    Vedeu::Editor::Lines.coerce( | 
| 91 | 
            +
                    Vedeu::Editor::Lines.coerce(collection)
         | 
| 114 92 | 
             
                  end
         | 
| 115 93 |  | 
| 116 94 | 
             
                  # Insert the line on the line below the given index.
         | 
| @@ -119,7 +97,7 @@ module Vedeu | |
| 119 97 | 
             
                  # @return [Vedeu::Editor::Lines]
         | 
| 120 98 | 
             
                  def insert_line(index = nil)
         | 
| 121 99 | 
             
                    Vedeu::Editor::Lines.coerce(
         | 
| 122 | 
            -
                      Vedeu::Editor::Insert.into( | 
| 100 | 
            +
                      Vedeu::Editor::Insert.into(collection,
         | 
| 123 101 | 
             
                                                 Vedeu::Editor::Line.new,
         | 
| 124 102 | 
             
                                                 index,
         | 
| 125 103 | 
             
                                                 size))
         | 
| @@ -130,27 +108,20 @@ module Vedeu | |
| 130 108 | 
             
                  # @param index [Fixnum|NilClass]
         | 
| 131 109 | 
             
                  # @return [Vedeu::Editor::Line]
         | 
| 132 110 | 
             
                  def line(index = nil)
         | 
| 133 | 
            -
                    return Vedeu::Editor::Line.new unless  | 
| 134 | 
            -
                    return Vedeu::Editor::Line.coerce( | 
| 111 | 
            +
                    return Vedeu::Editor::Line.new unless collection
         | 
| 112 | 
            +
                    return Vedeu::Editor::Line.coerce(collection[-1]) unless index
         | 
| 135 113 |  | 
| 136 | 
            -
                    Vedeu::Editor::Line.coerce( | 
| 137 | 
            -
                  end
         | 
| 138 | 
            -
             | 
| 139 | 
            -
                  # Return the number of lines.
         | 
| 140 | 
            -
                  #
         | 
| 141 | 
            -
                  # @return [Fixnum]
         | 
| 142 | 
            -
                  def size
         | 
| 143 | 
            -
                    lines.size
         | 
| 114 | 
            +
                    Vedeu::Editor::Line.coerce(by_index(index))
         | 
| 144 115 | 
             
                  end
         | 
| 145 116 |  | 
| 146 117 | 
             
                  # Return the lines as a string.
         | 
| 147 118 | 
             
                  #
         | 
| 148 119 | 
             
                  # @return [String]
         | 
| 149 120 | 
             
                  def to_s
         | 
| 150 | 
            -
                     | 
| 121 | 
            +
                    collection.map(&:to_s).join
         | 
| 151 122 | 
             
                  end
         | 
| 152 123 |  | 
| 153 | 
            -
                end #  | 
| 124 | 
            +
                end # Lines
         | 
| 154 125 |  | 
| 155 126 | 
             
              end # Editor
         | 
| 156 127 |  | 
| @@ -82,12 +82,6 @@ module Vedeu | |
| 82 82 | 
             
                  # @return [Object]
         | 
| 83 83 | 
             
                  attr_accessor :client
         | 
| 84 84 |  | 
| 85 | 
            -
                  # @param (see #initialize)
         | 
| 86 | 
            -
                  # @return (see #initialize)
         | 
| 87 | 
            -
                  def self.store(attributes, &block)
         | 
| 88 | 
            -
                    new(attributes).store(&block)
         | 
| 89 | 
            -
                  end
         | 
| 90 | 
            -
             | 
| 91 85 | 
             
                  # Returns a new instance of Vedeu::Geometries::Geometry.
         | 
| 92 86 | 
             
                  #
         | 
| 93 87 | 
             
                  # @param attributes [Hash<Symbol => Boolean|Fixnum|String|
         | 
    
        data/lib/vedeu/groups/group.rb
    CHANGED
    
    | @@ -14,12 +14,6 @@ module Vedeu | |
| 14 14 | 
             
                  # @return [String]
         | 
| 15 15 | 
             
                  attr_accessor :name
         | 
| 16 16 |  | 
| 17 | 
            -
                  # @param (see #initialize)
         | 
| 18 | 
            -
                  # @return (see #initialize)
         | 
| 19 | 
            -
                  def self.store(attributes = {})
         | 
| 20 | 
            -
                    new(attributes).store
         | 
| 21 | 
            -
                  end
         | 
| 22 | 
            -
             | 
| 23 17 | 
             
                  # Return a new instance of Vedeu::Groups::Group.
         | 
| 24 18 | 
             
                  #
         | 
| 25 19 | 
             
                  # @note
         | 
    
        data/lib/vedeu/input/capture.rb
    CHANGED
    
    | @@ -107,7 +107,7 @@ module Vedeu | |
| 107 107 | 
             
                  # Returns a boolean indicating whether a mouse click was
         | 
| 108 108 | 
             
                  # received.
         | 
| 109 109 | 
             
                  #
         | 
| 110 | 
            -
                  # @param  | 
| 110 | 
            +
                  # @param input [NilClass|String|Symbol|Vedeu::Cursors::Cursor]
         | 
| 111 111 | 
             
                  # @return [Boolean]
         | 
| 112 112 | 
             
                  def click?(input)
         | 
| 113 113 | 
             
                    return false if input.nil? || input.is_a?(Symbol)
         | 
    
        data/lib/vedeu/logging/log.rb
    CHANGED
    
    | @@ -135,7 +135,7 @@ module Vedeu | |
| 135 135 | 
             
                    def message_type(type)
         | 
| 136 136 | 
             
                      Vedeu::EscapeSequences::Esc
         | 
| 137 137 | 
             
                        .send(message_types.fetch(type, :default)[0]) do
         | 
| 138 | 
            -
                        "[#{type}]".ljust( | 
| 138 | 
            +
                        "[#{type}]".ljust(11)
         | 
| 139 139 | 
             
                      end
         | 
| 140 140 | 
             
                    end
         | 
| 141 141 |  | 
| @@ -170,7 +170,10 @@ module Vedeu | |
| 170 170 | 
             
                        debug:  [:white, :light_grey],
         | 
| 171 171 |  | 
| 172 172 | 
             
                        input:  [:light_yellow, :yellow],
         | 
| 173 | 
            -
             | 
| 173 | 
            +
             | 
| 174 | 
            +
                        compress: [:white, :light_grey],
         | 
| 175 | 
            +
                        output:   [:light_green, :green],
         | 
| 176 | 
            +
                        render:   [:light_green, :green],
         | 
| 174 177 |  | 
| 175 178 | 
             
                        error:  [:light_red, :red],
         | 
| 176 179 |  | 
    
        data/lib/vedeu/models/focus.rb
    CHANGED
    
    | @@ -169,15 +169,13 @@ module Vedeu | |
| 169 169 | 
             
                    Vedeu.trigger(:_refresh_cursor_, current)
         | 
| 170 170 | 
             
                  end
         | 
| 171 171 |  | 
| 172 | 
            -
                  #  | 
| 173 | 
            -
                  # entities.
         | 
| 172 | 
            +
                  # Access to the storage for this repository.
         | 
| 174 173 | 
             
                  #
         | 
| 175 174 | 
             
                  # @return [Array]
         | 
| 176 | 
            -
                  def  | 
| 177 | 
            -
                     | 
| 178 | 
            -
             | 
| 179 | 
            -
                    storage
         | 
| 175 | 
            +
                  def storage
         | 
| 176 | 
            +
                    @storage ||= in_memory
         | 
| 180 177 | 
             
                  end
         | 
| 178 | 
            +
                  alias_method :registered, :storage
         | 
| 181 179 |  | 
| 182 180 | 
             
                  # Returns a boolean indicating whether the named model is
         | 
| 183 181 | 
             
                  # registered.
         | 
| @@ -229,13 +227,6 @@ module Vedeu | |
| 229 227 | 
             
                    current
         | 
| 230 228 | 
             
                  end
         | 
| 231 229 |  | 
| 232 | 
            -
                  # Access to the storage for this repository.
         | 
| 233 | 
            -
                  #
         | 
| 234 | 
            -
                  # @return [Array]
         | 
| 235 | 
            -
                  def storage
         | 
| 236 | 
            -
                    @storage ||= in_memory
         | 
| 237 | 
            -
                  end
         | 
| 238 | 
            -
             | 
| 239 230 | 
             
                  # Returns an empty collection ready for the storing of interface
         | 
| 240 231 | 
             
                  # names.
         | 
| 241 232 | 
             
                  #
         | 
| @@ -51,9 +51,13 @@ module Vedeu | |
| 51 51 |  | 
| 52 52 | 
             
                  # @return [Array]
         | 
| 53 53 | 
             
                  def content
         | 
| 54 | 
            -
                     | 
| 54 | 
            +
                    @content ||= if present?(output)
         | 
| 55 | 
            +
                                   output.content.reject(&:cell?)
         | 
| 55 56 |  | 
| 56 | 
            -
             | 
| 57 | 
            +
                                 else
         | 
| 58 | 
            +
                                   []
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                                 end
         | 
| 57 61 | 
             
                  end
         | 
| 58 62 |  | 
| 59 63 | 
             
                  # @return [String]
         | 
| @@ -69,7 +73,7 @@ module Vedeu | |
| 69 73 | 
             
                        ].join
         | 
| 70 74 | 
             
                      end.join
         | 
| 71 75 |  | 
| 72 | 
            -
                      Vedeu.log(type:    : | 
| 76 | 
            +
                      Vedeu.log(type:    :compress,
         | 
| 73 77 | 
             
                                message: "Compression: #{content.size} objects -> " \
         | 
| 74 78 | 
             
                                         "#{out.size} characters".freeze)
         | 
| 75 79 |  | 
| @@ -81,7 +85,7 @@ module Vedeu | |
| 81 85 | 
             
                  def uncompress
         | 
| 82 86 | 
             
                    out = content.map(&:to_s).join
         | 
| 83 87 |  | 
| 84 | 
            -
                    Vedeu.log(type:    : | 
| 88 | 
            +
                    Vedeu.log(type:    :compress,
         | 
| 85 89 | 
             
                              message: "No compression: #{content.size} objects -> " \
         | 
| 86 90 | 
             
                                       "#{out.size} characters".freeze)
         | 
| 87 91 |  | 
    
        data/lib/vedeu/output/output.rb
    CHANGED
    
    | @@ -74,7 +74,7 @@ module Vedeu | |
| 74 74 | 
             
                  # Send the view to the renderers. If the output is a
         | 
| 75 75 | 
             
                  # {Vedeu::Models::Escape} object (typical when showing or
         | 
| 76 76 | 
             
                  # hiding the cursor) then we bypass the
         | 
| 77 | 
            -
                  # {Vedeu::Terminal | 
| 77 | 
            +
                  # {Vedeu::Buffers::Terminal} and write directly to the terminal
         | 
| 78 78 | 
             
                  # because escape sequences only make sense to the terminal and
         | 
| 79 79 | 
             
                  # not other renderers.
         | 
| 80 80 | 
             
                  #
         | 
| @@ -100,12 +100,12 @@ module Vedeu | |
| 100 100 |  | 
| 101 101 | 
             
                  # @return [Array]
         | 
| 102 102 | 
             
                  def buffer_update!
         | 
| 103 | 
            -
                    Vedeu::Terminal | 
| 103 | 
            +
                    Vedeu::Buffers::Terminal.update(output)
         | 
| 104 104 | 
             
                  end
         | 
| 105 105 |  | 
| 106 106 | 
             
                  # @return [Array]
         | 
| 107 107 | 
             
                  def buffer_write!
         | 
| 108 | 
            -
                    Vedeu::Terminal | 
| 108 | 
            +
                    Vedeu::Buffers::Terminal.write(output)
         | 
| 109 109 | 
             
                  end
         | 
| 110 110 |  | 
| 111 111 | 
             
                  # @return [Array<String>]
         | 
| @@ -18,7 +18,7 @@ module Vedeu | |
| 18 18 | 
             
                # @return [Array<void>]
         | 
| 19 19 | 
             
                def clear
         | 
| 20 20 | 
             
                  storage.map do |renderer|
         | 
| 21 | 
            -
                    Vedeu.log(type:    : | 
| 21 | 
            +
                    Vedeu.log(type:    :render,
         | 
| 22 22 | 
             
                              message: "Clearing via #{renderer.class.name}".freeze)
         | 
| 23 23 |  | 
| 24 24 | 
             
                    Thread.new(renderer) do
         | 
| @@ -51,7 +51,7 @@ module Vedeu | |
| 51 51 | 
             
                # @return [Array<void>]
         | 
| 52 52 | 
             
                def render(output)
         | 
| 53 53 | 
             
                  storage.map do |renderer|
         | 
| 54 | 
            -
                    Vedeu.log(type:    : | 
| 54 | 
            +
                    Vedeu.log(type:    :render,
         | 
| 55 55 | 
             
                              message: "Rendering via #{renderer.class.name}".freeze)
         | 
| 56 56 |  | 
| 57 57 | 
             
                    Thread.new(renderer) do
         |