Sha256: e7a0b3493942e3358e8c78a8ffd9e9c8e4e1978da56ac9d8dd7fc17f05d85524
Contents?: true
Size: 866 Bytes
Versions: 1
Compression:
Stored size: 866 Bytes
Contents
# frozen_string_literal: true require "clipboard" module Textbringer module Commands CLIPBOARD_AVAILABLE = Clipboard.implementation.name != :Linux || ENV["DISPLAY"] if CLIPBOARD_AVAILABLE GLOBAL_MAP.define_key("\ew", :clipboard_copy_region) GLOBAL_MAP.define_key("\C-w", :clipboard_kill_region) GLOBAL_MAP.define_key("\C-y", :clipboard_yank) end define_command(:clipboard_copy_region) do copy_region Clipboard.copy(KILL_RING.current) end define_command(:clipboard_kill_region) do kill_region Clipboard.copy(KILL_RING.current) end define_command(:clipboard_yank) do s = Clipboard.paste.encode(Encoding::UTF_8) if KILL_RING.empty? || KILL_RING.current != s KILL_RING.push(s) end yank Controller.current.this_command = :yank end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
textbringer-0.1.5 | lib/textbringer/commands/clipboard.rb |