Sha256: 8bb0d73153c295677a0de96a2c60f802ca8f14932f5f6fefb3929f56990237f7
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true require_relative "implementation" module Clipboard module Osc52 include Implementation extend self CLIPBOARDS = %w[clipboard primary].freeze OSC52 = "]52;%<selection_option>s;%<data_base64>s" def copy(data, clipboard: "all") selections = clipboard.to_s == "all" ? CLIPBOARDS : [clipboard] selections.each{ |selection| raise ArgumentError, "unknown clipboard selection" unless CLIPBOARDS.include?(selection) print OSC52 % { selection_option: selection == "primary" ? "p" : "c", data_base64: [data].pack("m0"), } } true end def clear(clipboard: "all") selections = clipboard.to_s == "all" ? CLIPBOARDS : [clipboard] selections.each{ |selection| raise ArgumentError, "unknown clipboard selection" unless CLIPBOARDS.include?(selection) print OSC52 % { selection_option: selection == "primary" ? "p" : "c", data_base64: ?! # anything non-base64 / question mark clears } } true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clipboard-2.0.0 | lib/clipboard/osc52.rb |