Class: Groonga::DatabaseViewerGtk::Clipboard

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga/database-viewer-gtk/clipboard.rb

Class Method Summary collapse

Class Method Details

.clipboardObject



38
39
40
# File 'lib/groonga/database-viewer-gtk/clipboard.rb', line 38

def clipboard
  Gtk::Clipboard.get(Gdk::Selection::CLIPBOARD)
end

.copy_to_clipboard(text) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/groonga/database-viewer-gtk/clipboard.rb', line 23

def copy_to_clipboard(text)
  if /darwin/ =~ RUBY_PLATFORM
    require "tempfile"
    Tempfile.open(["clipcellar", "w"]) do |file|
      text.each_line do |line|
        file.puts(line)
      end
      file.flush
      system("pbcopy < #{file.path}")
    end
  else
    clipboard.text = text
  end
end