class Diakonos::ClipboardKlipper
Same interface as Diakonos::Clipboard
, except interacts with Klipper in KDE 3 (via dcop)
Public Class Methods
new()
click to toggle source
# File lib/diakonos/clipboard-klipper.rb, line 6 def initialize end
Public Instance Methods
add_clip( text )
click to toggle source
text is an array of Strings Returns true iff a clip was added, and only non-nil text can be added.
# File lib/diakonos/clipboard-klipper.rb, line 40 def add_clip( text ) return false if text.nil? send_to_klipper text end
append_to_clip( text )
click to toggle source
text is an array of Strings (lines) Appends the lines to the current clip. If no current clip, then a new clip is created. Returns true iff the text was successfully appended.
# File lib/diakonos/clipboard-klipper.rb, line 53 def append_to_clip( text ) return false if text.nil? last_clip = clip last_clip.pop if last_clip[ -1 ] == "" send_to_klipper last_clip + text end
clip()
click to toggle source
# File lib/diakonos/clipboard-klipper.rb, line 30 def clip text = `dcop klipper klipper getClipboardContents`.split( "\n", -1 ) # getClipboardContents puts an extra newline on end; pop it off. text.pop text end
each()
click to toggle source
no-op.
# File lib/diakonos/clipboard-klipper.rb, line 46 def each end
send_to_klipper( text )
click to toggle source
Returns true iff some text was copied to klipper.
# File lib/diakonos/clipboard-klipper.rb, line 10 def send_to_klipper( text ) return false if text.nil? clip_filename = write_to_clip_file( text.join( "\n" ) ) # A little shell sorcery to ensure the shell doesn't strip off trailing newlines. `clipping=$(cat #{clip_filename};printf "_"); dcop klipper klipper setClipboardContents "${clipping%_}"` true end
write_to_clip_file( text )
click to toggle source
# File lib/diakonos/clipboard-klipper.rb, line 20 def write_to_clip_file( text ) clip_filename = $diakonos.diakonos_home + "/clip.txt" File.open( clip_filename, "w" ) do |f| f.print text end clip_filename end