1
0
mirror of https://github.com/kepler155c/opus synced 2025-02-06 04:00:03 +00:00
opus/sys/autorun/clipboard.lua

27 lines
572 B
Lua
Raw Normal View History

local Util = require('opus.util')
2017-10-14 03:41:54 -04:00
local kernel = _G.kernel
local keyboard = _G.device.keyboard
2018-01-21 05:44:13 -05:00
local os = _G.os
local textutils = _G.textutils
kernel.hook('clipboard_copy', function(_, args)
keyboard.clipboard = args[1]
2017-10-14 03:41:54 -04:00
end)
local function queuePaste()
local data = keyboard.clipboard
2018-01-24 17:39:38 -05:00
if type(data) == 'table' then
local s, m = pcall(textutils.serialize, data)
data = s and m or Util.tostring(data)
2018-01-24 17:39:38 -05:00
end
2018-01-24 17:39:38 -05:00
if data then
os.queueEvent('paste', data)
2018-01-21 05:44:13 -05:00
end
end
kernel.hook('clipboard_paste', queuePaste)
keyboard.addHotkey('shift-paste', queuePaste)