Module: Clipboard::Java

Extended by:
Java
Includes:
Implementation
Included in:
Java
Defined in:
lib/clipboard/java.rb

Overview

Basic java clipboard access (jruby). No fun to use on X.

Constant Summary collapse

FLAVOR =
::Java::JavaAwtDatatransfer::DataFlavor.stringFlavor

Instance Method Summary collapse

Methods included from Implementation

#clear

Instance Method Details

#copy(data) ⇒ Object



13
14
15
16
17
18
# File 'lib/clipboard/java.rb', line 13

def copy(data, **)
  selection_string = ::Java::JavaAwtDatatransfer::StringSelection.new data
  ::Java::JavaAwt::Toolkit.default_toolkit.system_clipboard.set_contents selection_string, nil

  true
end

#paste(_ = nil) ⇒ Object



20
21
22
23
24
# File 'lib/clipboard/java.rb', line 20

def paste(_ = nil, **)
  ::Java::JavaAwt::Toolkit.default_toolkit.system_clipboard.get_data(FLAVOR)
rescue
  ''
end