Refer to the description below on how to use the macro.
Code: Select all
--
-- Name: Mouse Click Append Line to Clipboard
--
-- Author: Jussi Jumppanen
--
-- Language: Lua Macro
--
-- Description: The click event macro will append the current line of
-- text to the clipboard.
--
-- To use the macro use the Options, Editor Optiosn menu
-- and in the Triggers panel add this to the Mouse Click
-- trigger:
--
-- $zud\zScript\event_mouse_copy.lua
--
-- That line assumes the macro is saved to the zScript
-- folder as the event_mouse_copy.lua file.
--
function key_macro()
if (is_document() == 1) then
-- look for the line number
for i = 1, argc(), 1 do
-- Mouse Y argument will hold the line number
local index, length, line = string.find(argv(i - 1), "MouseY=([%d:]+)")
-- look for the line number argument
if line ~= nil then
-- append the line of text to the clipboard text
local text = get_clipboard_text() .. get_line_text(line) .. "\n"
-- put the combined text back into the clipboard
set_clipboard_text(text)
break;
end
end
else
-- macro only works for documents
message("This macro only works for document files.");
beep();
end
-- fire the default handler any any case
set_return_code(0)
end
key_macro() -- run the macro