File: current.rb

package info (click to toggle)
ruby-neovim 0.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 548 kB
  • sloc: ruby: 4,178; sh: 23; makefile: 4
file content (74 lines) | stat: -rw-r--r-- 1,645 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require "neovim/buffer"
require "neovim/tabpage"
require "neovim/window"

module Neovim
  # Support for +Client#current+ chaining.
  #
  # @see Client#current
  class Current
    def initialize(session)
      @session = session
    end

    # Get the line under the cursor.
    #
    # @return [String]
    def line
      @session.request(:nvim_get_current_line)
    end

    # Set the line under the cursor.
    #
    # @param line [String] The target line contents.
    # @return [String]
    def line=(line)
      @session.request(:nvim_set_current_line, line)
    end

    # Get the active buffer.
    #
    # @return [Buffer]
    def buffer
      @session.request(:nvim_get_current_buf)
    end

    # Set the active buffer.
    #
    # @param buffer [Buffer, Integer] The target buffer or index.
    # @return [Buffer, Integer]
    def buffer=(buffer)
      @session.request(:nvim_set_current_buf, buffer)
    end

    # Get the active window.
    #
    # @return [Window]
    def window
      @session.request(:nvim_get_current_win)
    end

    # Set the active window.
    #
    # @param window [Window, Integer] The target window or index.
    # @return [Window, Integer]
    def window=(window)
      @session.request(:nvim_set_current_win, window)
    end

    # Get the active tabpage.
    #
    # @return [Tabpage]
    def tabpage
      @session.request(:nvim_get_current_tabpage)
    end

    # Set the active tabpage.
    #
    # @param tabpage [Tabpage, Integer] The target tabpage or index.
    # @return [Tabpage, Integer]
    def tabpage=(tabpage)
      @session.request(:nvim_set_current_tabpage, tabpage)
    end
  end
end