Class: Neovim::WriteBuf

Inherits:
WriteStd show all
Defined in:
lib/neovim/output.rb

Instance Method Summary collapse

Methods inherited from WriteStd

redirect

Methods inherited from Write

#<<, #flush, open, #print, #puts

Constructor Details

#initialize(*args, whole: nil, top: nil) ⇒ WriteBuf

Returns a new instance of WriteBuf.



113
114
115
116
117
# File 'lib/neovim/output.rb', line 113

def initialize *args, whole: nil, top: nil
  super
  @lines, @last = [], ""
  @whole, @top = whole, top
end

Instance Method Details

#finishObject



128
129
130
131
132
133
134
135
136
137
138
# File 'lib/neovim/output.rb', line 128

def finish
  if @last.notempty? then
    @lines.push @last
    @last = nil
  end
  if @whole then
    @client.buf_set_lines 0, 0, -1, true, @lines
  else
    @client.put @lines, "l", true, !@top
  end
end

#write(*args) ⇒ Object



118
119
120
121
122
123
124
125
126
127
# File 'lib/neovim/output.rb', line 118

def write *args
  args.each { |a| @last << a.to_s }
  loop do
    n, r = @last.split $/, 2
    r or break
    @lines.push n
    @last = r
  end
  nil
end