diff --git a/R2H2.lua b/R2H2.lua index 7393a25..5d1a219 100644 --- a/R2H2.lua +++ b/R2H2.lua @@ -1,4 +1,17 @@ --functions +function CopyToClipboard(textString) + outClipFile, err = io.open("clipboardTempFile",'w') + if err then + print("[Error Opening Clipboard Temporary File for Writing]") + return + end + outClipFile:write(textString,'\n') + outClipFile:close() + command = 'cat "' .. "clipboardTempFile" .. '" | xclip -selection clipboard &' + os.execute(command) + os.execute("rm clipboardTempFile") +end + function PrintPosition(string) local print_text = "" for i = 1, string.len(string) do @@ -41,11 +54,11 @@ function convertToHeonian(text) local transcribed = false local transcribed_text = "" - -- verbose? local debug = false - + local autocopy = false for _, v in pairs(arg) do if v == "-v" or v == "--verbose" then debug = true end + if v == "-c" or v == "--copy" then autocopy = true end end -- we check if it's necessary to check anything at all @@ -218,6 +231,7 @@ function convertToHeonian(text) end -- output + if autocopy then CopyToClipboard(transcribed_text) end return transcribed_text end end \ No newline at end of file