From 698f2dc400aea41f40a9eccc52b7fdc9db856884 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 6 Feb 2018 22:33:22 +0800 Subject: add pdpaste and pdcopy on linux --- xmake/core/base/os.lua | 7 +++++++ xmake/core/ui/textedit.lua | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 7b3bceca3..3841a9d89 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -824,6 +824,11 @@ function os.pbpaste() if ok then return result end + elseif os.host() == "linux" then + local ok, result = os.iorun("xsel --clipboard --output") + if ok then + return result + end else -- TODO end @@ -833,6 +838,8 @@ end function os.pbcopy(data) if os.host() == "macosx" then os.run("bash -c \"echo '" .. data .. "' | pbcopy\"") + elseif os.host() == "linux" then + os.run("bash -c \"echo '" .. data .. "' | xsel --clipboard --input\"") else -- TODO end diff --git a/xmake/core/ui/textedit.lua b/xmake/core/ui/textedit.lua index ea5222140..ed1a92221 100644 --- a/xmake/core/ui/textedit.lua +++ b/xmake/core/ui/textedit.lua @@ -91,6 +91,12 @@ function textedit:event_on(e) self:text_set(text:sub(1, #text - 1)) end return true + elseif e.key_name == "CtrlV" then + local pastetext = os.pbpaste() + if pastetext then + self:text_set(self:text() .. pastetext) + end + return true end end -- cgit v1.3.1