Module: Clipboard::Java

Extended by:
Java
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

Instance Method Details

#clearObject



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

def clear
  copy ''
end

#copy(text) ⇒ Object



10
11
12
13
14
# File 'lib/clipboard/java.rb', line 10

def copy(text)
  selection_string = ::Java::JavaAwtDatatransfer::StringSelection.new text
  ::Java::JavaAwt::Toolkit.default_toolkit.system_clipboard.set_contents selection_string, nil
  paste
end

#paste(_ = nil) ⇒ Object



16
17
18
19
20
# File 'lib/clipboard/java.rb', line 16

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