Sha256: 7b13d27106ec76d2c535cdd995a0c4b91ca0f509bd49be90df3d7e0f891b7726

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

require "neovim/buffer"
require "neovim/tabpage"
require "neovim/window"

module Neovim
  # Support for +client.current+ chaining.
  #
  # @see Client#current
  # @api private
  class Current
    def initialize(session)
      @session = session
      @range = (0..-1)
    end

    # @return [String]
    def line
      @session.request(:vim_get_current_line)
    end

    # @param line [String] The target line contents.
    # @return [String]
    def line=(line)
      @session.request(:vim_set_current_line, line)
    end

    # @return [Buffer]
    def buffer
      @session.request(:vim_get_current_buffer).tap do |buf|
        buf.range = @range
      end
    end

    # @param buffer [Buffer, Fixnum] The target buffer or index.
    # @return [Buffer, Fixnum]
    def buffer=(buffer)
      @session.request(:vim_set_current_buffer, buffer)
    end

    # @return [Window]
    def window
      @session.request(:vim_get_current_window)
    end

    # @param window [Window, Fixnum] The target window or index.
    # @return [Window, Fixnum]
    def window=(window)
      @session.request(:vim_set_current_window, window)
    end

    # @return [Tabpage]
    def tabpage
      @session.request(:vim_get_current_tabpage)
    end

    # @param tabpage [Tabpage, Fixnum] The target tabpage or index.
    # @return [Tabpage, Fixnum]
    def tabpage=(tabpage)
      @session.request(:vim_set_current_tabpage, tabpage)
    end

    # @param range [Range] The target range
    def range=(range)
      @range = range
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
neovim-0.2.5 lib/neovim/current.rb
neovim-0.2.4 lib/neovim/current.rb
neovim-0.2.3 lib/neovim/current.rb