From 5213835970020ffe16ae550132d2ffb63cdfee1d Mon Sep 17 00:00:00 2001 From: Amanda Cameron Date: Thu, 21 May 2020 15:02:46 -0400 Subject: [PATCH] clipboard: Make the clipboard service work under the new service sys This also adds a [.editorconfig](https://editorconfig.org/) and adds apidoc.md to the gitignore. --- .editorconfig | 5 +++++ .gitignore | 1 + service/clipboard.lua | 24 +++++++++++++++--------- 3 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f889f30 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +root = true + +[*.lua] +indent_style = space +indent_size = 1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 03fadf9..1616417 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.cpio *.af +apidoc.md /target /doc diff --git a/service/clipboard.lua b/service/clipboard.lua index 6ccc07f..99c8c04 100644 --- a/service/clipboard.lua +++ b/service/clipboard.lua @@ -1,11 +1,17 @@ -local lc = computer.uptime() _G.clip = "" -while true do - local eT = {coroutine.yield()} - if eT[1] == "clipboard" then - if computer.uptime() > lc + 5 then - _G.clip = "" - end - _G.clip = _G.clip .. eT[3] - end + +function start() + return os.spawn(function() + local lc + while true do + local eT = {coroutine.yield()} + if eT[1] == "clipboard" then + if computer.uptime() > lc + 5 then + _G.clip = "" + end + lc = computer.uptime() + _G.clip = _G.clip .. eT[3] + end + end + end) end