Module: RelinePac::Packages::Clipboard::Methods

Defined in:
lib/reline_pac/packages/clipboard.rb

Overview

Methods adds clipboard operations to Reline::LineEditor.

Instance Method Summary collapse

Instance Method Details

#pbcopy_kill(_key) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/reline_pac/packages/clipboard.rb', line 14

def pbcopy_kill(_key)
  cut_text = line.byteslice(byte_pointer..-1)
  return unless cut_text && !cut_text.empty?

  ::IO.popen('pbcopy', 'w') { |io| io.write cut_text }
  delete_text(byte_pointer..-1)
end

#pbpaste(_key) ⇒ Object



9
10
11
12
# File 'lib/reline_pac/packages/clipboard.rb', line 9

def pbpaste(_key)
  text = `pbpaste`.chomp
  insert_text(text)
end