2019-06-28 17:50:02 +00:00
|
|
|
local Util = require('opus.util')
|
2017-10-14 07:41:54 +00:00
|
|
|
|
2018-01-10 21:46:37 +00:00
|
|
|
local kernel = _G.kernel
|
|
|
|
local keyboard = _G.device.keyboard
|
2018-01-21 10:44:13 +00:00
|
|
|
local os = _G.os
|
2018-01-10 21:46:37 +00:00
|
|
|
local textutils = _G.textutils
|
2017-09-05 06:09:31 +00:00
|
|
|
|
2018-01-10 21:46:37 +00:00
|
|
|
kernel.hook('clipboard_copy', function(_, args)
|
2019-07-02 14:19:08 +00:00
|
|
|
keyboard.clipboard = args[1]
|
2017-10-14 07:41:54 +00:00
|
|
|
end)
|
|
|
|
|
2018-01-24 22:39:38 +00:00
|
|
|
keyboard.addHotkey('shift-paste', function()
|
2019-07-02 14:19:08 +00:00
|
|
|
local data = keyboard.clipboard
|
|
|
|
|
2018-01-24 22:39:38 +00:00
|
|
|
if type(data) == 'table' then
|
|
|
|
local s, m = pcall(textutils.serialize, data)
|
2019-07-02 14:19:08 +00:00
|
|
|
data = s and m or Util.tostring(data)
|
2018-01-24 22:39:38 +00:00
|
|
|
end
|
2019-07-02 14:19:08 +00:00
|
|
|
|
2018-01-24 22:39:38 +00:00
|
|
|
if data then
|
|
|
|
os.queueEvent('paste', data)
|
2018-01-21 10:44:13 +00:00
|
|
|
end
|
2017-10-14 07:41:54 +00:00
|
|
|
end)
|