1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-14 04:34:49 +00:00
opus/sys/extensions/clipboard.lua
kepler155c@gmail.com 9f5c58cc4c web run applications
2017-09-05 21:21:43 -04:00

44 lines
777 B
Lua

if _G.clipboard then
return
end
requireInjector(getfenv(1))
local Util = require('util')
_G.clipboard = { internal, data }
function clipboard.getData()
return clipboard.data
end
function clipboard.setData(data)
clipboard.data = data
if data then
clipboard.useInternal(true)
end
end
function clipboard.getText()
if clipboard.data then
return Util.tostring(clipboard.data)
end
end
function clipboard.isInternal()
return clipboard.internal
end
function clipboard.useInternal(mode)
if mode ~= clipboard.internal then
clipboard.internal = mode
os.queueEvent('clipboard_mode', mode)
end
end
if multishell and multishell.addHotkey then
multishell.addHotkey(20, function()
clipboard.useInternal(not clipboard.isInternal())
end)
end