Sha256: 4b890db365bd14af94176cffed68913fc5a0ed764996fa6e3da5c30fe33a9a3e
Contents?: true
Size: 1.22 KB
Versions: 76
Compression:
Stored size: 1.22 KB
Contents
module Redcar class ApplicationSWT # The controller for a Clipboard. In SWT a clipboard can only contain # one piece of text, but that's ok because inside Redcar all the Paste # commands are implemented directly from the model. This is only useful # for copying/pasting between other applications and Redcar. class Clipboard attr_accessor :last_set def initialize(model) @model = model @model.controller = self @swt_clipboard = Swt::DND::Clipboard.new(Redcar.app.controller.display) attach_model_listeners if contents = get_contents @model.silently_add([contents]) end end def plain_text_data_type Swt::DND::TextTransfer.get_instance end def attach_model_listeners @model.add_listener(:added_internal) do |text| text = text.join("\n") @last_set = text @swt_clipboard.set_contents([text].to_java(:object), [plain_text_data_type].to_java(Swt::DND::Transfer)) end end def changed? @last_set != get_contents end def get_contents @swt_clipboard.get_contents(plain_text_data_type) end end end end
Version data entries
76 entries across 76 versions & 2 rubygems